1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.sentrysoftware.wbem.sblim.slp.internal.msg;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 import java.util.Iterator;
49 import java.util.List;
50 import java.util.TreeSet;
51
52 import org.sentrysoftware.wbem.sblim.slp.ServiceLocationAttribute;
53
54
55
56
57
58
59
60
61
62 public class DADescriptor implements Comparable<DADescriptor> {
63
64 private String iURL;
65
66 private TreeSet<String> iScopeSet;
67
68 private List<ServiceLocationAttribute> iAttributes;
69
70
71
72
73
74
75
76
77
78
79 public DADescriptor(String pURL, TreeSet<String> pScopeSet,
80 List<ServiceLocationAttribute> pAttributes) {
81 this.iURL = pURL;
82 this.iScopeSet = pScopeSet;
83 this.iAttributes = pAttributes;
84 }
85
86
87
88
89
90
91 public String getURL() {
92 return this.iURL;
93 }
94
95
96
97
98
99
100
101 public boolean hasScope(String pScope) {
102 if (this.iScopeSet == null) return false;
103 return this.iScopeSet.contains(pScope);
104 }
105
106 public int compareTo(DADescriptor o) {
107 DADescriptor that = o;
108 return this.iURL.compareTo(that.iURL);
109 }
110
111 @Override
112 public boolean equals(Object pObj) {
113 if (!(pObj instanceof DADescriptor)) return false;
114 DADescriptor that = (DADescriptor) pObj;
115 return this.iURL.equals(that.iURL);
116 }
117
118 private int iHashCode = 0;
119
120 private void incHashCode(int pHashCode) {
121 this.iHashCode *= 31;
122 this.iHashCode += pHashCode;
123 }
124
125
126
127
128
129
130
131 @Override
132 public int hashCode() {
133 if (this.iHashCode == 0) {
134 this.iHashCode = this.iURL.hashCode();
135 Iterator<?> itr;
136 if (this.iScopeSet != null) {
137 itr = this.iScopeSet.iterator();
138 while (itr.hasNext())
139 incHashCode(itr.next().hashCode());
140 }
141 if (this.iAttributes != null) {
142 itr = this.iAttributes.iterator();
143
144
145
146
147 while (itr.hasNext())
148 this.iHashCode += itr.next().hashCode();
149 }
150 }
151 return this.iHashCode;
152 }
153
154 @Override
155 public String toString() {
156 StringBuffer strBuf = new StringBuffer("URL : " + this.iURL + "\nScopes : ");
157 if (this.iScopeSet != null) {
158 Iterator<String> itr = this.iScopeSet.iterator();
159 boolean more = false;
160 while (itr.hasNext()) {
161 if (more) strBuf.append(", ");
162 else more = true;
163 strBuf.append(itr.next());
164 }
165 }
166
167 return strBuf.toString();
168 }
169
170 }