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.ExprDefault; 10 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 11 import SOFA.SOFAnode.Made.TIR.ExprOperKind; 12 import SOFA.SOFAnode.Made.TIR.Repository; 13 import SOFA.SOFAnode.Made.TIR.StateKind; 14 import SOFA.SOFAnode.Made.TIR.TIRExceptCalculate; 15 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 16 17 public class ExprDefaultImpl extends UnicastRemoteObject implements ExprDefault, TIRImplObject { 18 ExprOperKindImpl eok; 19 DefinitionKindImpl defKindImpl; 20 StateKindImpl stKindImpl; 21 22 public ExprDefaultImpl(int state) throws RemoteException { 23 eok = new ExprOperKindImpl(ExprOperKind.eok_default); 24 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 25 stKindImpl = new StateKindImpl(state); 26 } 27 28 29 public DefinitionKind get_def_kind() throws RemoteException { 30 return (DefinitionKind) defKindImpl; 31 } 32 33 34 public StateKind get_state() throws RemoteException { 35 return (StateKind) stKindImpl; 36 } 37 38 public ExprOperKind get_eok_kind() throws RemoteException { 39 return (ExprOperKind) eok; 40 } 41 42 public ExprOperDef calculate() throws RemoteException , TIRExceptCalculate { 43 throw new TIRExceptCalculate("Can't calculate default."); 44 } 45 46 public void save(Storage st) throws RemoteException , TIRExceptStorage { 47 try { 48 st.curOutFile.writeInt(eok.value()); 49 } catch (IOException e) { 50 throw new TIRExceptStorage("Can't write in directory "+st.current+"."); 51 } 52 } 53 54 public void load(Storage st) throws RemoteException , TIRExceptStorage {} 55 56 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage {} 57 58 public boolean isNew() { 59 return (stKindImpl.value()==StateKind.sk_work); 60 } 61 62 public void canCommit() throws RemoteException , TIRExceptCommit {} 63 64 public void doCommit(Container in, Repository rep) throws RemoteException { 65 if (stKindImpl.value()==StateKind.sk_work) 66 stKindImpl.toNormal(); 67 } 68 69 public void doAbort(long workId) throws RemoteException {} 70 } 71 | Popular Tags |