1 2 package SOFA.SOFAnode.Made.TIR.Impl; 3 import java.io.IOException ; 4 import java.rmi.RemoteException ; 5 import java.rmi.server.UnicastRemoteObject ; 6 7 import SOFA.SOFAnode.Made.TIR.Container; 8 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 9 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 10 import SOFA.SOFAnode.Made.TIR.FixedDef; 11 import SOFA.SOFAnode.Made.TIR.Repository; 12 import SOFA.SOFAnode.Made.TIR.StateKind; 13 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 14 15 public class FixedDefImpl extends UnicastRemoteObject implements FixedDef, TIRImplObject { 16 ExprOperDef dig; 17 ExprOperDef sc; 18 DefinitionKindImpl defKindImpl; 19 StateKindImpl stKindImpl; 20 21 public FixedDefImpl(ExprOperDef digits, ExprOperDef scale) throws RemoteException { 22 dig = digits; 23 sc = scale; 24 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Fixed); 25 stKindImpl = new StateKindImpl(StateKind.sk_work); 26 } 27 28 public FixedDefImpl() throws RemoteException { 29 dig = null; 30 sc = null; 31 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Fixed); 32 stKindImpl = new StateKindImpl(StateKind.sk_normal); 33 } 34 35 public ExprOperDef digits() throws RemoteException { 36 return dig; 37 } 38 39 public ExprOperDef scale() throws RemoteException { 40 return sc; 41 } 42 43 44 public DefinitionKind get_def_kind() throws RemoteException { 45 return (DefinitionKind) defKindImpl; 46 } 47 48 49 public StateKind get_state() throws RemoteException { 50 return (StateKind) stKindImpl; 51 } 52 53 54 public void load(Storage st) throws RemoteException , TIRExceptStorage { 55 dig = Storage.readExprOperDef(st); 56 sc = Storage.readExprOperDef(st); 57 } 58 59 public void save(Storage st) throws RemoteException , TIRExceptStorage { 60 try { 61 Storage.writeExprOperDef(st,dig); 62 Storage.writeExprOperDef(st,sc); 63 } catch (IOException e) { 64 throw new TIRExceptStorage("Can't write in file "+st.currentFile+"."); 65 } 66 } 67 68 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage { 69 ((TIRImplObject) dig).postLoad(r); 70 ((TIRImplObject) sc).postLoad(r); 71 } 72 73 public boolean isNew() { 74 return (stKindImpl.value()==StateKind.sk_work); 75 } 76 77 public void canCommit() throws RemoteException , TIRExceptCommit {;} 78 79 public void doCommit(Container in, Repository rep) throws RemoteException { 80 if (stKindImpl.value()==StateKind.sk_normal) 81 return; 82 if (isNew()) { 83 stKindImpl.toNormal(); 84 ((TIRImplObject) dig).doCommit(in,rep); 85 ((TIRImplObject) sc).doCommit(in,rep); 86 } 87 } 88 89 public void doAbort(long workId) throws RemoteException {} 90 } 91 | Popular Tags |