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