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