KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: FullID.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3
4 class FullID {
5   public Scopename sn;
6   public String JavaDoc name;
7   public String JavaDoc version;
8   public String JavaDoc tag;
9   public int isin;
10   public boolean isAbsolute;
11
12   public FullID(boolean isAbs) {
13     sn = new Scopename();
14     name = null;
15     version = null;
16     tag = null;
17     isin = IDKind.none;
18     isAbsolute = isAbs;
19   }
20   
21   public FullID(String JavaDoc name, String JavaDoc vt) {
22     if (vt == null || vt.length()==0) {
23       isin = IDKind.none;
24       tag = null;
25       version = null;
26     } else {
27       if (vt.indexOf('!')==-1) {
28         version = null;
29         isin = IDKind.tag;
30         tag = new String JavaDoc(vt);
31       } else {
32         version = new String JavaDoc(vt);
33         isin = IDKind.version;
34         tag = null;
35       }
36     }
37     int i;
38     int count = 0;
39     
40     isAbsolute = true;
41     
42     for (i=0;i<name.length();i++) {
43       if (name.charAt(i)==':' && name.charAt(i+1)==':')
44         count++;
45     }
46     int j = 0;
47     for(i=0;i<count;i++) {
48       StringBuffer JavaDoc str = new StringBuffer JavaDoc();
49       while (name.charAt(j)==':')
50         j++;
51       while (name.charAt(j)!=':' && j<name.length()) {
52         str = str.append(name.charAt(j));
53         j++;
54       }
55       if (i==count-1)
56         this.name = str.toString();
57       else
58         sn.addScope(str.toString());
59     }
60   }
61   
62   public FullID(FullID a) {
63     isAbsolute = a.isAbsolute;
64     name = new String JavaDoc(a.name);
65     if (a.version != null)
66       version = new String JavaDoc(a.version);
67     else
68       version = null;
69     if (a.tag != null)
70       tag = new String JavaDoc(a.tag);
71     else
72       tag = null;
73     isin = a.isin;
74     sn = new Scopename();
75     a.sn.names.toFirst();
76     for(int i=0;i<a.sn.length();i++) {
77       sn.addScope(new String JavaDoc((String JavaDoc)a.sn.names.aktual()));
78       a.sn.names.toNext();
79     }
80   }
81
82   public void setVersion(String JavaDoc vt) {
83     if (vt == null || vt.length()==0) {
84       isin = IDKind.none;
85       tag = null;
86       version = null;
87     } else {
88       if (vt.indexOf('!')==-1) {
89         version = null;
90         isin = IDKind.tag;
91         tag = new String JavaDoc(vt);
92       } else {
93         version = new String JavaDoc(vt);
94         isin = IDKind.version;
95         tag = null;
96       }
97     }
98   }
99
100   public String JavaDoc toString() {
101     if (sn.length()==0)
102       return "::"+name+":"+version;
103     else
104       return sn.toString()+"::"+name+":"+version;
105   }
106
107   public String JavaDoc toStringWithoutVersion() {
108     if (sn.length()==0)
109       return "::"+name;
110     else
111       return sn.toString()+"::"+name;
112   }
113
114   public String JavaDoc langToString() {
115     if (sn.length()==0)
116       return "::"+ID.lang+"::"+name;
117     else
118       return "::"+ID.lang+sn.toString()+"::"+name;
119   }
120 }
121
Popular Tags