Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / util / AbstractList.js
1 // BH 8/25/2014 1:10:59 AM  - removed indirect access/inner class business.
2
3 Clazz.load(["java.util.AbstractCollection","$.Iterator","$.List","$.ListIterator","$.RandomAccess","$.NoSuchElementException"],"java.util.AbstractList",["java.lang.IllegalArgumentException","$.IllegalStateException","$.IndexOutOfBoundsException","$.UnsupportedOperationException","java.util.ConcurrentModificationException"],function(){
4 c$=Clazz.decorateAsClass(function(){
5 this.modCount=0;
6
7
8
9 //if(!Clazz.isClassDefined("java.util.AbstractList.SimpleListIterator")){
10 //java.util.AbstractList.$AbstractList$SimpleListIterator$();
11 //}
12 //if(!Clazz.isClassDefined("java.util.AbstractList.FullListIterator")){
13 //java.util.AbstractList.$AbstractList$FullListIterator$();
14 //}
15
16
17
18 Clazz.instantialize(this,arguments);
19 },java.util,"AbstractList",java.util.AbstractCollection,java.util.List);
20 Clazz.defineMethod(c$,"add",
21 function(location,object){
22 throw new UnsupportedOperationException();
23 },"~N,~O");
24 Clazz.defineMethod(c$,"add",
25 function(object){
26 this.add(this.size(),object);
27 return true;
28 },"~O");
29 Clazz.defineMethod(c$,"addAll",
30 function(location,collection){
31 var it=collection.iterator();
32 while(it.hasNext()){
33 this.add(location++,it.next());
34 }
35 return!collection.isEmpty();
36 },"~N,java.util.Collection");
37 Clazz.overrideMethod(c$,"clear",
38 function(){
39 this.removeRange(0,this.size());
40 });
41 Clazz.overrideMethod(c$,"equals",
42 function(object){
43 if(this===object){
44 return true;
45 }if(Clazz.instanceOf(object,java.util.List)){
46 var list=object;
47 if(list.size()!=this.size()){
48 return false;
49 }var it1=this.iterator();
50 var it2=list.iterator();
51 while(it1.hasNext()){
52 var e1=it1.next();
53 var e2=it2.next();
54 if(!(e1==null?e2==null:e1.equals(e2))){
55 return false;
56 }}
57 return true;
58 }return false;
59 },"~O");
60 Clazz.overrideMethod(c$,"hashCode",
61 function(){
62 var result=1;
63 var it=this.iterator();
64 while(it.hasNext()){
65 var object=it.next();
66 result=(31*result)+(object==null?0:object.hashCode());
67 }
68 return result;
69 });
70 Clazz.overrideMethod(c$,"indexOf",
71 function(object){
72 var it=this.listIterator();
73 if(object!=null){
74 while(it.hasNext()){
75 if(object.equals(it.next())){
76 return it.previousIndex();
77 }}
78 }else{
79 while(it.hasNext()){
80 if(it.next()==null){
81 return it.previousIndex();
82 }}
83 }return-1;
84 },"~O");
85 Clazz.overrideMethod(c$,"iterator",
86 function(){
87 return new java.util.AbstractListSimpleListIterator(this); // Clazz.innerTypeInstance(java.util.AbstractList.SimpleListIterator,this,null);
88 });
89 Clazz.overrideMethod(c$,"lastIndexOf",
90 function(object){
91 var it=this.listIterator(this.size());
92 if(object!=null){
93 while(it.hasPrevious()){
94 if(object.equals(it.previous())){
95 return it.nextIndex();
96 }}
97 }else{
98 while(it.hasPrevious()){
99 if(it.previous()==null){
100 return it.nextIndex();
101 }}
102 }return-1;
103 },"~O");
104 //Clazz.defineMethod(c$,"listIterator",
105 //function(){
106 //return this.listIterator(0);
107 //});
108 Clazz.defineMethod(c$,"listIterator",
109 function(location){
110 location || (location = 0);
111 return new java.util.AbstractListFullListIterator(this, location);//Clazz.innerTypeInstance(java.util.AbstractList.FullListIterator,this,null,location);
112 },"~N");
113 Clazz.defineMethod(c$,"remove",
114 function(location){
115 throw new UnsupportedOperationException();
116 },"~N");
117 Clazz.defineMethod(c$,"removeRange",
118 function(start,end){
119 var it=this.listIterator(start);
120 for(var i=start;i<end;i++){
121 it.next();
122 it.remove();
123 }
124 },"~N,~N");
125 Clazz.overrideMethod(c$,"set",
126 function(location,object){
127 throw new UnsupportedOperationException();
128 },"~N,~O");
129 Clazz.overrideMethod(c$,"subList",
130 function(start,end){
131 if(0<=start&&end<=this.size()){
132 if(start<=end){
133 if(Clazz.instanceOf(this,java.util.RandomAccess)){
134 return new java.util.AbstractList.SubAbstractListRandomAccess(this,start,end);
135 }return new java.util.AbstractList.SubAbstractList(this,start,end);
136 }throw new IllegalArgumentException();
137 }throw new IndexOutOfBoundsException();
138 },"~N,~N");
139
140
141
142 //c$.$AbstractList$SimpleListIterator$=function(){
143
144 Clazz.pu$h(self.c$);
145
146 c$=Clazz.decorateAsClass(function(){
147 //Clazz.prepareCallback(this,arguments);
148 this.pos=-1;
149 this.expectedModCount=0;
150 this.lastPosition=-1;
151 Clazz.instantialize(this,arguments);
152 },java.util,"AbstractListSimpleListIterator",null,java.util.Iterator);
153
154
155 Clazz.makeConstructor(c$,
156 function(a){
157 this._list = a;
158 this.expectedModCount=a.modCount;
159 }, "java.util.AbstractList");
160
161 Clazz.overrideMethod(c$,"hasNext",
162 function(){
163 return this.pos+1<this._list.size();
164 });
165 Clazz.overrideMethod(c$,"next",
166 function(){
167 if(this.expectedModCount==this._list.modCount){
168 try{
169 var a=this._list.get(this.pos+1);
170 this.lastPosition=++this.pos;
171 return a;
172 }catch(e){
173 if(Clazz.instanceOf(e,IndexOutOfBoundsException)){
174 throw new java.util.NoSuchElementException();
175 }else{
176 throw e;
177 }
178 }
179 }throw new java.util.ConcurrentModificationException();
180 });
181 Clazz.overrideMethod(c$,"remove",
182 function(){
183 if(this.expectedModCount==this._list.modCount){
184 try{
185 this._list.remove(this.lastPosition);
186 }catch(e){
187 if(Clazz.instanceOf(e,IndexOutOfBoundsException)){
188 throw new IllegalStateException();
189 }else{
190 throw e;
191 }
192 }
193 if(this._list.modCount!=this.expectedModCount){
194 this.expectedModCount++;
195 }if(this.pos==this.lastPosition){
196 this.pos--;
197 }this.lastPosition=-1;
198 }else{
199 throw new java.util.ConcurrentModificationException();
200 }});
201
202 c$=Clazz.p0p();
203 //};
204
205
206 //c$.$AbstractList$FullListIterator$=function(){
207 Clazz.pu$h(self.c$);
208 c$=Clazz.decorateAsClass(function(){
209 //Clazz.prepareCallback(this,arguments);
210 Clazz.instantialize(this,arguments);
211 },java.util,"AbstractListFullListIterator",java.util.AbstractListSimpleListIterator,java.util.ListIterator);
212
213 //,Clazz.innerTypeInstance(java.util.AbstractList.SimpleListIterator,this,null,Clazz.inheritArgs));
214
215 Clazz.makeConstructor(c$,
216 function(a,b){
217 Clazz.superConstructor(this,java.util.AbstractListFullListIterator,[a]);
218 if(0<=b&&b<=this._list.size()){
219 this.pos=b-1;
220 }else{
221 throw new IndexOutOfBoundsException();
222 }},"java.util.AbstractList,~N");
223 Clazz.overrideMethod(c$,"add",
224 function(a){
225 if(this.expectedModCount==this._list.modCount){
226 try{
227 this._list.add(this.pos+1,a);
228 }catch(e){
229 if(Clazz.instanceOf(e,IndexOutOfBoundsException)){
230 throw new java.util.NoSuchElementException();
231 }else{
232 throw e;
233 }
234 }
235 this.pos++;
236 this.lastPosition=-1;
237 if(this._list.modCount!=this.expectedModCount){
238 this.expectedModCount++;
239 }}else{
240 throw new java.util.ConcurrentModificationException();
241 }},"~O");
242 Clazz.overrideMethod(c$,"hasPrevious",
243 function(){
244 return this.pos>=0;
245 });
246 Clazz.overrideMethod(c$,"nextIndex",
247 function(){
248 return this.pos+1;
249 });
250 Clazz.overrideMethod(c$,"previous",
251 function(){
252 if(this.expectedModCount==this._list.modCount){
253 try{
254 var a=this._list.get(this.pos);
255 this.lastPosition=this.pos;
256 this.pos--;
257 return a;
258 }catch(e){
259 if(Clazz.instanceOf(e,IndexOutOfBoundsException)){
260 throw new java.util.NoSuchElementException();
261 }else{
262 throw e;
263 }
264 }
265 }throw new java.util.ConcurrentModificationException();
266 });
267 Clazz.overrideMethod(c$,"previousIndex",
268 function(){
269 return this.pos;
270 });
271 Clazz.overrideMethod(c$,"set",
272 function(a){
273 if(this.expectedModCount==this._list.modCount){
274 try{
275 this._list.set(this.lastPosition,a);
276 }catch(e){
277 if(Clazz.instanceOf(e,IndexOutOfBoundsException)){
278 throw new IllegalStateException();
279 }else{
280 throw e;
281 }
282 }
283 }else{
284 throw new java.util.ConcurrentModificationException();
285 }},"~O");
286 c$=Clazz.p0p();
287 //};
288
289
290
291
292 Clazz.pu$h(self.c$);
293 c$=Clazz.declareType(java.util.AbstractList,"SubAbstractListRandomAccess",java.util.AbstractList.SubAbstractList,java.util.RandomAccess);
294 c$=Clazz.p0p();
295
296
297
298
299 Clazz.pu$h(self.c$);
300 c$=Clazz.decorateAsClass(function(){
301 this.fullList=null;
302 this.offset=0;
303 this.$size=0;
304 Clazz.instantialize(this,arguments);
305 },java.util.AbstractList,"SubAbstractList",java.util.AbstractList);
306 Clazz.makeConstructor(c$,
307 function(a,b,c){
308 Clazz.superConstructor(this,java.util.AbstractList.SubAbstractList);
309 this.fullList=a;
310 this.modCount=this.fullList.modCount;
311 this.offset=b;
312 this.$size=c-b;
313 },"java.util.AbstractList,~N,~N");
314 Clazz.defineMethod(c$,"add",
315 function(a,b){
316 if(this.modCount==this.fullList.modCount){
317 if(0<=a&&a<=this.$size){
318 this.fullList.add(a+this.offset,b);
319 this.$size++;
320 this.modCount=this.fullList.modCount;
321 }else{
322 throw new IndexOutOfBoundsException();
323 }}else{
324 throw new java.util.ConcurrentModificationException();
325 }},"~N,~O");
326 Clazz.defineMethod(c$,"addAll",
327 function(a,b){
328 if(this.modCount==this.fullList.modCount){
329 if(0<=a&&a<=this.$size){
330 var c=this.fullList.addAll(a+this.offset,b);
331 if(c){
332 this.$size+=b.size();
333 this.modCount=this.fullList.modCount;
334 }return c;
335 }throw new IndexOutOfBoundsException();
336 }throw new java.util.ConcurrentModificationException();
337 },"~N,java.util.Collection");
338 Clazz.defineMethod(c$,"addAll",
339 function(a){
340 if(this.modCount==this.fullList.modCount){
341 var b=this.fullList.addAll(this.offset+this.$size,a);
342 if(b){
343 this.$size+=a.size();
344 this.modCount=this.fullList.modCount;
345 }return b;
346 }throw new java.util.ConcurrentModificationException();
347 },"java.util.Collection");
348 Clazz.defineMethod(c$,"get",
349 function(a){
350 if(this.modCount==this.fullList.modCount){
351 if(0<=a&&a<this.$size){
352 return this.fullList.get(a+this.offset);
353 }throw new IndexOutOfBoundsException();
354 }throw new java.util.ConcurrentModificationException();
355 },"~N");
356 Clazz.overrideMethod(c$,"iterator",
357 function(){
358 return this.listIterator(0);
359 });
360 Clazz.defineMethod(c$,"listIterator",
361 function(a){
362 if(this.modCount==this.fullList.modCount){
363 if(0<=a&&a<=this.$size){
364 return new java.util.AbstractList.SubAbstractList.SubAbstractListIterator(this.fullList.listIterator(a+this.offset),this,this.offset,this.$size);
365 }throw new IndexOutOfBoundsException();
366 }throw new java.util.ConcurrentModificationException();
367 },"~N");
368 Clazz.defineMethod(c$,"remove",
369 function(a){
370 if(this.modCount==this.fullList.modCount){
371 if(0<=a&&a<this.$size){
372 var b=this.fullList.remove(a+this.offset);
373 this.$size--;
374 this.modCount=this.fullList.modCount;
375 return b;
376 }throw new IndexOutOfBoundsException();
377 }throw new java.util.ConcurrentModificationException();
378 },"~N");
379 Clazz.defineMethod(c$,"removeRange",
380 function(a,b){
381 if(a!=b){
382 if(this.modCount==this.fullList.modCount){
383 this.fullList.removeRange(a+this.offset,b+this.offset);
384 this.$size-=b-a;
385 this.modCount=this.fullList.modCount;
386 }else{
387 throw new java.util.ConcurrentModificationException();
388 }}},"~N,~N");
389 Clazz.defineMethod(c$,"set",
390 function(a,b){
391 if(this.modCount==this.fullList.modCount){
392 if(0<=a&&a<this.$size){
393 return this.fullList.set(a+this.offset,b);
394 }throw new IndexOutOfBoundsException();
395 }throw new java.util.ConcurrentModificationException();
396 },"~N,~O");
397 Clazz.overrideMethod(c$,"size",
398 function(){
399 return this.$size;
400 });
401 Clazz.defineMethod(c$,"sizeChanged",
402 function(a){
403 if(a){
404 this.$size++;
405 }else{
406 this.$size--;
407 }this.modCount=this.fullList.modCount;
408 },"~B");
409 Clazz.pu$h(self.c$);
410 c$=Clazz.decorateAsClass(function(){
411 this.subList=null;
412 this.iterator=null;
413 this.start=0;
414 this.end=0;
415 Clazz.instantialize(this,arguments);
416 },java.util.AbstractList.SubAbstractList,"SubAbstractListIterator",null,java.util.ListIterator);
417 Clazz.makeConstructor(c$,
418 function(a,b,c,d){
419 this.iterator=a;
420 this.subList=b;
421 this.start=c;
422 this.end=this.start+d;
423 },"java.util.ListIterator,java.util.AbstractList.SubAbstractList,~N,~N");
424 Clazz.defineMethod(c$,"add",
425 function(a){
426 this.iterator.add(a);
427 this.subList.sizeChanged(true);
428 this.end++;
429 },"~O");
430 Clazz.overrideMethod(c$,"hasNext",
431 function(){
432 return this.iterator.nextIndex()<this.end;
433 });
434 Clazz.overrideMethod(c$,"hasPrevious",
435 function(){
436 return this.iterator.previousIndex()>=this.start;
437 });
438 Clazz.defineMethod(c$,"next",
439 function(){
440 if(this.iterator.nextIndex()<this.end){
441 return this.iterator.next();
442 }throw new java.util.NoSuchElementException();
443 });
444 Clazz.defineMethod(c$,"nextIndex",
445 function(){
446 return this.iterator.nextIndex()-this.start;
447 });
448 Clazz.defineMethod(c$,"previous",
449 function(){
450 if(this.iterator.previousIndex()>=this.start){
451 return this.iterator.previous();
452 }throw new java.util.NoSuchElementException();
453 });
454 Clazz.defineMethod(c$,"previousIndex",
455 function(){
456 var a=this.iterator.previousIndex();
457 if(a>=this.start){
458 return a-this.start;
459 }return-1;
460 });
461 Clazz.defineMethod(c$,"remove",
462 function(){
463 this.iterator.remove();
464 this.subList.sizeChanged(false);
465 this.end--;
466 });
467 Clazz.defineMethod(c$,"set",
468 function(a){
469 this.iterator.set(a);
470 },"~O");
471 c$=Clazz.p0p();
472 c$=Clazz.p0p();
473 });