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.EnumMember; 10 import SOFA.SOFAnode.Made.TIR.Repository; 11 import SOFA.SOFAnode.Made.TIR.StateKind; 12 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 13 14 public class EnumMemberImpl extends UnicastRemoteObject implements EnumMember, TIRImplObject { 15 String nm; 16 DefinitionKindImpl defKindImpl; 17 StateKindImpl stKindImpl; 18 19 EnumMemberImpl normal; 20 21 public EnumMemberImpl(String name) throws RemoteException { 22 nm = name; 23 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_EnumMember); 24 stKindImpl = new StateKindImpl(StateKind.sk_work); 25 normal = null; 26 } 27 28 29 public EnumMemberImpl() throws RemoteException { 30 nm = null; 31 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_EnumMember); 32 stKindImpl = new StateKindImpl(StateKind.sk_normal); 33 normal = null; 34 } 35 36 public EnumMemberImpl(EnumMemberImpl a) throws RemoteException { 37 nm = a.nm; 38 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_EnumMember); 39 stKindImpl = new StateKindImpl(StateKind.sk_work); 40 normal = a; 41 } 42 43 public String name() throws RemoteException { 44 return nm; 45 } 46 47 48 public DefinitionKind get_def_kind() throws RemoteException { 49 return (DefinitionKind) defKindImpl; 50 } 51 52 53 public StateKind get_state() throws RemoteException { 54 return (StateKind) stKindImpl; 55 } 56 57 public void load(Storage st) throws RemoteException , TIRExceptStorage { 58 try { 59 nm = Storage.readString(st.curInFile); 60 } catch (IOException e) { 61 throw new TIRExceptStorage("Can't read in file "+st.currentFile+"."); 62 } 63 } 64 65 public void save(Storage st) throws RemoteException , TIRExceptStorage { 66 try { 67 Storage.writeString(st.curOutFile,nm); } catch (IOException e) { 69 throw new TIRExceptStorage("Can't write in file "+st.currentFile+"."); 70 } 71 } 72 73 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage { 74 ; 75 } 76 77 public boolean isNew() { 78 return ((stKindImpl.value()==StateKind.sk_work) && normal==null); 79 } 80 81 public void canCommit() throws RemoteException , TIRExceptCommit {;} 82 83 public void doCommit(Container in, Repository rep) throws RemoteException { 84 if (stKindImpl.value()==StateKind.sk_normal) 85 return; 86 if (isNew()) { 87 stKindImpl.toNormal(); 88 } else { 89 normal = null; 90 } 91 } 92 93 public void doAbort(long workId) throws RemoteException {} 94 } 95 | Popular Tags |