KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > TIR > Impl > ProtocolMetaOperandDefImpl


1 /* $Id: ProtocolMetaOperandDefImpl.java,v 1.2 2004/05/20 14:23:52 bures Exp $ */
2 package SOFA.SOFAnode.Made.TIR.Impl;
3 import java.io.IOException JavaDoc;
4 import java.rmi.RemoteException JavaDoc;
5 import java.rmi.server.UnicastRemoteObject JavaDoc;
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 JavaDoc implements ProtocolMetaOperandDef, TIRImplObject, SProtocolOperDef {
16   String JavaDoc nm;
17   ProtocolOperKind pok;
18   DefinitionKindImpl defKindImpl;
19   StateKindImpl stKindImpl;
20   
21
22   public ProtocolMetaOperandDefImpl(String JavaDoc name) throws RemoteException JavaDoc {
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 JavaDoc {
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 JavaDoc {
37     return pok;
38   }
39
40   /* from interface TIRObject */
41   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
42     return (DefinitionKind) defKindImpl;
43   }
44
45   /* from interface TIRObject */
46   public StateKind get_state() throws RemoteException JavaDoc {
47     return (StateKind) stKindImpl;
48   }
49
50   public String JavaDoc name() throws RemoteException JavaDoc {
51     return nm;
52   }
53   
54   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
55     try {
56       st.curOutFile.writeInt(pok.value());
57       Storage.writeString(st.curOutFile, nm);
58     } catch (IOException JavaDoc e) {
59       throw new TIRExceptStorage("Can't write in directory "+st.current+".");
60     }
61   }
62   
63   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
64     try {
65       nm = Storage.readString(st.curInFile);
66     } catch (IOException JavaDoc e) {
67       throw new TIRExceptStorage("Can't read in directory "+st.current+".");
68     }
69   }
70
71   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, TIRExceptStorage {
72   }
73
74   public boolean isNew() {
75     return (stKindImpl.value()==StateKind.sk_work);
76   }
77
78   public void canCommit() throws RemoteException JavaDoc, TIRExceptCommit {;}
79
80   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
81     if (stKindImpl.value()==StateKind.sk_normal)
82       return;
83     stKindImpl.toNormal();
84   }
85
86   public void doAbort(long workId) throws RemoteException JavaDoc {}
87
88   public String JavaDoc to_text() throws RemoteException JavaDoc {
89     StringBuffer JavaDoc sb = new StringBuffer JavaDoc("[");
90     sb.append(nm);
91     sb.append("]");
92     return sb.toString();
93   }
94 }
95
Popular Tags