JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / javax / swing / text / Segment.js
1 Clazz.declarePackage ("javax.swing.text");\r
2 Clazz.load (["java.text.CharacterIterator"], "javax.swing.text.Segment", ["java.lang.IllegalArgumentException", "$.StringIndexOutOfBoundsException"], function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.array = null;\r
5 this.offset = 0;\r
6 this.count = 0;\r
7 this.partialReturn = false;\r
8 this.pos = 0;\r
9 Clazz.instantialize (this, arguments);\r
10 }, javax.swing.text, "Segment", null, [Cloneable, java.text.CharacterIterator, CharSequence]);\r
11 Clazz.makeConstructor (c$, \r
12 function () {\r
13 this.construct (null, 0, 0);\r
14 });\r
15 Clazz.makeConstructor (c$, \r
16 function (array, offset, count) {\r
17 this.array = array;\r
18 this.offset = offset;\r
19 this.count = count;\r
20 this.partialReturn = false;\r
21 }, "~A,~N,~N");\r
22 Clazz.defineMethod (c$, "setPartialReturn", \r
23 function (p) {\r
24 this.partialReturn = p;\r
25 }, "~B");\r
26 Clazz.defineMethod (c$, "isPartialReturn", \r
27 function () {\r
28 return this.partialReturn;\r
29 });\r
30 Clazz.overrideMethod (c$, "toString", \r
31 function () {\r
32 if (this.array != null) {\r
33 return  String.instantialize (this.array, this.offset, this.count);\r
34 }return  String.instantialize ();\r
35 });\r
36 Clazz.overrideMethod (c$, "first", \r
37 function () {\r
38 this.pos = this.offset;\r
39 if (this.count != 0) {\r
40 return this.array[this.pos];\r
41 }return '\uffff';\r
42 });\r
43 Clazz.overrideMethod (c$, "last", \r
44 function () {\r
45 this.pos = this.offset + this.count;\r
46 if (this.count != 0) {\r
47 this.pos -= 1;\r
48 return this.array[this.pos];\r
49 }return '\uffff';\r
50 });\r
51 Clazz.overrideMethod (c$, "current", \r
52 function () {\r
53 if (this.count != 0 && this.pos < this.offset + this.count) {\r
54 return this.array[this.pos];\r
55 }return '\uffff';\r
56 });\r
57 Clazz.overrideMethod (c$, "next", \r
58 function () {\r
59 this.pos += 1;\r
60 var end = this.offset + this.count;\r
61 if (this.pos >= end) {\r
62 this.pos = end;\r
63 return '\uffff';\r
64 }return this.current ();\r
65 });\r
66 Clazz.overrideMethod (c$, "previous", \r
67 function () {\r
68 if (this.pos == this.offset) {\r
69 return '\uffff';\r
70 }this.pos -= 1;\r
71 return this.current ();\r
72 });\r
73 Clazz.overrideMethod (c$, "setIndex", \r
74 function (position) {\r
75 var end = this.offset + this.count;\r
76 if ((position < this.offset) || (position > end)) {\r
77 throw  new IllegalArgumentException ("bad position: " + position);\r
78 }this.pos = position;\r
79 if ((this.pos != end) && (this.count != 0)) {\r
80 return this.array[this.pos];\r
81 }return '\uffff';\r
82 }, "~N");\r
83 Clazz.overrideMethod (c$, "getBeginIndex", \r
84 function () {\r
85 return this.offset;\r
86 });\r
87 Clazz.overrideMethod (c$, "getEndIndex", \r
88 function () {\r
89 return this.offset + this.count;\r
90 });\r
91 Clazz.overrideMethod (c$, "getIndex", \r
92 function () {\r
93 return this.pos;\r
94 });\r
95 Clazz.overrideMethod (c$, "charAt", \r
96 function (index) {\r
97 if (index < 0 || index >= this.count) {\r
98 throw  new StringIndexOutOfBoundsException (index);\r
99 }return this.array[this.offset + index];\r
100 }, "~N");\r
101 Clazz.overrideMethod (c$, "length", \r
102 function () {\r
103 return this.count;\r
104 });\r
105 Clazz.overrideMethod (c$, "subSequence", \r
106 function (start, end) {\r
107 if (start < 0) {\r
108 throw  new StringIndexOutOfBoundsException (start);\r
109 }if (end > this.count) {\r
110 throw  new StringIndexOutOfBoundsException (end);\r
111 }if (start > end) {\r
112 throw  new StringIndexOutOfBoundsException (end - start);\r
113 }var segment =  new javax.swing.text.Segment ();\r
114 segment.array = this.array;\r
115 segment.offset = this.offset + start;\r
116 segment.count = end - start;\r
117 return segment;\r
118 }, "~N,~N");\r
119 Clazz.overrideMethod (c$, "clone", \r
120 function () {\r
121 var o;\r
122 try {\r
123 o = Clazz.superCall (this, javax.swing.text.Segment, "clone", []);\r
124 } catch (cnse) {\r
125 if (Clazz.exceptionOf (cnse, CloneNotSupportedException)) {\r
126 o = null;\r
127 } else {\r
128 throw cnse;\r
129 }\r
130 }\r
131 return o;\r
132 });\r
133 });\r