KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: CompExprEnum.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.ExprOperDef;
10 import SOFA.SOFAnode.Made.TIR.Repository;
11 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
12 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
13
14 class CompExprEnum extends CompExprOper {
15   public CompReffer en;
16   public String JavaDoc item; // enum item
17
public CompExprEnum(CompReffer en, String JavaDoc it) {
18     super(CompExprKind.e_enum);
19     this.en = en;
20     item = it;
21   }
22
23   public int type() { return CompExprKind.e_enum; }
24   public boolean isProp() { return false; }
25   public EnumList nameProp(CompRepository rep) throws CDLExceptRemote, CDLExceptLock {
26     EnumList l = new EnumList();
27     return l;
28   }
29
30   public String JavaDoc toString() {
31     return item;
32   }
33   
34   public int isPositive() {
35     return -2;
36   }
37
38   public ExprOperDef toNormal(CDLRepository rep) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock {
39     try {
40       int i,j;
41       Container con = rep;
42       en.ref.sn.names.toFirst();
43       for(i=0;i<en.ref.sn.names.size();i++) {
44         Contained[] a = con.lookup_name((String JavaDoc) en.ref.sn.names.aktual());
45         if (a.length==1) {
46           con = (Container) a[0];
47         } else {
48           for(j=0;j<a.length;j++) {
49             if (a[j].get_identification().version().compareTo(en.ref.version)==0) {
50               con = (Container) a[j];
51               break;
52             }
53           }
54         }
55         en.ref.sn.names.toNext();
56       }
57       Contained sec = con.lookup(en.ref.name, en.ref.version);
58       return ((Repository) rep.get_containing_repository()).create_exprenum((EnumDef) sec, item);
59     } catch (RemoteException JavaDoc e) {
60       throw new CDLExceptRemote("Remote exception occured: "+e.getMessage());
61     } catch (TIRExceptCreate ecr) {
62       throw new CDLExceptToNormal("Can't create expression");
63     } catch (TIRExceptLock e) {
64       throw new CDLExceptLock("Repository is locked.");
65     }
66   }
67 }
68
Popular Tags