86a34c96c04c6c828a8185032124d64844de953a
[jalviewjs.git] / site / swingjs / j2s / java / text / CharacterIteratorFieldDelegate.js
1 Clazz.declarePackage ("java.text");\r
2 Clazz.load (["java.text.Format"], "java.text.CharacterIteratorFieldDelegate", ["java.util.ArrayList", "java.text.AttributedString"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.attributedStrings = null;\r
5 this.size = 0;\r
6 Clazz.instantialize (this, arguments);\r
7 }, java.text, "CharacterIteratorFieldDelegate", null, java.text.Format.FieldDelegate);\r
8 Clazz.makeConstructor (c$, \r
9 function () {\r
10 this.attributedStrings =  new java.util.ArrayList ();\r
11 });\r
12 Clazz.defineMethod (c$, "formatted", \r
13 function (attr, value, start, end, buffer) {\r
14 if (start != end) {\r
15 if (start < this.size) {\r
16 var index = this.size;\r
17 var asIndex = this.attributedStrings.size () - 1;\r
18 while (start < index) {\r
19 var as = this.attributedStrings.get (asIndex--);\r
20 var newIndex = index - as.length ();\r
21 var aStart = Math.max (0, start - newIndex);\r
22 as.addAttribute (attr, value, aStart, Math.min (end - start, as.length () - aStart) + aStart);\r
23 index = newIndex;\r
24 }\r
25 }if (this.size < start) {\r
26 this.attributedStrings.add ( new java.text.AttributedString (buffer.substring (this.size, start)));\r
27 this.size = start;\r
28 }if (this.size < end) {\r
29 var aStart = Math.max (start, this.size);\r
30 var string =  new java.text.AttributedString (buffer.substring (aStart, end));\r
31 string.addAttribute (attr, value);\r
32 this.attributedStrings.add (string);\r
33 this.size = end;\r
34 }}}, "java.text.Format.Field,~O,~N,~N,StringBuffer");\r
35 Clazz.defineMethod (c$, "formatted", \r
36 function (fieldID, attr, value, start, end, buffer) {\r
37 this.formatted (attr, value, start, end, buffer);\r
38 }, "~N,java.text.Format.Field,~O,~N,~N,StringBuffer");\r
39 Clazz.defineMethod (c$, "getIterator", \r
40 function (string) {\r
41 if (string.length > this.size) {\r
42 this.attributedStrings.add ( new java.text.AttributedString (string.substring (this.size)));\r
43 this.size = string.length;\r
44 }var iCount = this.attributedStrings.size ();\r
45 var iterators =  new Array (iCount);\r
46 for (var counter = 0; counter < iCount; counter++) {\r
47 iterators[counter] = (this.attributedStrings.get (counter)).getIterator ();\r
48 }\r
49 return  new java.text.AttributedString (iterators).getIterator ();\r
50 }, "~S");\r
51 });\r