JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / swingjs / j2s / javax / swing / text / SimpleAttributeSet.js
1 Clazz.declarePackage ("javax.swing.text");\r
2 Clazz.load (["javax.swing.text.AttributeSet", "$.MutableAttributeSet", "java.util.Hashtable"], "javax.swing.text.SimpleAttributeSet", ["java.util.Enumeration", "$.NoSuchElementException", "javax.swing.text.StyleConstants"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.table = null;\r
5 Clazz.instantialize (this, arguments);\r
6 }, javax.swing.text, "SimpleAttributeSet", null, [javax.swing.text.MutableAttributeSet, Cloneable]);\r
7 Clazz.prepareFields (c$, function () {\r
8 this.table =  new java.util.Hashtable (3);\r
9 });\r
10 Clazz.makeConstructor (c$, \r
11 function () {\r
12 });\r
13 Clazz.makeConstructor (c$, \r
14 function (source) {\r
15 this.addAttributes (source);\r
16 }, "javax.swing.text.AttributeSet");\r
17 Clazz.defineMethod (c$, "isEmpty", \r
18 function () {\r
19 return this.table.isEmpty ();\r
20 });\r
21 Clazz.defineMethod (c$, "getAttributeCount", \r
22 function () {\r
23 return this.table.size ();\r
24 });\r
25 Clazz.overrideMethod (c$, "isDefined", \r
26 function (attrName) {\r
27 return this.table.containsKey (attrName);\r
28 }, "~O");\r
29 Clazz.overrideMethod (c$, "isEqual", \r
30 function (attr) {\r
31 return ((this.getAttributeCount () == attr.getAttributeCount ()) && this.containsAttributes (attr));\r
32 }, "javax.swing.text.AttributeSet");\r
33 Clazz.overrideMethod (c$, "copyAttributes", \r
34 function () {\r
35 return this.clone ();\r
36 });\r
37 Clazz.defineMethod (c$, "getAttributeNames", \r
38 function () {\r
39 return this.table.keys ();\r
40 });\r
41 Clazz.defineMethod (c$, "getAttribute", \r
42 function (name) {\r
43 var value = this.table.get (name);\r
44 if (value == null) {\r
45 var parent = this.getResolveParent ();\r
46 if (parent != null) {\r
47 value = parent.getAttribute (name);\r
48 }}return value;\r
49 }, "~O");\r
50 Clazz.overrideMethod (c$, "containsAttribute", \r
51 function (name, value) {\r
52 return value.equals (this.getAttribute (name));\r
53 }, "~O,~O");\r
54 Clazz.overrideMethod (c$, "containsAttributes", \r
55 function (attributes) {\r
56 var result = true;\r
57 var names = attributes.getAttributeNames ();\r
58 while (result && names.hasMoreElements ()) {\r
59 var name = names.nextElement ();\r
60 result = attributes.getAttribute (name).equals (this.getAttribute (name));\r
61 }\r
62 return result;\r
63 }, "javax.swing.text.AttributeSet");\r
64 Clazz.overrideMethod (c$, "addAttribute", \r
65 function (name, value) {\r
66 this.table.put (name, value);\r
67 }, "~O,~O");\r
68 Clazz.overrideMethod (c$, "addAttributes", \r
69 function (attributes) {\r
70 var names = attributes.getAttributeNames ();\r
71 while (names.hasMoreElements ()) {\r
72 var name = names.nextElement ();\r
73 this.addAttribute (name, attributes.getAttribute (name));\r
74 }\r
75 }, "javax.swing.text.AttributeSet");\r
76 Clazz.overrideMethod (c$, "removeAttribute", \r
77 function (name) {\r
78 this.table.remove (name);\r
79 }, "~O");\r
80 Clazz.defineMethod (c$, "removeAttributes", \r
81 function (names) {\r
82 while (names.hasMoreElements ()) this.removeAttribute (names.nextElement ());\r
83 \r
84 }, "java.util.Enumeration");\r
85 Clazz.defineMethod (c$, "removeAttributes", \r
86 function (attributes) {\r
87 if (attributes === this) {\r
88 this.table.clear ();\r
89 } else {\r
90 var names = attributes.getAttributeNames ();\r
91 while (names.hasMoreElements ()) {\r
92 var name = names.nextElement ();\r
93 var value = attributes.getAttribute (name);\r
94 if (value.equals (this.getAttribute (name))) this.removeAttribute (name);\r
95 }\r
96 }}, "javax.swing.text.AttributeSet");\r
97 Clazz.overrideMethod (c$, "getResolveParent", \r
98 function () {\r
99 return this.table.get (javax.swing.text.StyleConstants.ResolveAttribute);\r
100 });\r
101 Clazz.overrideMethod (c$, "setResolveParent", \r
102 function (parent) {\r
103 this.addAttribute (javax.swing.text.StyleConstants.ResolveAttribute, parent);\r
104 }, "javax.swing.text.AttributeSet");\r
105 Clazz.defineMethod (c$, "clone", \r
106 function () {\r
107 var attr;\r
108 try {\r
109 attr = Clazz.superCall (this, javax.swing.text.SimpleAttributeSet, "clone", []);\r
110 attr.table = this.table.clone ();\r
111 } catch (cnse) {\r
112 if (Clazz.exceptionOf (cnse, CloneNotSupportedException)) {\r
113 attr = null;\r
114 } else {\r
115 throw cnse;\r
116 }\r
117 }\r
118 return attr;\r
119 });\r
120 Clazz.overrideMethod (c$, "hashCode", \r
121 function () {\r
122 return this.table.hashCode ();\r
123 });\r
124 Clazz.defineMethod (c$, "equals", \r
125 function (obj) {\r
126 if (this === obj) {\r
127 return true;\r
128 }if (Clazz.instanceOf (obj, javax.swing.text.AttributeSet)) {\r
129 var attrs = obj;\r
130 return this.isEqual (attrs);\r
131 }return false;\r
132 }, "~O");\r
133 Clazz.overrideMethod (c$, "toString", \r
134 function () {\r
135 var s = "";\r
136 var names = this.getAttributeNames ();\r
137 while (names.hasMoreElements ()) {\r
138 var key = names.nextElement ();\r
139 var value = this.getAttribute (key);\r
140 if (Clazz.instanceOf (value, javax.swing.text.AttributeSet)) {\r
141 s = s + key + "=**AttributeSet** ";\r
142 } else {\r
143 s = s + key + "=" + value + " ";\r
144 }}\r
145 return s;\r
146 });\r
147 Clazz.pu$h(self.c$);\r
148 c$ = Clazz.declareType (javax.swing.text.SimpleAttributeSet, "EmptyAttributeSet", null, javax.swing.text.AttributeSet);\r
149 Clazz.defineMethod (c$, "getAttributeCount", \r
150 function () {\r
151 return 0;\r
152 });\r
153 Clazz.overrideMethod (c$, "isDefined", \r
154 function (a) {\r
155 return false;\r
156 }, "~O");\r
157 Clazz.overrideMethod (c$, "isEqual", \r
158 function (a) {\r
159 return (a.getAttributeCount () == 0);\r
160 }, "javax.swing.text.AttributeSet");\r
161 Clazz.overrideMethod (c$, "copyAttributes", \r
162 function () {\r
163 return this;\r
164 });\r
165 Clazz.overrideMethod (c$, "getAttribute", \r
166 function (a) {\r
167 return null;\r
168 }, "~O");\r
169 Clazz.overrideMethod (c$, "getAttributeNames", \r
170 function () {\r
171 return ((Clazz.isClassDefined ("javax.swing.text.SimpleAttributeSet$EmptyAttributeSet$1") ? 0 : javax.swing.text.SimpleAttributeSet.EmptyAttributeSet.$SimpleAttributeSet$EmptyAttributeSet$1$ ()), Clazz.innerTypeInstance (javax.swing.text.SimpleAttributeSet$EmptyAttributeSet$1, this, null));\r
172 });\r
173 Clazz.overrideMethod (c$, "containsAttribute", \r
174 function (a, b) {\r
175 return false;\r
176 }, "~O,~O");\r
177 Clazz.overrideMethod (c$, "containsAttributes", \r
178 function (a) {\r
179 return (a.getAttributeCount () == 0);\r
180 }, "javax.swing.text.AttributeSet");\r
181 Clazz.overrideMethod (c$, "getResolveParent", \r
182 function () {\r
183 return null;\r
184 });\r
185 Clazz.overrideMethod (c$, "equals", \r
186 function (a) {\r
187 if (this === a) {\r
188 return true;\r
189 }return ((Clazz.instanceOf (a, javax.swing.text.AttributeSet)) && ((a).getAttributeCount () == 0));\r
190 }, "~O");\r
191 Clazz.overrideMethod (c$, "hashCode", \r
192 function () {\r
193 return 0;\r
194 });\r
195 c$.$SimpleAttributeSet$EmptyAttributeSet$1$ = function () {\r
196 Clazz.pu$h(self.c$);\r
197 c$ = Clazz.declareAnonymous (javax.swing.text, "SimpleAttributeSet$EmptyAttributeSet$1", null, java.util.Enumeration);\r
198 Clazz.overrideMethod (c$, "hasMoreElements", \r
199 function () {\r
200 return false;\r
201 });\r
202 Clazz.overrideMethod (c$, "nextElement", \r
203 function () {\r
204 throw  new java.util.NoSuchElementException ();\r
205 });\r
206 c$ = Clazz.p0p ();\r
207 };\r
208 c$ = Clazz.p0p ();\r
209 c$.EMPTY = c$.prototype.EMPTY =  new javax.swing.text.SimpleAttributeSet.EmptyAttributeSet ();\r
210 });\r