KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: ExprPropertyImpl.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.ExprOperDef;
10 import SOFA.SOFAnode.Made.TIR.ExprOperKind;
11 import SOFA.SOFAnode.Made.TIR.ExprProperty;
12 import SOFA.SOFAnode.Made.TIR.Repository;
13 import SOFA.SOFAnode.Made.TIR.StateKind;
14 import SOFA.SOFAnode.Made.TIR.TIRExceptCalculate;
15 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit;
16
17 public class ExprPropertyImpl extends UnicastRemoteObject JavaDoc implements ExprProperty, TIRImplObject {
18   String JavaDoc prop;
19   ExprOperKindImpl eok;
20   DefinitionKindImpl defKindImpl;
21   StateKindImpl stKindImpl;
22
23   public ExprPropertyImpl(String JavaDoc property) throws RemoteException JavaDoc {
24     prop = property;
25     eok = new ExprOperKindImpl(ExprOperKind.eok_property);
26     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression);
27     stKindImpl = new StateKindImpl(StateKind.sk_work);
28   }
29
30   public ExprPropertyImpl() throws RemoteException JavaDoc {
31     prop = null;
32     eok = new ExprOperKindImpl(ExprOperKind.eok_property);
33     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression);
34     stKindImpl = new StateKindImpl(StateKind.sk_normal);
35   }
36
37   /* from interface TIRObject */
38   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
39     return (DefinitionKind) defKindImpl;
40   }
41
42   /* from interface TIRObject */
43   public StateKind get_state() throws RemoteException JavaDoc {
44     return (StateKind) stKindImpl;
45   }
46
47   public String JavaDoc ref_prop() throws RemoteException JavaDoc {
48     return prop;
49   }
50
51   public ExprOperDef calculate() throws RemoteException JavaDoc, TIRExceptCalculate {
52     throw new TIRExceptCalculate("Can't calculate property.");
53   }
54
55   public ExprOperKind get_eok_kind() throws RemoteException JavaDoc {
56     return (ExprOperKind) eok;
57   }
58
59   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
60     try {
61       st.curOutFile.writeInt(eok.value());
62       Storage.writeString(st.curOutFile, prop);
63     } catch (IOException JavaDoc e) {
64       throw new TIRExceptStorage("Can't write in directory "+st.current+".");
65     }
66   }
67   
68   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
69     try {
70       prop = Storage.readString(st.curInFile);
71     } catch (IOException JavaDoc e) {
72       throw new TIRExceptStorage("Can't read in directory "+st.current+".");
73     }
74   }
75
76   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, TIRExceptStorage {}
77
78   public boolean isNew() {
79     return (stKindImpl.value()==StateKind.sk_work);
80   }
81
82   public void canCommit() throws RemoteException JavaDoc, TIRExceptCommit {;}
83
84   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
85     if (stKindImpl.value()==StateKind.sk_work) {
86       stKindImpl.toNormal();
87     }
88   }
89
90   public void doAbort(long workId) throws RemoteException JavaDoc {}
91 }
92
Popular Tags