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.ExprChar; 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 ExprCharImpl extends UnicastRemoteObject implements ExprChar, TIRImplObject { 18 char v; 19 ExprOperKindImpl eok; 20 DefinitionKindImpl defKindImpl; 21 StateKindImpl stKindImpl; 22 23 public ExprCharImpl(char value) throws RemoteException { 24 v = value; 25 eok = new ExprOperKindImpl(ExprOperKind.eok_char); 26 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 27 stKindImpl = new StateKindImpl(StateKind.sk_work); 28 } 29 30 public ExprCharImpl() throws RemoteException { 31 v = 0; 32 eok = new ExprOperKindImpl(ExprOperKind.eok_char); 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 char value() throws RemoteException { 48 return v; 49 } 50 51 public void value(char value) { 52 v = value; 53 } 54 55 public ExprOperKind get_eok_kind() throws RemoteException { 56 return (ExprOperKind) eok; 57 } 58 59 public ExprOperDef calculate() throws RemoteException , TIRExceptCalculate { 60 throw new TIRExceptCalculate("Can't calculate char."); 61 } 62 63 public void save(Storage st) throws RemoteException , TIRExceptStorage { 64 try { 65 st.curOutFile.writeInt(eok.value()); 66 st.curOutFile.writeChar(v); 67 } catch (IOException e) { 68 throw new TIRExceptStorage("Can't write in directory "+st.current+"."); 69 } 70 } 71 72 public void load(Storage st) throws RemoteException , TIRExceptStorage { 73 try { 74 v = st.curInFile.readChar(); 75 } catch (IOException e) { 76 throw new TIRExceptStorage("Can't read in directory "+st.current+"."); 77 } 78 } 79 80 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage { 81 ; 82 } 83 84 public boolean isNew() { 85 return (stKindImpl.value()==StateKind.sk_work); 86 } 87 88 public void canCommit() throws RemoteException , TIRExceptCommit {;} 89 90 public void doCommit(Container in, Repository rep) throws RemoteException { 91 if (stKindImpl.value()==StateKind.sk_work) 92 stKindImpl.toNormal(); 93 } 94 95 public void doAbort(long workId) throws RemoteException {} 96 } 97 | Popular Tags |