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