KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: EnumMemberImpl.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.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 JavaDoc implements EnumMember, TIRImplObject {
15   String JavaDoc nm;
16   DefinitionKindImpl defKindImpl;
17   StateKindImpl stKindImpl;
18
19   EnumMemberImpl normal;
20
21   public EnumMemberImpl(String JavaDoc name) throws RemoteException JavaDoc {
22     nm = name;
23     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_EnumMember);
24     stKindImpl = new StateKindImpl(StateKind.sk_work);
25     normal = null;
26   }
27
28   /* constuctor for load() */
29   public EnumMemberImpl() throws RemoteException JavaDoc {
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 JavaDoc {
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 JavaDoc name() throws RemoteException JavaDoc {
44     return nm;
45   }
46   
47   /* from interface TIRObject */
48   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
49     return (DefinitionKind) defKindImpl;
50   }
51
52   /* from interface TIRObject */
53   public StateKind get_state() throws RemoteException JavaDoc {
54     return (StateKind) stKindImpl;
55   }
56    
57   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
58     try {
59       nm = Storage.readString(st.curInFile);
60     } catch (IOException JavaDoc e) {
61       throw new TIRExceptStorage("Can't read in file "+st.currentFile+".");
62     }
63   }
64
65   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
66     try {
67       Storage.writeString(st.curOutFile,nm); // saving name
68
} catch (IOException JavaDoc e) {
69       throw new TIRExceptStorage("Can't write in file "+st.currentFile+".");
70     }
71   }
72
73   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, 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 JavaDoc, TIRExceptCommit {;}
82
83   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
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 JavaDoc {}
94 }
95
Popular Tags