KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > CDL > CompException


1 /* $Id: CompException.java,v 1.2 2004/05/20 14:23:51 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3 import java.rmi.RemoteException JavaDoc;
4
5 import SOFA.SOFAnode.Made.TIR.CDLRepository;
6 import SOFA.SOFAnode.Made.TIR.Contained;
7 import SOFA.SOFAnode.Made.TIR.Container;
8 import SOFA.SOFAnode.Made.TIR.EnumDef;
9 import SOFA.SOFAnode.Made.TIR.ExceptionDef;
10 import SOFA.SOFAnode.Made.TIR.StructDef;
11 import SOFA.SOFAnode.Made.TIR.StructMember;
12 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
13 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
14 import SOFA.SOFAnode.Made.TIR.UnionDef;
15
16 class CompException extends CompContainedContainerIm {
17   public CompException(ID id, CompContainer in, CompRepository inRep) {
18     super(ObjectsKind.o_Exception, id, in, inRep);
19   }
20
21   public boolean addObject(CompContained o) {
22     ((CompContained) o).getIdent().version = id.version;
23     return super.addObject(o);
24   }
25
26   public void addToNormal(Container obj, CDLRepository normRep, java.util.ArrayList JavaDoc delayed) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock {
27     if (id.isin == IDKind.versiontag) {
28       try {
29         ((Contained)obj).tag(id.tag);
30       } catch (RemoteException JavaDoc e) {
31         throw new CDLExceptRemote("Remote exception occured: "+e.getMessage());
32       } catch (TIRExceptLock e) {
33         throw new CDLExceptLock("Repository is locked.");
34       } catch (TIRExceptCreate ecr) {
35         throw new CDLExceptToNormal("Can't set tag for "+ fullName());
36       }
37     }
38     cont.toFirst();
39     try {
40       for (int i=0;i<cont.size(); i++) {
41         CompContained akt = (CompContained) cont.aktual();
42         switch (akt.objectKind()) {
43         // *****************
44
case ObjectsKind.o_Struct:
45           try {
46             StructDef str = ((ExceptionDef) obj).create_struct(akt.getIdent().id);
47             if (str == null)
48               throw new CDLExceptToNormal("Can't create struct "+((CompContained)akt).fullName());
49             ((CompStruct) akt).addToNormal(str, normRep, delayed);
50           } catch (TIRExceptCreate ecr) {
51             throw new CDLExceptToNormal("Can't create struct "+((CompContained)akt).fullName());
52           }
53           break;
54         // *****************
55
case ObjectsKind.o_StructMember:
56           try {
57             StructMember mem = ((ExceptionDef) obj).create_member(akt.getIdent().name, ((CompStructMember)akt).tp.toNormal(normRep));
58             if (mem == null)
59               throw new CDLExceptToNormal("Can't create struct member "+((CompContained)akt).fullName());
60           } catch (TIRExceptCreate ecr) {
61             throw new CDLExceptToNormal("Can't create struct member "+((CompContained)akt).fullName());
62           }
63           break;
64         // *****************
65
case ObjectsKind.o_Enum:
66           try {
67             EnumDef en = ((ExceptionDef) obj).create_enum(akt.getIdent().id);
68             if (en == null)
69               throw new CDLExceptToNormal("Can't create enum "+((CompContained)akt).fullName());
70             ((CompEnum) akt).addToNormal(en);
71           } catch (TIRExceptCreate ecr) {
72             throw new CDLExceptToNormal("Can't create enum "+((CompContained)akt).fullName());
73           }
74           break;
75         // *****************
76
case ObjectsKind.o_Union:
77           try {
78             UnionDef un = ((ExceptionDef) obj).create_union(akt.getIdent().id, ((CompUnion) akt).switch_type.toNormal(normRep));
79             if (un == null)
80               throw new CDLExceptToNormal("Can't create union "+((CompContained)akt).fullName());
81             ((CompUnion) akt).addToNormal(un, normRep, delayed);
82           } catch (TIRExceptCreate ecr) {
83             throw new CDLExceptToNormal("Can't create union "+((CompContained)akt).fullName());
84           }
85           break;
86
87         default:
88           throw new CDLExceptToNormal("Unexcepted kind of object");
89         }
90         cont.toNext();
91       }
92     } catch (RemoteException JavaDoc e) {
93       throw new CDLExceptRemote("Remote exception occured: "+e.getMessage());
94     } catch (TIRExceptLock e) {
95       throw new CDLExceptLock("Repository is locked.");
96     }
97   }
98
99   public void checkConsist(EnumList props, CompRepository rep) throws CDLExceptCheck, CDLExceptLock, CDLExceptRemote {
100     CompContained[] cont = contents();
101     for (int i=0;i<cont.length;i++) {
102       cont[i].checkConsist(props, rep);
103     }
104   }
105 }
106
Popular Tags