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
6 Clazz.instantialize (this, arguments);
\r
7 }, java.text, "CharacterIteratorFieldDelegate", null, java.text.Format.FieldDelegate);
\r
8 Clazz.makeConstructor (c$,
\r
10 this.attributedStrings = new java.util.ArrayList ();
\r
12 Clazz.defineMethod (c$, "formatted",
\r
13 function (attr, value, start, end, buffer) {
\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
25 }if (this.size < start) {
\r
26 this.attributedStrings.add ( new java.text.AttributedString (buffer.substring (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
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
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
49 return new java.text.AttributedString (iterators).getIterator ();
\r