1 Clazz.declarePackage ("javax.swing.tree");
2 Clazz.load (null, "javax.swing.tree.TreePath", ["java.lang.IllegalArgumentException", "$.NullPointerException", "$.StringBuffer"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.parentPath = null;
5 this.lastPathComponent = null;
6 Clazz.instantialize (this, arguments);
7 }, javax.swing.tree, "TreePath");
8 Clazz.makeConstructor (c$,
10 if (path == null || path.length == 0) throw new IllegalArgumentException ("path in TreePath must be non null and not empty.");
11 this.lastPathComponent = path[path.length - 1];
12 if (path.length > 1) this.parentPath = new javax.swing.tree.TreePath (path, path.length - 1);
14 Clazz.makeConstructor (c$,
15 function (singlePath) {
16 if (singlePath == null) throw new IllegalArgumentException ("path in TreePath must be non null.");
17 this.lastPathComponent = singlePath;
18 this.parentPath = null;
20 Clazz.makeConstructor (c$,
21 function (parent, lastElement) {
22 if (lastElement == null) throw new IllegalArgumentException ("path in TreePath must be non null.");
23 this.parentPath = parent;
24 this.lastPathComponent = lastElement;
25 }, "javax.swing.tree.TreePath,~O");
26 Clazz.makeConstructor (c$,
27 function (path, length) {
28 this.lastPathComponent = path[length - 1];
29 if (length > 1) this.parentPath = new javax.swing.tree.TreePath (path, length - 1);
31 Clazz.makeConstructor (c$,
34 Clazz.defineMethod (c$, "getPath",
36 var i = this.getPathCount ();
37 var result = new Array (i--);
38 for (var path = this; path != null; path = path.parentPath) {
39 result[i--] = path.lastPathComponent;
43 Clazz.defineMethod (c$, "getLastPathComponent",
45 return this.lastPathComponent;
47 Clazz.defineMethod (c$, "getPathCount",
50 for (var path = this; path != null; path = path.parentPath) {
55 Clazz.defineMethod (c$, "getPathComponent",
57 var pathLength = this.getPathCount ();
58 if (element < 0 || element >= pathLength) throw new IllegalArgumentException ("Index " + element + " is out of the specified range");
60 for (var i = pathLength - 1; i != element; i--) {
61 path = path.parentPath;
63 return path.lastPathComponent;
65 Clazz.defineMethod (c$, "equals",
67 if (o === this) return true;
68 if (Clazz.instanceOf (o, javax.swing.tree.TreePath)) {
70 if (this.getPathCount () != oTreePath.getPathCount ()) return false;
71 for (var path = this; path != null; path = path.parentPath) {
72 if (!(path.lastPathComponent.equals (oTreePath.lastPathComponent))) {
74 }oTreePath = oTreePath.parentPath;
79 Clazz.defineMethod (c$, "hashCode",
81 return this.lastPathComponent.hashCode ();
83 Clazz.defineMethod (c$, "isDescendant",
84 function (aTreePath) {
85 if (aTreePath === this) return true;
86 if (aTreePath != null) {
87 var pathLength = this.getPathCount ();
88 var oPathLength = aTreePath.getPathCount ();
89 if (oPathLength < pathLength) return false;
90 while (oPathLength-- > pathLength) aTreePath = aTreePath.getParentPath ();
92 return this.equals (aTreePath);
94 }, "javax.swing.tree.TreePath");
95 Clazz.defineMethod (c$, "pathByAddingChild",
97 if (child == null) throw new NullPointerException ("Null child not allowed");
98 return new javax.swing.tree.TreePath (this, child);
100 Clazz.defineMethod (c$, "getParentPath",
102 return this.parentPath;
104 Clazz.overrideMethod (c$, "toString",
106 var tempSpot = new StringBuffer ("[");
107 for (var counter = 0, maxCounter = this.getPathCount (); counter < maxCounter; counter++) {
108 if (counter > 0) tempSpot.append (", ");
109 tempSpot.append (this.getPathComponent (counter));
111 tempSpot.append ("]");
112 return tempSpot.toString ();