KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: Scopename.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3
4 class Scopename {
5   public List names;
6
7   public Scopename() {
8     names = new List();
9   }
10
11   public void addScope(String JavaDoc name) {
12     if (name != null && name.length()!=0) {
13       names.add(name);
14     }
15   }
16
17   public void prependScope(String JavaDoc name) {
18     if (name != null && name.length()!=0) {
19       names.prepend(name);
20     }
21   }
22
23   public long length() { return names.size(); }
24
25   public void removeScope() {
26     names.toLast();
27     names.removeAkt();
28   }
29
30   public String JavaDoc toString() {
31     StringBuffer JavaDoc ret = new StringBuffer JavaDoc("::");
32     names.toFirst();
33     for (int i=0;i<names.size();i++) {
34       ret.append((String JavaDoc) names.aktual());
35       if (i!= names.size()-1)
36         ret.append("::");
37       names.toNext();
38     }
39     return ret.toString();
40   }
41
42   public boolean equal(Scopename s) {
43     if (names.size() != s.names.size())
44       return false;
45     names.toFirst();
46     s.names.toFirst();
47     for(int i=0;i<names.size();i++) {
48       if (((String JavaDoc) names.aktual()).compareTo(((String JavaDoc) s.names.aktual()))!=0)
49         return false;
50       names.toNext();
51       s.names.toNext();
52     }
53     return true;
54   }
55 }
56
Popular Tags