KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: CompContainedContainerIm.java,v 1.2 2004/05/20 14:23:51 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3 import SOFA.SOFAnode.Made.TIR.CDLRepository;
4 import SOFA.SOFAnode.Made.TIR.Container;
5
6 abstract class CompContainedContainerIm extends CompObjectIm implements CompContained, CompContainer {
7   public ID id;
8   public CompContainer par;
9   public CompRepository rep;
10   public List cont;
11
12   public CompContainedContainerIm(int okind, ID id, CompContainer parent, CompRepository rep) {
13     super(okind);
14     this.id = id;
15     par = parent;
16     this.rep = rep;
17     cont = new List();
18
19   }
20   
21   public ID getIdent() { return id; }
22   public CompContainer parent() { return par; }
23   public CompRepository repository() { return rep; }
24   public FullID fullName() {
25     FullID ret = null;
26     if (par instanceof CompRepository ) {
27       ret = new FullID(true);
28       ret.name = id.name;
29       ret.version = id.version;
30     } else {
31       FullID p = ((CompContained)par).fullName();
32       ret = new FullID(p);
33       ret.sn.addScope(new String JavaDoc(p.name));
34       ret.name = id.name;
35       ret.version = id.version;
36     }
37     return ret;
38   }
39
40  public CompContained[] contents() {
41     CompContained[] ret = new CompContained [cont.size()];
42     cont.toFirst();
43     for(int i=0;i<cont.size();i++) {
44       ret[i] = (CompContained) cont.aktual();
45       cont.toNext();
46     }
47     return ret;
48   }
49
50   public CompContained lookup(String JavaDoc name, String JavaDoc ver) {
51     CompContained ret = null;
52     cont.toFirst();
53     for(int i=0;i<cont.size();i++) {
54       if (((CompContained) cont.aktual()).getIdent().isEqual(name,ver)) {
55         ret = (CompContained) cont.aktual();
56     break;
57       }
58       cont.toNext();
59     }
60     return ret;
61   }
62   
63   public CompContained[] lookup(String JavaDoc name) {
64     CompContained[] pom = new CompContained [cont.size()];
65     int i,j = 0;
66     cont.toFirst();
67     for(i=0;i<cont.size();i++) {
68       if (((CompContained) cont.aktual()).getIdent().isNameEqual(name)) {
69         pom[j] = (CompContained) cont.aktual();
70     j++;
71       }
72       cont.toNext();
73     }
74     CompContained[] ret = new CompContained [j];
75     for(i=0;i<j;i++)
76       ret[i]=pom[i];
77     return ret;
78   }
79
80   public CompContained lookupTag(String JavaDoc name, String JavaDoc tag) {
81     CompContained ret = null;
82     cont.toFirst();
83     for(int i=0;i<cont.size();i++) {
84       if (((CompContained) cont.aktual()).getIdent().isTagEqual(name,tag)) {
85         ret = (CompContained) cont.aktual();
86     break;
87       }
88       cont.toNext();
89     }
90     return ret;
91   }
92
93   public boolean addObject(CompContained o) {
94     cont.toFirst();
95     for (int i=0;i<cont.size();i++) {
96       if (((CompContained) cont.aktual()).getIdent().isNameEqual(o.getIdent().name))
97         return false;
98       cont.toNext();
99     }
100     cont.add(o);
101     return true;
102   }
103
104   public boolean isContainer() {return true;}
105
106   public void addToNormal(Container obj, CDLRepository normRep, java.util.ArrayList JavaDoc delayed) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock {
107     // !!! zrus to a tridu dej abstract !!!
108
}
109 }
110
Popular Tags