KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: FixedDefImpl.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.FixedDef;
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 FixedDefImpl extends UnicastRemoteObject JavaDoc implements FixedDef, TIRImplObject {
16   ExprOperDef dig;
17   ExprOperDef sc;
18   DefinitionKindImpl defKindImpl;
19   StateKindImpl stKindImpl;
20
21   public FixedDefImpl(ExprOperDef digits, ExprOperDef scale) throws RemoteException JavaDoc {
22     dig = digits;
23     sc = scale;
24     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Fixed);
25     stKindImpl = new StateKindImpl(StateKind.sk_work);
26   }
27
28   public FixedDefImpl() throws RemoteException JavaDoc {
29     dig = null;
30     sc = null;
31     defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_Fixed);
32     stKindImpl = new StateKindImpl(StateKind.sk_normal);
33   }
34   
35   public ExprOperDef digits() throws RemoteException JavaDoc {
36     return dig;
37   }
38   
39   public ExprOperDef scale() throws RemoteException JavaDoc {
40     return sc;
41   }
42
43   /* from interface TIRObject */
44   public DefinitionKind get_def_kind() throws RemoteException JavaDoc {
45     return (DefinitionKind) defKindImpl;
46   }
47
48   /* from interface TIRObject */
49   public StateKind get_state() throws RemoteException JavaDoc {
50     return (StateKind) stKindImpl;
51   }
52   
53   /* load & save OK */
54   public void load(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
55     dig = Storage.readExprOperDef(st);
56     sc = Storage.readExprOperDef(st);
57   }
58
59   public void save(Storage st) throws RemoteException JavaDoc, TIRExceptStorage {
60     try {
61       Storage.writeExprOperDef(st,dig);
62       Storage.writeExprOperDef(st,sc);
63     } catch (IOException JavaDoc e) {
64       throw new TIRExceptStorage("Can't write in file "+st.currentFile+".");
65     }
66   }
67
68   public void postLoad(RepositoryImpl r) throws RemoteException JavaDoc, TIRExceptStorage {
69     ((TIRImplObject) dig).postLoad(r);
70     ((TIRImplObject) sc).postLoad(r);
71   }
72
73   public boolean isNew() {
74     return (stKindImpl.value()==StateKind.sk_work);
75   }
76
77   public void canCommit() throws RemoteException JavaDoc, TIRExceptCommit {;}
78
79   public void doCommit(Container in, Repository rep) throws RemoteException JavaDoc {
80     if (stKindImpl.value()==StateKind.sk_normal)
81       return;
82     if (isNew()) {
83       stKindImpl.toNormal();
84       ((TIRImplObject) dig).doCommit(in,rep);
85       ((TIRImplObject) sc).doCommit(in,rep);
86     }
87   }
88
89   public void doAbort(long workId) throws RemoteException JavaDoc {}
90 }
91
Popular Tags