51 |
{ |
{ |
52 |
static final long serialVersionUID = 4380036194768077479L; |
static final long serialVersionUID = 4380036194768077479L; |
53 |
|
|
54 |
//------------------------------------------------------------- |
/** |
55 |
// Variables -------------------------------------------------- |
* path |
56 |
//------------------------------------------------------------- |
*/ |
57 |
|
private Object[] path = null; |
58 |
/** |
|
59 |
* path |
|
60 |
*/ |
/** |
61 |
private Object[] path = null; |
* Constructor TreePath |
62 |
|
* @param path TODO |
63 |
|
*/ |
64 |
//------------------------------------------------------------- |
public TreePath(Object[] path) |
65 |
// Initialization --------------------------------------------- |
{ |
66 |
//------------------------------------------------------------- |
// Create Path |
67 |
|
this.path = new Object[path.length]; |
68 |
/** |
System.arraycopy(path, 0, this.path, 0, path.length); |
69 |
* Constructor TreePath |
} |
70 |
* @param path TODO |
|
71 |
*/ |
/** |
72 |
public TreePath(Object[] path) { |
* Constructor TreePath |
73 |
|
* @param element TODO |
74 |
// Create Path |
*/ |
75 |
this.path = new Object[path.length]; |
public TreePath(Object element) |
76 |
System.arraycopy(path, 0, this.path, 0, path.length); |
{ |
77 |
|
// Create Path |
78 |
} // TreePath() |
path = new Object[1]; |
79 |
|
path[0] = element; |
80 |
/** |
} |
81 |
* Constructor TreePath |
|
82 |
* @param element TODO |
/** |
83 |
*/ |
* Constructor TreePath |
84 |
public TreePath(Object element) { |
* @param path TODO |
85 |
|
* @param element TODO |
86 |
// Create Path |
*/ |
87 |
path = new Object[1]; |
protected TreePath(TreePath path, Object element) |
88 |
path[0] = element; |
{ |
89 |
|
// Variables |
90 |
} // TreePath() |
Object[] treepath; |
91 |
|
|
92 |
/** |
// Get Tree Path |
93 |
* Constructor TreePath |
treepath = path.getPath(); |
94 |
* @param path TODO |
|
95 |
* @param element TODO |
// Create Tree Path |
96 |
*/ |
this.path = new Object[treepath.length + 1]; |
97 |
protected TreePath(TreePath path, Object element) { |
System.arraycopy(treepath, 0, this.path, 0, treepath.length); |
98 |
|
this.path[treepath.length] = element; |
99 |
// Variables |
} |
100 |
Object[] treepath; |
|
101 |
|
/** |
102 |
// Get Tree Path |
* Constructor TreePath |
103 |
treepath = path.getPath(); |
* @param path TODO |
104 |
|
* @param length TODO |
105 |
// Create Tree Path |
*/ |
106 |
this.path = new Object[treepath.length + 1]; |
protected TreePath(Object[] path, int length) |
107 |
System.arraycopy(treepath, 0, this.path, 0, treepath.length); |
{ |
108 |
this.path[treepath.length] = element; |
// Create Path |
109 |
|
this.path = new Object[length]; |
110 |
} // TreePath() |
System.arraycopy(path, 0, this.path, 0, length); |
111 |
|
} |
112 |
/** |
|
113 |
* Constructor TreePath |
/** |
114 |
* @param path TODO |
* Constructor TreePath |
115 |
* @param length TODO |
*/ |
116 |
*/ |
protected TreePath() |
117 |
protected TreePath(Object[] path, int length) { |
{ |
118 |
|
path = new Object[0]; |
119 |
// Create Path |
} |
120 |
this.path = new Object[length]; |
|
121 |
System.arraycopy(path, 0, this.path, 0, length); |
|
122 |
|
/** |
123 |
} // TreePath() |
* hashCode |
124 |
|
* @returns int |
125 |
/** |
*/ |
126 |
* Constructor TreePath |
public int hashCode() |
127 |
*/ |
{ |
128 |
protected TreePath() { |
return getLastPathComponent().hashCode(); |
129 |
path = new Object[0]; |
} |
130 |
} // TreePath() |
|
131 |
|
/** |
132 |
|
* equals |
133 |
//------------------------------------------------------------- |
* @param object TODO |
134 |
// Methods ---------------------------------------------------- |
* @returns boolean |
135 |
//------------------------------------------------------------- |
*/ |
136 |
|
public boolean equals(Object object) |
137 |
/** |
{ |
138 |
* hashCode |
// Variables |
139 |
* @returns int |
Object[] treepath; |
140 |
*/ |
int index; |
141 |
public int hashCode() { |
|
142 |
return getLastPathComponent().hashCode(); |
// Check for TreePath |
143 |
} // hashCode() |
if (object instanceof TreePath) |
144 |
|
{ |
145 |
/** |
// Get Path Elements |
146 |
* equals |
treepath = ((TreePath) object).getPath(); |
147 |
* @param object TODO |
|
148 |
* @returns boolean |
// Check length |
149 |
*/ |
if (treepath.length != path.length) |
150 |
public boolean equals(Object object) { |
return false; |
151 |
|
|
152 |
// Variables |
// Check Elements |
153 |
Object[] treepath; |
for (index = 0; index < path.length; index++) |
154 |
int index; |
{ |
155 |
|
if (treepath[index] != path[index]) |
156 |
// Check for TreePath |
return false; |
157 |
if (object instanceof TreePath) { |
} |
158 |
|
|
159 |
// Get Path Elements |
// Tree Path's are equals |
160 |
treepath = ((TreePath) object).getPath(); |
return true; |
161 |
|
} |
162 |
// Check length |
|
163 |
if (treepath.length != path.length) { |
// Unequal |
164 |
return false; |
return false; |
165 |
} // if |
} |
166 |
|
|
167 |
// Check Elements |
/** |
168 |
for (index = 0; index < path.length; index++) { |
* toString |
169 |
if (treepath[index] != path[index]) { |
* @returns String |
170 |
return false; |
*/ |
171 |
} // if |
public String toString() |
172 |
} // for |
{ |
173 |
|
return null; // TODO |
174 |
// Tree Path's are equals |
} |
175 |
return true; |
|
176 |
|
/** |
177 |
} // if |
* writeObject |
178 |
|
* @param value0 TODO |
179 |
// Unequal |
* @exception IOException TODO |
180 |
return false; |
*/ |
181 |
|
private void writeObject(ObjectOutputStream value0) |
182 |
} // equals() |
throws IOException |
183 |
|
{ |
184 |
/** |
// TODO |
185 |
* toString |
} |
186 |
* @returns String |
|
187 |
*/ |
/** |
188 |
public String toString() { |
* readObject |
189 |
return null; // TODO |
* @param value0 TODO |
190 |
} // toString() |
* @exception IOException TODO |
191 |
|
* @exception ClassNotFoundException TODO |
192 |
/** |
*/ |
193 |
* writeObject |
private void readObject(ObjectInputStream value0) |
194 |
* @param value0 TODO |
throws IOException, ClassNotFoundException |
195 |
* @exception IOException TODO |
{ |
196 |
*/ |
// TODO |
197 |
private void writeObject(ObjectOutputStream value0) throws IOException { |
} |
198 |
// TODO |
|
199 |
} // writeObject() |
/** |
200 |
|
* getPath |
201 |
/** |
* @returns Object[] |
202 |
* readObject |
*/ |
203 |
* @param value0 TODO |
public Object[] getPath() |
204 |
* @exception IOException TODO |
{ |
205 |
* @exception ClassNotFoundException TODO |
return path; |
206 |
*/ |
} |
207 |
private void readObject(ObjectInputStream value0) throws IOException, ClassNotFoundException { |
|
208 |
// TODO |
/** |
209 |
} // readObject() |
* getLastPathComponent |
210 |
|
* @returns Object |
211 |
/** |
*/ |
212 |
* getPath |
public Object getLastPathComponent() |
213 |
* @returns Object[] |
{ |
214 |
*/ |
return path[path.length - 1]; |
215 |
public Object[] getPath() { |
} |
216 |
return path; |
|
217 |
} // getPath() |
/** |
218 |
|
* getPathCount |
219 |
/** |
* @returns int |
220 |
* getLastPathComponent |
*/ |
221 |
* @returns Object |
public int getPathCount() |
222 |
*/ |
{ |
223 |
public Object getLastPathComponent() { |
return path.length; |
224 |
return path[path.length - 1]; |
} |
225 |
} // getLastPathComponent() |
|
226 |
|
/** |
227 |
/** |
* getPathComponent |
228 |
* getPathCount |
* @param position TODO |
229 |
* @returns int |
* @returns Object |
230 |
*/ |
*/ |
231 |
public int getPathCount() { |
public Object getPathComponent(int position) |
232 |
return path.length; |
{ |
233 |
} // getPathCount() |
return path[position]; |
234 |
|
} |
235 |
/** |
|
236 |
* getPathComponent |
/** |
237 |
* @param position TODO |
* isDescendant |
238 |
* @returns Object |
* @param path TODO |
239 |
*/ |
* @returns boolean |
240 |
public Object getPathComponent(int position) { |
*/ |
241 |
return path[position]; |
public boolean isDescendant(TreePath path) |
242 |
} // getPathComponent() |
{ |
243 |
|
|
244 |
/** |
// Variables |
245 |
* isDescendant |
Object[] treepath; |
246 |
* @param path TODO |
int index; |
247 |
* @returns boolean |
int index2; |
248 |
*/ |
|
249 |
public boolean isDescendant(TreePath path) { |
// Get Descendant path |
250 |
|
treepath = path.getPath(); |
251 |
// Variables |
|
252 |
Object[] treepath; |
// Locate Start Index |
253 |
int index; |
index = 0; |
254 |
int index2; |
index2 = 0; |
255 |
|
while (treepath[index] != this.path[index2]) |
256 |
// Get Descendant path |
index++; |
257 |
treepath = path.getPath(); |
|
258 |
|
// Verify Paths |
259 |
// Locate Start Index |
while (treepath[index] == this.path[index2]) |
260 |
index = 0; |
{ |
261 |
index2 = 0; |
index++; |
262 |
while (treepath[index] != this.path[index2]) { |
index2++; |
263 |
index++; |
} |
264 |
} // while |
|
265 |
|
// Check for descendant |
266 |
// Verify Paths |
if (index2 != this.path.length) |
267 |
while (treepath[index] == this.path[index2]) { |
return false; |
268 |
index++; |
|
269 |
index2++; |
// Is Descendant |
270 |
} // while |
return true; |
271 |
|
|
272 |
// Check for descendant |
} |
273 |
if (index2 != this.path.length) { |
|
274 |
return false; |
/** |
275 |
} // if |
* pathByAddingChild |
276 |
|
* @param element TODO |
277 |
// Is Descendant |
* @returns TreePath |
278 |
return true; |
*/ |
279 |
|
public TreePath pathByAddingChild(Object element) |
280 |
} // isDescendant() |
{ |
281 |
|
return new TreePath(this, element); |
282 |
/** |
} |
283 |
* pathByAddingChild |
|
284 |
* @param element TODO |
/** |
285 |
* @returns TreePath |
* getParentPath |
286 |
*/ |
* @returns TreePath |
287 |
public TreePath pathByAddingChild(Object element) { |
*/ |
288 |
return new TreePath(this, element); |
public TreePath getParentPath() |
289 |
} // pathByAddingChild() |
{ |
290 |
|
return new TreePath(this.getPath(), path.length - 1); |
291 |
/** |
} |
292 |
* getParentPath |
} |
|
* @returns TreePath |
|
|
*/ |
|
|
public TreePath getParentPath() { |
|
|
return new TreePath(this.getPath(), path.length - 1); |
|
|
} // getParentPath() |
|
|
|
|
|
|
|
|
} // TreePath |
|