0a49c697ed0a5b7d01fa12086bcadbb6ea9aff5b
[jalviewjs.git] / site / j2s / java / text / AttributedString.js
1 Clazz.declarePackage ("java.text");\r
2 Clazz.load (["java.util.AbstractMap", "$.Map", "java.text.AttributedCharacterIterator"], ["java.text.AttributedString", "$.AttributeEntry"], ["java.lang.IllegalArgumentException", "$.InternalError", "$.NullPointerException", "$.StringBuffer", "$.UnsupportedOperationException", "java.util.HashSet", "$.Hashtable", "$.Vector", "java.text.Annotation"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.text = null;\r
5 this.runArraySize = 0;\r
6 this.runCount = 0;\r
7 this.runStarts = null;\r
8 this.runAttributes = null;\r
9 this.runAttributeValues = null;\r
10 if (!Clazz.isClassDefined ("java.text.AttributedString.AttributedStringIterator")) {\r
11 java.text.AttributedString.$AttributedString$AttributedStringIterator$ ();\r
12 }\r
13 if (!Clazz.isClassDefined ("java.text.AttributedString.AttributeMap")) {\r
14 java.text.AttributedString.$AttributedString$AttributeMap$ ();\r
15 }\r
16 Clazz.instantialize (this, arguments);\r
17 }, java.text, "AttributedString");\r
18 Clazz.makeConstructor (c$, \r
19 function (iterators) {\r
20 if (iterators == null) {\r
21 throw  new NullPointerException ("Iterators must not be null");\r
22 }if (iterators.length == 0) {\r
23 this.text = "";\r
24 } else {\r
25 var buffer =  new StringBuffer ();\r
26 for (var counter = 0; counter < iterators.length; counter++) {\r
27 this.appendContents (buffer, iterators[counter]);\r
28 }\r
29 this.text = buffer.toString ();\r
30 if (this.text.length > 0) {\r
31 var offset = 0;\r
32 var last = null;\r
33 for (var counter = 0; counter < iterators.length; counter++) {\r
34 var iterator = iterators[counter];\r
35 var start = iterator.getBeginIndex ();\r
36 var end = iterator.getEndIndex ();\r
37 var index = start;\r
38 while (index < end) {\r
39 iterator.setIndex (index);\r
40 var attrs = iterator.getAttributes ();\r
41 if (java.text.AttributedString.mapsDiffer (last, attrs)) {\r
42 this.setAttributes (attrs, index - start + offset);\r
43 }last = attrs;\r
44 index = iterator.getRunLimit ();\r
45 }\r
46 offset += (end - start);\r
47 }\r
48 }}}, "~A");\r
49 Clazz.makeConstructor (c$, \r
50 function (text) {\r
51 if (text == null) {\r
52 throw  new NullPointerException ();\r
53 }this.text = text;\r
54 }, "~S");\r
55 Clazz.makeConstructor (c$, \r
56 function (text, attributes) {\r
57 if (text == null || attributes == null) {\r
58 throw  new NullPointerException ();\r
59 }this.text = text;\r
60 if (text.length == 0) {\r
61 if (attributes.isEmpty ()) return;\r
62 throw  new IllegalArgumentException ("Can't add attribute to 0-length text");\r
63 }var attributeCount = attributes.size ();\r
64 if (attributeCount > 0) {\r
65 this.createRunAttributeDataVectors ();\r
66 var newRunAttributes =  new java.util.Vector (attributeCount);\r
67 var newRunAttributeValues =  new java.util.Vector (attributeCount);\r
68 this.runAttributes[0] = newRunAttributes;\r
69 this.runAttributeValues[0] = newRunAttributeValues;\r
70 var iterator = attributes.entrySet ().iterator ();\r
71 while (iterator.hasNext ()) {\r
72 var entry = iterator.next ();\r
73 newRunAttributes.addElement (entry.getKey ());\r
74 newRunAttributeValues.addElement (entry.getValue ());\r
75 }\r
76 }}, "~S,java.util.Map");\r
77 Clazz.makeConstructor (c$, \r
78 function (text) {\r
79 this.construct (text, text.getBeginIndex (), text.getEndIndex (), null);\r
80 }, "java.text.AttributedCharacterIterator");\r
81 Clazz.makeConstructor (c$, \r
82 function (text, beginIndex, endIndex) {\r
83 this.construct (text, beginIndex, endIndex, null);\r
84 }, "java.text.AttributedCharacterIterator,~N,~N");\r
85 Clazz.makeConstructor (c$, \r
86 function (text, beginIndex, endIndex, attributes) {\r
87 if (text == null) {\r
88 throw  new NullPointerException ();\r
89 }var textBeginIndex = text.getBeginIndex ();\r
90 var textEndIndex = text.getEndIndex ();\r
91 if (beginIndex < textBeginIndex || endIndex > textEndIndex || beginIndex > endIndex) throw  new IllegalArgumentException ("Invalid substring range");\r
92 var textBuffer =  new StringBuffer ();\r
93 text.setIndex (beginIndex);\r
94 for (var c = text.current (); text.getIndex () < endIndex; c = text.next ()) textBuffer.append (c);\r
95 \r
96 this.text = textBuffer.toString ();\r
97 if (beginIndex == endIndex) return;\r
98 var keys =  new java.util.HashSet ();\r
99 if (attributes == null) {\r
100 keys.addAll (text.getAllAttributeKeys ());\r
101 } else {\r
102 for (var i = 0; i < attributes.length; i++) keys.add (attributes[i]);\r
103 \r
104 keys.retainAll (text.getAllAttributeKeys ());\r
105 }if (keys.isEmpty ()) return;\r
106 var itr = keys.iterator ();\r
107 while (itr.hasNext ()) {\r
108 var attributeKey = itr.next ();\r
109 text.setIndex (textBeginIndex);\r
110 while (text.getIndex () < endIndex) {\r
111 var start = text.getRunStart (attributeKey);\r
112 var limit = text.getRunLimit (attributeKey);\r
113 var value = text.getAttribute (attributeKey);\r
114 if (value != null) {\r
115 if (Clazz.instanceOf (value, java.text.Annotation)) {\r
116 if (start >= beginIndex && limit <= endIndex) {\r
117 this.addAttribute (attributeKey, value, start - beginIndex, limit - beginIndex);\r
118 } else {\r
119 if (limit > endIndex) break;\r
120 }} else {\r
121 if (start >= endIndex) break;\r
122 if (limit > beginIndex) {\r
123 if (start < beginIndex) start = beginIndex;\r
124 if (limit > endIndex) limit = endIndex;\r
125 if (start != limit) {\r
126 this.addAttribute (attributeKey, value, start - beginIndex, limit - beginIndex);\r
127 }}}}text.setIndex (limit);\r
128 }\r
129 }\r
130 }, "java.text.AttributedCharacterIterator,~N,~N,~A");\r
131 Clazz.defineMethod (c$, "addAttribute", \r
132 function (attribute, value) {\r
133 if (attribute == null) {\r
134 throw  new NullPointerException ();\r
135 }var len = this.length ();\r
136 if (len == 0) {\r
137 throw  new IllegalArgumentException ("Can't add attribute to 0-length text");\r
138 }this.addAttributeImpl (attribute, value, 0, len);\r
139 }, "java.text.AttributedCharacterIterator.Attribute,~O");\r
140 Clazz.defineMethod (c$, "addAttribute", \r
141 function (attribute, value, beginIndex, endIndex) {\r
142 if (attribute == null) {\r
143 throw  new NullPointerException ();\r
144 }if (beginIndex < 0 || endIndex > this.length () || beginIndex >= endIndex) {\r
145 throw  new IllegalArgumentException ("Invalid substring range");\r
146 }this.addAttributeImpl (attribute, value, beginIndex, endIndex);\r
147 }, "java.text.AttributedCharacterIterator.Attribute,~O,~N,~N");\r
148 Clazz.defineMethod (c$, "addAttributes", \r
149 function (attributes, beginIndex, endIndex) {\r
150 if (attributes == null) {\r
151 throw  new NullPointerException ();\r
152 }if (beginIndex < 0 || endIndex > this.length () || beginIndex > endIndex) {\r
153 throw  new IllegalArgumentException ("Invalid substring range");\r
154 }if (beginIndex == endIndex) {\r
155 if (attributes.isEmpty ()) return;\r
156 throw  new IllegalArgumentException ("Can't add attribute to 0-length text");\r
157 }if (this.runCount == 0) {\r
158 this.createRunAttributeDataVectors ();\r
159 }var beginRunIndex = this.ensureRunBreak (beginIndex);\r
160 var endRunIndex = this.ensureRunBreak (endIndex);\r
161 var iterator = attributes.entrySet ().iterator ();\r
162 while (iterator.hasNext ()) {\r
163 var entry = iterator.next ();\r
164 this.addAttributeRunData (entry.getKey (), entry.getValue (), beginRunIndex, endRunIndex);\r
165 }\r
166 }, "java.util.Map,~N,~N");\r
167 Clazz.defineMethod (c$, "addAttributeImpl", \r
168  function (attribute, value, beginIndex, endIndex) {\r
169 if (this.runCount == 0) {\r
170 this.createRunAttributeDataVectors ();\r
171 }var beginRunIndex = this.ensureRunBreak (beginIndex);\r
172 var endRunIndex = this.ensureRunBreak (endIndex);\r
173 this.addAttributeRunData (attribute, value, beginRunIndex, endRunIndex);\r
174 }, "java.text.AttributedCharacterIterator.Attribute,~O,~N,~N");\r
175 Clazz.defineMethod (c$, "createRunAttributeDataVectors", \r
176  function () {\r
177 var newRunStarts =  Clazz.newIntArray (10, 0);\r
178 var newRunAttributes =  new Array (10);\r
179 var newRunAttributeValues =  new Array (10);\r
180 this.runStarts = newRunStarts;\r
181 this.runAttributes = newRunAttributes;\r
182 this.runAttributeValues = newRunAttributeValues;\r
183 this.runArraySize = 10;\r
184 this.runCount = 1;\r
185 });\r
186 Clazz.defineMethod (c$, "ensureRunBreak", \r
187  function (offset) {\r
188 return this.ensureRunBreak (offset, true);\r
189 }, "~N");\r
190 Clazz.defineMethod (c$, "ensureRunBreak", \r
191  function (offset, copyAttrs) {\r
192 if (offset == this.length ()) {\r
193 return this.runCount;\r
194 }var runIndex = 0;\r
195 while (runIndex < this.runCount && this.runStarts[runIndex] < offset) {\r
196 runIndex++;\r
197 }\r
198 if (runIndex < this.runCount && this.runStarts[runIndex] == offset) {\r
199 return runIndex;\r
200 }if (this.runCount == this.runArraySize) {\r
201 var newArraySize = this.runArraySize + 10;\r
202 var newRunStarts =  Clazz.newIntArray (newArraySize, 0);\r
203 var newRunAttributes =  new Array (newArraySize);\r
204 var newRunAttributeValues =  new Array (newArraySize);\r
205 for (var i = 0; i < this.runArraySize; i++) {\r
206 newRunStarts[i] = this.runStarts[i];\r
207 newRunAttributes[i] = this.runAttributes[i];\r
208 newRunAttributeValues[i] = this.runAttributeValues[i];\r
209 }\r
210 this.runStarts = newRunStarts;\r
211 this.runAttributes = newRunAttributes;\r
212 this.runAttributeValues = newRunAttributeValues;\r
213 this.runArraySize = newArraySize;\r
214 }var newRunAttributes = null;\r
215 var newRunAttributeValues = null;\r
216 if (copyAttrs) {\r
217 var oldRunAttributes = this.runAttributes[runIndex - 1];\r
218 var oldRunAttributeValues = this.runAttributeValues[runIndex - 1];\r
219 if (oldRunAttributes != null) {\r
220 newRunAttributes = oldRunAttributes.clone ();\r
221 }if (oldRunAttributeValues != null) {\r
222 newRunAttributeValues = oldRunAttributeValues.clone ();\r
223 }}this.runCount++;\r
224 for (var i = this.runCount - 1; i > runIndex; i--) {\r
225 this.runStarts[i] = this.runStarts[i - 1];\r
226 this.runAttributes[i] = this.runAttributes[i - 1];\r
227 this.runAttributeValues[i] = this.runAttributeValues[i - 1];\r
228 }\r
229 this.runStarts[runIndex] = offset;\r
230 this.runAttributes[runIndex] = newRunAttributes;\r
231 this.runAttributeValues[runIndex] = newRunAttributeValues;\r
232 return runIndex;\r
233 }, "~N,~B");\r
234 Clazz.defineMethod (c$, "addAttributeRunData", \r
235  function (attribute, value, beginRunIndex, endRunIndex) {\r
236 for (var i = beginRunIndex; i < endRunIndex; i++) {\r
237 var keyValueIndex = -1;\r
238 if (this.runAttributes[i] == null) {\r
239 var newRunAttributes =  new java.util.Vector ();\r
240 var newRunAttributeValues =  new java.util.Vector ();\r
241 this.runAttributes[i] = newRunAttributes;\r
242 this.runAttributeValues[i] = newRunAttributeValues;\r
243 } else {\r
244 keyValueIndex = this.runAttributes[i].indexOf (attribute);\r
245 }if (keyValueIndex == -1) {\r
246 var oldSize = this.runAttributes[i].size ();\r
247 this.runAttributes[i].addElement (attribute);\r
248 try {\r
249 this.runAttributeValues[i].addElement (value);\r
250 } catch (e) {\r
251 if (Clazz.exceptionOf (e, Exception)) {\r
252 this.runAttributes[i].setSize (oldSize);\r
253 this.runAttributeValues[i].setSize (oldSize);\r
254 } else {\r
255 throw e;\r
256 }\r
257 }\r
258 } else {\r
259 this.runAttributeValues[i].set (keyValueIndex, value);\r
260 }}\r
261 }, "java.text.AttributedCharacterIterator.Attribute,~O,~N,~N");\r
262 Clazz.defineMethod (c$, "getIterator", \r
263 function () {\r
264 return this.getIterator (null, 0, this.length ());\r
265 });\r
266 Clazz.defineMethod (c$, "getIterator", \r
267 function (attributes) {\r
268 return this.getIterator (attributes, 0, this.length ());\r
269 }, "~A");\r
270 Clazz.defineMethod (c$, "getIterator", \r
271 function (attributes, beginIndex, endIndex) {\r
272 return Clazz.innerTypeInstance (java.text.AttributedString.AttributedStringIterator, this, null, attributes, beginIndex, endIndex);\r
273 }, "~A,~N,~N");\r
274 Clazz.defineMethod (c$, "length", \r
275 function () {\r
276 return this.text.length;\r
277 });\r
278 Clazz.defineMethod (c$, "charAt", \r
279  function (index) {\r
280 return this.text.charAt (index);\r
281 }, "~N");\r
282 Clazz.defineMethod (c$, "getAttribute", \r
283  function (attribute, runIndex) {\r
284 var currentRunAttributes = this.runAttributes[runIndex];\r
285 var currentRunAttributeValues = this.runAttributeValues[runIndex];\r
286 if (currentRunAttributes == null) {\r
287 return null;\r
288 }var attributeIndex = currentRunAttributes.indexOf (attribute);\r
289 if (attributeIndex != -1) {\r
290 return currentRunAttributeValues.elementAt (attributeIndex);\r
291 } else {\r
292 return null;\r
293 }}, "java.text.AttributedCharacterIterator.Attribute,~N");\r
294 Clazz.defineMethod (c$, "getAttributeCheckRange", \r
295  function (attribute, runIndex, beginIndex, endIndex) {\r
296 var value = this.getAttribute (attribute, runIndex);\r
297 if (Clazz.instanceOf (value, java.text.Annotation)) {\r
298 if (beginIndex > 0) {\r
299 var currIndex = runIndex;\r
300 var runStart = this.runStarts[currIndex];\r
301 while (runStart >= beginIndex && java.text.AttributedString.valuesMatch (value, this.getAttribute (attribute, currIndex - 1))) {\r
302 currIndex--;\r
303 runStart = this.runStarts[currIndex];\r
304 }\r
305 if (runStart < beginIndex) {\r
306 return null;\r
307 }}var textLength = this.length ();\r
308 if (endIndex < textLength) {\r
309 var currIndex = runIndex;\r
310 var runLimit = (currIndex < this.runCount - 1) ? this.runStarts[currIndex + 1] : textLength;\r
311 while (runLimit <= endIndex && java.text.AttributedString.valuesMatch (value, this.getAttribute (attribute, currIndex + 1))) {\r
312 currIndex++;\r
313 runLimit = (currIndex < this.runCount - 1) ? this.runStarts[currIndex + 1] : textLength;\r
314 }\r
315 if (runLimit > endIndex) {\r
316 return null;\r
317 }}}return value;\r
318 }, "java.text.AttributedCharacterIterator.Attribute,~N,~N,~N");\r
319 Clazz.defineMethod (c$, "attributeValuesMatch", \r
320  function (attributes, runIndex1, runIndex2) {\r
321 var iterator = attributes.iterator ();\r
322 while (iterator.hasNext ()) {\r
323 var key = iterator.next ();\r
324 if (!java.text.AttributedString.valuesMatch (this.getAttribute (key, runIndex1), this.getAttribute (key, runIndex2))) {\r
325 return false;\r
326 }}\r
327 return true;\r
328 }, "java.util.Set,~N,~N");\r
329 c$.valuesMatch = Clazz.defineMethod (c$, "valuesMatch", \r
330  function (value1, value2) {\r
331 if (value1 == null) {\r
332 return value2 == null;\r
333 } else {\r
334 return value1.equals (value2);\r
335 }}, "~O,~O");\r
336 Clazz.defineMethod (c$, "appendContents", \r
337  function (buf, iterator) {\r
338 var index = iterator.getBeginIndex ();\r
339 var end = iterator.getEndIndex ();\r
340 while (index < end) {\r
341 iterator.setIndex (index++);\r
342 buf.append (iterator.current ());\r
343 }\r
344 }, "StringBuffer,java.text.CharacterIterator");\r
345 Clazz.defineMethod (c$, "setAttributes", \r
346  function (attrs, offset) {\r
347 if (this.runCount == 0) {\r
348 this.createRunAttributeDataVectors ();\r
349 }var index = this.ensureRunBreak (offset, false);\r
350 var size;\r
351 if (attrs != null && (size = attrs.size ()) > 0) {\r
352 var runAttrs =  new java.util.Vector (size);\r
353 var runValues =  new java.util.Vector (size);\r
354 var iterator = attrs.entrySet ().iterator ();\r
355 while (iterator.hasNext ()) {\r
356 var entry = iterator.next ();\r
357 runAttrs.add (entry.getKey ());\r
358 runValues.add (entry.getValue ());\r
359 }\r
360 this.runAttributes[index] = runAttrs;\r
361 this.runAttributeValues[index] = runValues;\r
362 }}, "java.util.Map,~N");\r
363 c$.mapsDiffer = Clazz.defineMethod (c$, "mapsDiffer", \r
364  function (last, attrs) {\r
365 if (last == null) {\r
366 return (attrs != null && attrs.size () > 0);\r
367 }return (!last.equals (attrs));\r
368 }, "java.util.Map,java.util.Map");\r
369 c$.$AttributedString$AttributedStringIterator$ = function () {\r
370 Clazz.pu$h(self.c$);\r
371 c$ = Clazz.decorateAsClass (function () {\r
372 Clazz.prepareCallback (this, arguments);\r
373 this.beginIndex = 0;\r
374 this.endIndex = 0;\r
375 this.currentIndex = 0;\r
376 this.currentRunIndex = 0;\r
377 this.currentRunStart = 0;\r
378 this.currentRunLimit = 0;\r
379 Clazz.instantialize (this, arguments);\r
380 }, java.text.AttributedString, "AttributedStringIterator", null, java.text.AttributedCharacterIterator);\r
381 Clazz.makeConstructor (c$, \r
382 function (a, b, c) {\r
383 if (b < 0 || b > c || c > this.b$["java.text.AttributedString"].length ()) {\r
384 throw  new IllegalArgumentException ("Invalid substring range");\r
385 }this.beginIndex = b;\r
386 this.endIndex = c;\r
387 this.currentIndex = b;\r
388 this.updateRunInfo ();\r
389 }, "~A,~N,~N");\r
390 Clazz.overrideMethod (c$, "equals", \r
391 function (a) {\r
392 if (this === a) {\r
393 return true;\r
394 }if (!(Clazz.instanceOf (a, java.text.AttributedString.AttributedStringIterator))) {\r
395 return false;\r
396 }var b = a;\r
397 if (this.b$["java.text.AttributedString"] !== b.getString ()) return false;\r
398 if (this.currentIndex != b.currentIndex || this.beginIndex != b.beginIndex || this.endIndex != b.endIndex) return false;\r
399 return true;\r
400 }, "~O");\r
401 Clazz.overrideMethod (c$, "hashCode", \r
402 function () {\r
403 return this.b$["java.text.AttributedString"].text.hashCode () ^ this.currentIndex ^ this.beginIndex ^ this.endIndex;\r
404 });\r
405 Clazz.overrideMethod (c$, "clone", \r
406 function () {\r
407 try {\r
408 var a = Clazz.superCall (this, java.text.AttributedString.AttributedStringIterator, "clone", []);\r
409 return a;\r
410 } catch (e) {\r
411 if (Clazz.exceptionOf (e, CloneNotSupportedException)) {\r
412 throw  new InternalError ();\r
413 } else {\r
414 throw e;\r
415 }\r
416 }\r
417 });\r
418 Clazz.overrideMethod (c$, "first", \r
419 function () {\r
420 return this.internalSetIndex (this.beginIndex);\r
421 });\r
422 Clazz.overrideMethod (c$, "last", \r
423 function () {\r
424 if (this.endIndex == this.beginIndex) {\r
425 return this.internalSetIndex (this.endIndex);\r
426 } else {\r
427 return this.internalSetIndex (this.endIndex - 1);\r
428 }});\r
429 Clazz.overrideMethod (c$, "current", \r
430 function () {\r
431 if (this.currentIndex == this.endIndex) {\r
432 return '\uffff';\r
433 } else {\r
434 return this.b$["java.text.AttributedString"].charAt (this.currentIndex);\r
435 }});\r
436 Clazz.overrideMethod (c$, "next", \r
437 function () {\r
438 if (this.currentIndex < this.endIndex) {\r
439 return this.internalSetIndex (this.currentIndex + 1);\r
440 } else {\r
441 return '\uffff';\r
442 }});\r
443 Clazz.overrideMethod (c$, "previous", \r
444 function () {\r
445 if (this.currentIndex > this.beginIndex) {\r
446 return this.internalSetIndex (this.currentIndex - 1);\r
447 } else {\r
448 return '\uffff';\r
449 }});\r
450 Clazz.overrideMethod (c$, "setIndex", \r
451 function (a) {\r
452 if (a < this.beginIndex || a > this.endIndex) throw  new IllegalArgumentException ("Invalid index");\r
453 return this.internalSetIndex (a);\r
454 }, "~N");\r
455 Clazz.overrideMethod (c$, "getBeginIndex", \r
456 function () {\r
457 return this.beginIndex;\r
458 });\r
459 Clazz.overrideMethod (c$, "getEndIndex", \r
460 function () {\r
461 return this.endIndex;\r
462 });\r
463 Clazz.overrideMethod (c$, "getIndex", \r
464 function () {\r
465 return this.currentIndex;\r
466 });\r
467 Clazz.defineMethod (c$, "getRunStart", \r
468 function () {\r
469 return this.currentRunStart;\r
470 });\r
471 Clazz.defineMethod (c$, "getRunStart", \r
472 function (a) {\r
473 if (this.currentRunStart == this.beginIndex || this.currentRunIndex == -1) {\r
474 return this.currentRunStart;\r
475 } else {\r
476 var b = this.getAttribute (a);\r
477 var c = this.currentRunStart;\r
478 var d = this.currentRunIndex;\r
479 while (c > this.beginIndex && java.text.AttributedString.valuesMatch (b, this.b$["java.text.AttributedString"].getAttribute (a, d - 1))) {\r
480 d--;\r
481 c = this.b$["java.text.AttributedString"].runStarts[d];\r
482 }\r
483 if (c < this.beginIndex) {\r
484 c = this.beginIndex;\r
485 }return c;\r
486 }}, "java.text.AttributedCharacterIterator.Attribute");\r
487 Clazz.defineMethod (c$, "getRunStart", \r
488 function (a) {\r
489 if (this.currentRunStart == this.beginIndex || this.currentRunIndex == -1) {\r
490 return this.currentRunStart;\r
491 } else {\r
492 var b = this.currentRunStart;\r
493 var c = this.currentRunIndex;\r
494 while (b > this.beginIndex && this.b$["java.text.AttributedString"].attributeValuesMatch (a, this.currentRunIndex, c - 1)) {\r
495 c--;\r
496 b = this.b$["java.text.AttributedString"].runStarts[c];\r
497 }\r
498 if (b < this.beginIndex) {\r
499 b = this.beginIndex;\r
500 }return b;\r
501 }}, "java.util.Set");\r
502 Clazz.defineMethod (c$, "getRunLimit", \r
503 function () {\r
504 return this.currentRunLimit;\r
505 });\r
506 Clazz.defineMethod (c$, "getRunLimit", \r
507 function (a) {\r
508 if (this.currentRunLimit == this.endIndex || this.currentRunIndex == -1) {\r
509 return this.currentRunLimit;\r
510 } else {\r
511 var b = this.getAttribute (a);\r
512 var c = this.currentRunLimit;\r
513 var d = this.currentRunIndex;\r
514 while (c < this.endIndex && java.text.AttributedString.valuesMatch (b, this.b$["java.text.AttributedString"].getAttribute (a, d + 1))) {\r
515 d++;\r
516 c = d < this.b$["java.text.AttributedString"].runCount - 1 ? this.b$["java.text.AttributedString"].runStarts[d + 1] : this.endIndex;\r
517 }\r
518 if (c > this.endIndex) {\r
519 c = this.endIndex;\r
520 }return c;\r
521 }}, "java.text.AttributedCharacterIterator.Attribute");\r
522 Clazz.defineMethod (c$, "getRunLimit", \r
523 function (a) {\r
524 if (this.currentRunLimit == this.endIndex || this.currentRunIndex == -1) {\r
525 return this.currentRunLimit;\r
526 } else {\r
527 var b = this.currentRunLimit;\r
528 var c = this.currentRunIndex;\r
529 while (b < this.endIndex && this.b$["java.text.AttributedString"].attributeValuesMatch (a, this.currentRunIndex, c + 1)) {\r
530 c++;\r
531 b = c < this.b$["java.text.AttributedString"].runCount - 1 ? this.b$["java.text.AttributedString"].runStarts[c + 1] : this.endIndex;\r
532 }\r
533 if (b > this.endIndex) {\r
534 b = this.endIndex;\r
535 }return b;\r
536 }}, "java.util.Set");\r
537 Clazz.overrideMethod (c$, "getAttributes", \r
538 function () {\r
539 if (this.b$["java.text.AttributedString"].runAttributes == null || this.currentRunIndex == -1 || this.b$["java.text.AttributedString"].runAttributes[this.currentRunIndex] == null) {\r
540 return  new java.util.Hashtable ();\r
541 }return Clazz.innerTypeInstance (java.text.AttributedString.AttributeMap, this, null, this.currentRunIndex, this.beginIndex, this.endIndex);\r
542 });\r
543 Clazz.overrideMethod (c$, "getAllAttributeKeys", \r
544 function () {\r
545 if (this.b$["java.text.AttributedString"].runAttributes == null) {\r
546 return  new java.util.HashSet ();\r
547 }{\r
548 var a =  new java.util.HashSet ();\r
549 var b = 0;\r
550 while (b < this.b$["java.text.AttributedString"].runCount) {\r
551 if (this.b$["java.text.AttributedString"].runStarts[b] < this.endIndex && (b == this.b$["java.text.AttributedString"].runCount - 1 || this.b$["java.text.AttributedString"].runStarts[b + 1] > this.beginIndex)) {\r
552 var c = this.b$["java.text.AttributedString"].runAttributes[b];\r
553 if (c != null) {\r
554 var d = c.size ();\r
555 while (d-- > 0) {\r
556 a.add (c.get (d));\r
557 }\r
558 }}b++;\r
559 }\r
560 return a;\r
561 }});\r
562 Clazz.overrideMethod (c$, "getAttribute", \r
563 function (a) {\r
564 var b = this.currentRunIndex;\r
565 if (b < 0) {\r
566 return null;\r
567 }return this.b$["java.text.AttributedString"].getAttributeCheckRange (a, b, this.beginIndex, this.endIndex);\r
568 }, "java.text.AttributedCharacterIterator.Attribute");\r
569 Clazz.defineMethod (c$, "getString", \r
570  function () {\r
571 return this.b$["java.text.AttributedString"];\r
572 });\r
573 Clazz.defineMethod (c$, "internalSetIndex", \r
574  function (a) {\r
575 this.currentIndex = a;\r
576 if (a < this.currentRunStart || a >= this.currentRunLimit) {\r
577 this.updateRunInfo ();\r
578 }if (this.currentIndex == this.endIndex) {\r
579 return '\uffff';\r
580 } else {\r
581 return this.b$["java.text.AttributedString"].charAt (a);\r
582 }}, "~N");\r
583 Clazz.defineMethod (c$, "updateRunInfo", \r
584  function () {\r
585 if (this.currentIndex == this.endIndex) {\r
586 this.currentRunStart = this.currentRunLimit = this.endIndex;\r
587 this.currentRunIndex = -1;\r
588 } else {\r
589 {\r
590 var a = -1;\r
591 while (a < this.b$["java.text.AttributedString"].runCount - 1 && this.b$["java.text.AttributedString"].runStarts[a + 1] <= this.currentIndex) a++;\r
592 \r
593 this.currentRunIndex = a;\r
594 if (a >= 0) {\r
595 this.currentRunStart = this.b$["java.text.AttributedString"].runStarts[a];\r
596 if (this.currentRunStart < this.beginIndex) this.currentRunStart = this.beginIndex;\r
597 } else {\r
598 this.currentRunStart = this.beginIndex;\r
599 }if (a < this.b$["java.text.AttributedString"].runCount - 1) {\r
600 this.currentRunLimit = this.b$["java.text.AttributedString"].runStarts[a + 1];\r
601 if (this.currentRunLimit > this.endIndex) this.currentRunLimit = this.endIndex;\r
602 } else {\r
603 this.currentRunLimit = this.endIndex;\r
604 }}}});\r
605 c$ = Clazz.p0p ();\r
606 };\r
607 c$.$AttributedString$AttributeMap$ = function () {\r
608 Clazz.pu$h(self.c$);\r
609 c$ = Clazz.decorateAsClass (function () {\r
610 Clazz.prepareCallback (this, arguments);\r
611 this.runIndex = 0;\r
612 this.beginIndex = 0;\r
613 this.endIndex = 0;\r
614 Clazz.instantialize (this, arguments);\r
615 }, java.text.AttributedString, "AttributeMap", java.util.AbstractMap);\r
616 Clazz.makeConstructor (c$, \r
617 function (a, b, c) {\r
618 Clazz.superConstructor (this, java.text.AttributedString.AttributeMap, []);\r
619 this.runIndex = a;\r
620 this.beginIndex = b;\r
621 this.endIndex = c;\r
622 }, "~N,~N,~N");\r
623 Clazz.overrideMethod (c$, "entrySet", \r
624 function () {\r
625 var a =  new java.util.HashSet ();\r
626 {\r
627 var b = this.b$["java.text.AttributedString"].runAttributes[this.runIndex].size ();\r
628 for (var c = 0; c < b; c++) {\r
629 var d = this.b$["java.text.AttributedString"].runAttributes[this.runIndex].get (c);\r
630 var e = this.b$["java.text.AttributedString"].runAttributeValues[this.runIndex].get (c);\r
631 if (Clazz.instanceOf (e, java.text.Annotation)) {\r
632 e = this.b$["java.text.AttributedString"].getAttributeCheckRange (d, this.runIndex, this.beginIndex, this.endIndex);\r
633 if (e == null) {\r
634 continue;\r
635 }}var f =  new java.text.AttributeEntry (d, e);\r
636 a.add (f);\r
637 }\r
638 }return a;\r
639 });\r
640 Clazz.overrideMethod (c$, "get", \r
641 function (a) {\r
642 return this.b$["java.text.AttributedString"].getAttributeCheckRange (a, this.runIndex, this.beginIndex, this.endIndex);\r
643 }, "~O");\r
644 c$ = Clazz.p0p ();\r
645 };\r
646 Clazz.defineStatics (c$,\r
647 "ARRAY_SIZE_INCREMENT", 10);\r
648 c$ = Clazz.decorateAsClass (function () {\r
649 this.key = null;\r
650 this.value = null;\r
651 Clazz.instantialize (this, arguments);\r
652 }, java.text, "AttributeEntry", null, java.util.Map.Entry);\r
653 Clazz.makeConstructor (c$, \r
654 function (key, value) {\r
655 this.key = key;\r
656 this.value = value;\r
657 }, "java.text.AttributedCharacterIterator.Attribute,~O");\r
658 Clazz.overrideMethod (c$, "equals", \r
659 function (o) {\r
660 if (!(Clazz.instanceOf (o, java.text.AttributeEntry))) {\r
661 return false;\r
662 }var other = o;\r
663 return other.key.equals (this.key) && (this.value == null ? other.value == null : other.value.equals (this.value));\r
664 }, "~O");\r
665 Clazz.overrideMethod (c$, "getKey", \r
666 function () {\r
667 return this.key;\r
668 });\r
669 Clazz.overrideMethod (c$, "getValue", \r
670 function () {\r
671 return this.value;\r
672 });\r
673 Clazz.overrideMethod (c$, "setValue", \r
674 function (newValue) {\r
675 throw  new UnsupportedOperationException ();\r
676 }, "~O");\r
677 Clazz.overrideMethod (c$, "hashCode", \r
678 function () {\r
679 return this.key.hashCode () ^ (this.value == null ? 0 : this.value.hashCode ());\r
680 });\r
681 Clazz.defineMethod (c$, "toString", \r
682 function () {\r
683 return this.key.toString () + "=" + this.value.toString ();\r
684 });\r
685 });\r