KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: ExprFixedImpl.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.ExprFixed;
10 import SOFA.SOFAnode.Made.TIR.ExprOperDef;
11 import SOFA.SOFAnode.Made.TIR.ExprOperKind;
12 import SOFA.SOFAnode.Made.TIR.Repository;
13 import SOFA.SOFAnode.Made.TIR.StateKind;
14 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit;
15
16 public class ExprFixedImpl extends UnicastRemoteObject JavaDoc implements ExprFixed, TIRImplObject {
17   java.math.BigDecimal JavaDoc v;
18   int dig;
19   int sc;
20   ExprOperKindImpl eok;
21   DefinitionKindImpl defKindImpl;
22   StateKindImpl stKindImpl;
23
24   public ExprFixedImpl(java.math.BigDecimal JavaDoc value, int digits, int scale) throws RemoteException JavaDoc {
25     v = value;
26     dig = digits;
27     sc = scale;
28     eok = new ExprOperKindImpl(ExprOperKind.eok_fixed);
29     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression);
30     stKindImpl = new StateKindImpl(StateKind.sk_work);
31   }
32
33   public ExprFixedImpl() throws RemoteException JavaDoc {
34     v = null;
35     dig = 0;
36     sc = 0;
37     eok = new ExprOperKindImpl(ExprOperKind.eok_fixed);
38     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Expression);
39     stKindImpl = new StateKindImpl(StateKind.sk_normal);
40   }
41
42   /* from interface TIRObject */
43   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
44     return (DefinitionKind) defKindImpl;
45   }
46
47   /* from interface TIRObject */
48   public StateKind get_state() throws RemoteException JavaDoc {
49     return (StateKind) stKindImpl;
50   }
51
52   public java.math.BigDecimal JavaDoc value() throws RemoteException JavaDoc {
53     return v;
54   }
55   
56   public int digits() throws RemoteException JavaDoc {
57     return dig;
58   }
59   
60   public int scale() throws RemoteException JavaDoc {
61     return sc;
62   }
63
64   public ExprOperKind get_eok_kind() throws RemoteException JavaDoc {
65     return (ExprOperKind) eok;
66   }
67   
68   public ExprOperDef calculate() throws RemoteException JavaDoc {
69     return this;
70   }
71
72   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
73     try {
74       st.curOutFile.writeInt(eok.value());
75       Storage.writeString(st.curOutFile,v.toString());
76       st.curOutFile.writeInt(dig);
77       st.curOutFile.writeInt(sc);
78     } catch (IOException JavaDoc e) {
79       throw new TIRExceptStorage("Can't write in file "+st.currentFile+".");
80     }
81   }
82   
83   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
84     try {
85       String JavaDoc s = Storage.readString(st.curInFile);
86       v = new java.math.BigDecimal JavaDoc(s);
87       dig = st.curInFile.readInt();
88       sc = st.curInFile.readInt();
89     } catch (IOException JavaDoc e) {
90       throw new TIRExceptStorage("Can't read in file "+st.currentFile+".");
91     }
92   }
93
94   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, TIRExceptStorage {
95     ;
96   }
97
98   public boolean isNew() {
99     return (stKindImpl.value()==StateKind.sk_work);
100   }
101
102   public void canCommit() throws RemoteException JavaDoc, TIRExceptCommit {;}
103
104   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
105     if (stKindImpl.value()==StateKind.sk_work)
106       stKindImpl.toNormal();
107   }
108
109   public void doAbort(long workId) throws RemoteException JavaDoc {}
110 }
111
Popular Tags