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.ExprOperKind; 11 import SOFA.SOFAnode.Made.TIR.ExprProperty; 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 ExprPropertyImpl extends UnicastRemoteObject implements ExprProperty, TIRImplObject { 18 String prop; 19 ExprOperKindImpl eok; 20 DefinitionKindImpl defKindImpl; 21 StateKindImpl stKindImpl; 22 23 public ExprPropertyImpl(String property) throws RemoteException { 24 prop = property; 25 eok = new ExprOperKindImpl(ExprOperKind.eok_property); 26 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 27 stKindImpl = new StateKindImpl(StateKind.sk_work); 28 } 29 30 public ExprPropertyImpl() throws RemoteException { 31 prop = null; 32 eok = new ExprOperKindImpl(ExprOperKind.eok_property); 33 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 34 stKindImpl = new StateKindImpl(StateKind.sk_normal); 35 } 36 37 38 public DefinitionKind get_def_kind() throws RemoteException { 39 return (DefinitionKind) defKindImpl; 40 } 41 42 43 public StateKind get_state() throws RemoteException { 44 return (StateKind) stKindImpl; 45 } 46 47 public String ref_prop() throws RemoteException { 48 return prop; 49 } 50 51 public ExprOperDef calculate() throws RemoteException , TIRExceptCalculate { 52 throw new TIRExceptCalculate("Can't calculate property."); 53 } 54 55 public ExprOperKind get_eok_kind() throws RemoteException { 56 return (ExprOperKind) eok; 57 } 58 59 public void save(Storage st) throws RemoteException , TIRExceptStorage { 60 try { 61 st.curOutFile.writeInt(eok.value()); 62 Storage.writeString(st.curOutFile, prop); 63 } catch (IOException e) { 64 throw new TIRExceptStorage("Can't write in directory "+st.current+"."); 65 } 66 } 67 68 public void load(Storage st) throws RemoteException , TIRExceptStorage { 69 try { 70 prop = Storage.readString(st.curInFile); 71 } catch (IOException e) { 72 throw new TIRExceptStorage("Can't read in directory "+st.current+"."); 73 } 74 } 75 76 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage {} 77 78 public boolean isNew() { 79 return (stKindImpl.value()==StateKind.sk_work); 80 } 81 82 public void canCommit() throws RemoteException , TIRExceptCommit {;} 83 84 public void doCommit(Container in, Repository rep) throws RemoteException { 85 if (stKindImpl.value()==StateKind.sk_work) { 86 stKindImpl.toNormal(); 87 } 88 } 89 90 public void doAbort(long workId) throws RemoteException {} 91 } 92 | Popular Tags |