KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* $Id: ID.java,v 1.1.1.1 2003/02/11 16:19:40 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3 import SOFA.SOFAnode.Made.TIR.Identification;
4
5 class ID {
6   public static final String JavaDoc lang = "cdl";
7
8   public int isin; // what is in id -- version || tag || none
9
// constants in ReadIDKind.java
10
public String JavaDoc name;
11   public String JavaDoc version;
12   public String JavaDoc tag;
13
14   public int what; // what kind
15
public boolean exist; // for module, provider, amodule
16

17   public Identification id; // real id
18

19   public ID(String JavaDoc name, String JavaDoc vt) {
20     what = 0; exist = false; id = null;
21     this.name = new String JavaDoc(name);
22     id = null;
23     if (vt == null || vt.length()==0) {
24       isin = IDKind.none;
25       tag = null;
26       version = null;
27     } else {
28       if (vt.indexOf('!')==-1) {
29         version = null;
30         isin = IDKind.tag;
31         tag = new String JavaDoc(vt);
32       } else {
33         version = new String JavaDoc(vt);
34         isin = IDKind.version;
35         tag = null;
36       }
37     }
38   }
39
40   public void setVersion(String JavaDoc vt) {
41     what = 0; exist = false; id = null;
42     if (vt == null || vt.length()==0) {
43       isin = IDKind.none;
44       tag = null;
45       version = null;
46     } else {
47       if (vt.indexOf('!')==-1) {
48         version = null;
49         isin = IDKind.tag;
50         tag = new String JavaDoc(vt);
51       } else {
52         version = new String JavaDoc(vt);
53         isin = IDKind.version;
54         tag = null;
55       }
56     }
57   }
58
59   public boolean isEqual(String JavaDoc nm, String JavaDoc ver) {
60     if (isin==IDKind.version || isin==IDKind.versiontag)
61       if ((nm.compareTo(name)==0)&&(ver.compareTo(version)==0))
62         return true;
63     return false;
64   }
65
66   public boolean isNameEqual(String JavaDoc nm) {
67     if (nm.compareTo(name)==0)
68       return true;
69     return false;
70   }
71
72   public boolean isTagEqual(String JavaDoc nm, String JavaDoc t) {
73     if (isin==IDKind.tag || isin==IDKind.versiontag)
74       if ((nm.compareTo(name)==0)&&(t.compareTo(tag)==0))
75         return true;
76     return false;
77   }
78
79   public String JavaDoc toString() {
80     StringBuffer JavaDoc ret = new StringBuffer JavaDoc(name);
81     switch (isin) {
82       case IDKind.versiontag:
83       case IDKind.version: ret.append("::"+version); break;
84       case IDKind.tag: ret.append("::"+tag); break;
85     }
86     return ret.toString();
87   }
88 }
89
Popular Tags