f63c650f42d1f2f945efe6c88fa43032772d1d0e
[jalviewjs.git] / site / j2s / javax / swing / tree / TreePath.js
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
9 function (path) {\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
13 }, "~A");\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
19 }, "~O");\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
30 }, "~A,~N");\r
31 Clazz.makeConstructor (c$, \r
32 function () {\r
33 });\r
34 Clazz.defineMethod (c$, "getPath", \r
35 function () {\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
40 }\r
41 return result;\r
42 });\r
43 Clazz.defineMethod (c$, "getLastPathComponent", \r
44 function () {\r
45 return this.lastPathComponent;\r
46 });\r
47 Clazz.defineMethod (c$, "getPathCount", \r
48 function () {\r
49 var result = 0;\r
50 for (var path = this; path != null; path = path.parentPath) {\r
51 result++;\r
52 }\r
53 return result;\r
54 });\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
59 var path = this;\r
60 for (var i = pathLength - 1; i != element; i--) {\r
61 path = path.parentPath;\r
62 }\r
63 return path.lastPathComponent;\r
64 }, "~N");\r
65 Clazz.defineMethod (c$, "equals", \r
66 function (o) {\r
67 if (o === this) return true;\r
68 if (Clazz.instanceOf (o, javax.swing.tree.TreePath)) {\r
69 var oTreePath = o;\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
73 return false;\r
74 }oTreePath = oTreePath.parentPath;\r
75 }\r
76 return true;\r
77 }return false;\r
78 }, "~O");\r
79 Clazz.defineMethod (c$, "hashCode", \r
80 function () {\r
81 return this.lastPathComponent.hashCode ();\r
82 });\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
91 \r
92 return this.equals (aTreePath);\r
93 }return false;\r
94 }, "javax.swing.tree.TreePath");\r
95 Clazz.defineMethod (c$, "pathByAddingChild", \r
96 function (child) {\r
97 if (child == null) throw  new NullPointerException ("Null child not allowed");\r
98 return  new javax.swing.tree.TreePath (this, child);\r
99 }, "~O");\r
100 Clazz.defineMethod (c$, "getParentPath", \r
101 function () {\r
102 return this.parentPath;\r
103 });\r
104 Clazz.overrideMethod (c$, "toString", \r
105 function () {\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
110 }\r
111 tempSpot.append ("]");\r
112 return tempSpot.toString ();\r
113 });\r
114 });\r