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.ExprFixed; 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.TIRExceptCommit; 15 16 public class ExprFixedImpl extends UnicastRemoteObject implements ExprFixed, TIRImplObject { 17 java.math.BigDecimal v; 18 int dig; 19 int sc; 20 ExprOperKindImpl eok; 21 DefinitionKindImpl defKindImpl; 22 StateKindImpl stKindImpl; 23 24 public ExprFixedImpl(java.math.BigDecimal value, int digits, int scale) throws RemoteException { 25 v = value; 26 dig = digits; 27 sc = scale; 28 eok = new ExprOperKindImpl(ExprOperKind.eok_fixed); 29 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 30 stKindImpl = new StateKindImpl(StateKind.sk_work); 31 } 32 33 public ExprFixedImpl() throws RemoteException { 34 v = null; 35 dig = 0; 36 sc = 0; 37 eok = new ExprOperKindImpl(ExprOperKind.eok_fixed); 38 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression); 39 stKindImpl = new StateKindImpl(StateKind.sk_normal); 40 } 41 42 43 public DefinitionKind get_def_kind() throws RemoteException { 44 return (DefinitionKind) defKindImpl; 45 } 46 47 48 public StateKind get_state() throws RemoteException { 49 return (StateKind) stKindImpl; 50 } 51 52 public java.math.BigDecimal value() throws RemoteException { 53 return v; 54 } 55 56 public int digits() throws RemoteException { 57 return dig; 58 } 59 60 public int scale() throws RemoteException { 61 return sc; 62 } 63 64 public ExprOperKind get_eok_kind() throws RemoteException { 65 return (ExprOperKind) eok; 66 } 67 68 public ExprOperDef calculate() throws RemoteException { 69 return this; 70 } 71 72 public void save(Storage st) throws RemoteException , TIRExceptStorage { 73 try { 74 st.curOutFile.writeInt(eok.value()); 75 Storage.writeString(st.curOutFile,v.toString()); 76 st.curOutFile.writeInt(dig); 77 st.curOutFile.writeInt(sc); 78 } catch (IOException e) { 79 throw new TIRExceptStorage("Can't write in file "+st.currentFile+"."); 80 } 81 } 82 83 public void load(Storage st) throws RemoteException , TIRExceptStorage { 84 try { 85 String s = Storage.readString(st.curInFile); 86 v = new java.math.BigDecimal (s); 87 dig = st.curInFile.readInt(); 88 sc = st.curInFile.readInt(); 89 } catch (IOException e) { 90 throw new TIRExceptStorage("Can't read in file "+st.currentFile+"."); 91 } 92 } 93 94 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage { 95 ; 96 } 97 98 public boolean isNew() { 99 return (stKindImpl.value()==StateKind.sk_work); 100 } 101 102 public void canCommit() throws RemoteException , TIRExceptCommit {;} 103 104 public void doCommit(Container in, Repository rep) throws RemoteException { 105 if (stKindImpl.value()==StateKind.sk_work) 106 stKindImpl.toNormal(); 107 } 108 109 public void doAbort(long workId) throws RemoteException {} 110 } 111 | Popular Tags |