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