X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fswingjs%2Fj2s%2Fjava%2Futil%2FVector.js;fp=site%2Fswingjs%2Fj2s%2Fjava%2Futil%2FVector.js;h=ce16ec8987ec4121dca1aa26c690225f076ddad5;hp=e3059d0c67ef294c583b01def8c59a244a3d94d1;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/swingjs/j2s/java/util/Vector.js b/site/swingjs/j2s/java/util/Vector.js index e3059d0..ce16ec8 100644 --- a/site/swingjs/j2s/java/util/Vector.js +++ b/site/swingjs/j2s/java/util/Vector.js @@ -1,427 +1,427 @@ -Clazz.load(["java.util.AbstractList","$.List","$.RandomAccess"],"java.util.Vector",["java.lang.ArrayIndexOutOfBoundsException","$.IllegalArgumentException","$.IndexOutOfBoundsException","$.StringBuffer","java.lang.reflect.Array","java.util.Arrays","$.Collections","$.Enumeration","$.NoSuchElementException"],function(){ -c$=Clazz.decorateAsClass(function(){ -this.elementCount=0; -this.elementData=null; -this.capacityIncrement=0; -Clazz.instantialize(this,arguments); -},java.util,"Vector",java.util.AbstractList,[java.util.List,java.util.RandomAccess,Cloneable,java.io.Serializable]); -Clazz.makeConstructor(c$, -function(){ -this.construct(10,0); -}); -Clazz.makeConstructor(c$, -function(capacity){ -this.construct(capacity,0); -},"~N"); -Clazz.makeConstructor(c$, -function(capacity,capacityIncrement){ -Clazz.superConstructor(this,java.util.Vector,[]); -this.elementCount=0; -try{ -this.elementData=this.newElementArray(capacity); -}catch(e){ -if(Clazz.instanceOf(e,NegativeArraySizeException)){ -throw new IllegalArgumentException(); -}else{ -throw e; -} -} -this.capacityIncrement=capacityIncrement; -},"~N,~N"); -Clazz.makeConstructor(c$, -function(collection){ -this.construct(collection.size(),0); -var it=collection.iterator(); -while(it.hasNext()){ -this.elementData[this.elementCount++]=it.next(); -} -},"java.util.Collection"); -Clazz.defineMethod(c$,"newElementArray", -($fz=function(size){ -return new Array(size); -},$fz.isPrivate=true,$fz),"~N"); -Clazz.defineMethod(c$,"add", -function(location,object){ -this.insertElementAt(object,location); -},"~N,~O"); -Clazz.defineMethod(c$,"add", -function(object){ -this.addElement(object); -return true; -},"~O"); -Clazz.defineMethod(c$,"addAll", -function(location,collection){ -if(0<=location&&location<=this.elementCount){ -var size=collection.size(); -if(size==0){ -return false; -}var required=size-(this.elementData.length-this.elementCount); -if(required>0){ -this.growBy(required); -}var count=this.elementCount-location; -if(count>0){ -System.arraycopy(this.elementData,location,this.elementData,location+size,count); -}var it=collection.iterator(); -while(it.hasNext()){ -this.elementData[location++]=it.next(); -} -this.elementCount+=size; -this.modCount++; -return true; -}throw new ArrayIndexOutOfBoundsException(location); -},"~N,java.util.Collection"); -Clazz.defineMethod(c$,"addAll", -function(collection){ -return this.addAll(this.elementCount,collection); -},"java.util.Collection"); -Clazz.defineMethod(c$,"addElement", -function(object){ -if(this.elementCount==this.elementData.length){ -this.growByOne(); -}this.elementData[this.elementCount++]=object; -this.modCount++; -},"~O"); -Clazz.defineMethod(c$,"capacity", -function(){ -return this.elementData.length; -}); -Clazz.overrideMethod(c$,"clear", -function(){ -this.removeAllElements(); -}); -Clazz.defineMethod(c$,"clone", -function(){ -try{ -var vector=Clazz.superCall(this,java.util.Vector,"clone",[]); -vector.elementData=this.elementData.clone(); -return vector; -}catch(e){ -if(Clazz.instanceOf(e,CloneNotSupportedException)){ -return null; -}else{ -throw e; -} -} -}); -Clazz.overrideMethod(c$,"contains", -function(object){ -return this.indexOf(object,0)!=-1; -},"~O"); -Clazz.defineMethod(c$,"copyInto", -function(elements){ -System.arraycopy(this.elementData,0,elements,0,this.elementCount); -},"~A"); -Clazz.defineMethod(c$,"elementAt", -function(location){ -if(locationnext?minimumCapacity:next); -}},"~N"); -Clazz.overrideMethod(c$,"equals", -function(object){ -if(this===object){ -return true; -}if(Clazz.instanceOf(object,java.util.List)){ -var list=object; -if(list.size()!=this.size()){ -return false; -}var index=0; -var it=list.iterator(); -while(it.hasNext()){ -var e1=this.elementData[index++]; -var e2=it.next(); -if(!(e1==null?e2==null:e1.equals(e2))){ -return false; -}} -return true; -}return false; -},"~O"); -Clazz.defineMethod(c$,"firstElement", -function(){ -if(this.elementCount>0){ -return this.elementData[0]; -}throw new java.util.NoSuchElementException(); -}); -Clazz.overrideMethod(c$,"get", -function(location){ -return this.elementAt(location); -},"~N"); -Clazz.defineMethod(c$,"grow", -($fz=function(newCapacity){ -var newData=this.newElementArray(newCapacity); -System.arraycopy(this.elementData,0,newData,0,this.elementCount); -this.elementData=newData; -},$fz.isPrivate=true,$fz),"~N"); -Clazz.defineMethod(c$,"growByOne", -($fz=function(){ -var adding=0; -if(this.capacityIncrement<=0){ -if((adding=this.elementData.length)==0){ -adding=1; -}}else{ -adding=this.capacityIncrement; -}var newData=this.newElementArray(this.elementData.length+adding); -System.arraycopy(this.elementData,0,newData,0,this.elementCount); -this.elementData=newData; -},$fz.isPrivate=true,$fz)); -Clazz.defineMethod(c$,"growBy", -($fz=function(required){ -var adding=0; -if(this.capacityIncrement<=0){ -if((adding=this.elementData.length)==0){ -adding=required; -}while(adding0){ -System.arraycopy(this.elementData,location,this.elementData,location+1,count); -}this.elementData[location]=object; -this.elementCount++; -this.modCount++; -}else{ -throw new ArrayIndexOutOfBoundsException(location); -}},"~O,~N"); -Clazz.overrideMethod(c$,"isEmpty", -function(){ -return this.elementCount==0; -}); -Clazz.defineMethod(c$,"lastElement", -function(){ -try{ -return this.elementData[this.elementCount-1]; -}catch(e){ -if(Clazz.instanceOf(e,IndexOutOfBoundsException)){ -throw new java.util.NoSuchElementException(); -}else{ -throw e; -} -} -}); -Clazz.defineMethod(c$,"lastIndexOf", -function(object){ -return this.lastIndexOf(object,this.elementCount-1); -},"~O"); -Clazz.defineMethod(c$,"lastIndexOf", -function(object,location){ -if(location=0;i--){ -if(object.equals(this.elementData[i])){ -return i; -}} -}else{ -for(var i=location;i>=0;i--){ -if(this.elementData[i]==null){ -return i; -}} -}return-1; -}throw new ArrayIndexOutOfBoundsException(location); -},"~O,~N"); -Clazz.defineMethod(c$,"remove", -function(location){ -if(location0){ -System.arraycopy(this.elementData,location+1,this.elementData,location,size); -}this.elementData[this.elementCount]=null; -this.modCount++; -return result; -}throw new ArrayIndexOutOfBoundsException(location); -},"~N"); -Clazz.defineMethod(c$,"remove", -function(object){ -return this.removeElement(object); -},"~O"); -Clazz.defineMethod(c$,"removeAllElements", -function(){ -java.util.Arrays.fill(this.elementData,0,this.elementCount,null); -this.modCount++; -this.elementCount=0; -}); -Clazz.defineMethod(c$,"removeElement", -function(object){ -var index; -if((index=this.indexOf(object,0))==-1){ -return false; -}this.removeElementAt(index); -return true; -},"~O"); -Clazz.defineMethod(c$,"removeElementAt", -function(location){ -if(0<=location&&location0){ -System.arraycopy(this.elementData,location+1,this.elementData,location,size); -}this.elementData[this.elementCount]=null; -this.modCount++; -}else{ -throw new ArrayIndexOutOfBoundsException(location); -}},"~N"); -Clazz.overrideMethod(c$,"removeRange", -function(start,end){ -if(start>=0&&start<=end&&end<=this.size()){ -if(start==end){ -return; -}if(end!=this.elementCount){ -System.arraycopy(this.elementData,end,this.elementData,start,this.elementCount-end); -var newCount=this.elementCount-(end-start); -java.util.Arrays.fill(this.elementData,newCount,this.elementCount,null); -this.elementCount=newCount; -}else{ -java.util.Arrays.fill(this.elementData,start,this.elementCount,null); -this.elementCount=start; -}this.modCount++; -}else{ -throw new IndexOutOfBoundsException(); -}},"~N,~N"); -Clazz.overrideMethod(c$,"set", -function(location,object){ -if(locationlength){ -java.util.Arrays.fill(this.elementData,length,this.elementCount,null); -}this.elementCount=length; -this.modCount++; -},"~N"); -Clazz.overrideMethod(c$,"size", -function(){ -return this.elementCount; -}); -Clazz.overrideMethod(c$,"subList", -function(start,end){ -return new java.util.Collections.SynchronizedRandomAccessList(Clazz.superCall(this,java.util.Vector,"subList",[start,end]),this); -},"~N,~N"); -Clazz.defineMethod(c$,"toArray", -function(){ -var result=new Array(this.elementCount); -System.arraycopy(this.elementData,0,result,0,this.elementCount); -return result; -}); -Clazz.defineMethod(c$,"toArray", -function(contents){ -if(this.elementCount>contents.length){ -var ct=contents.getClass().getComponentType(); -contents=java.lang.reflect.Array.newInstance(ct,this.elementCount); -}System.arraycopy(this.elementData,0,contents,0,this.elementCount); -if(this.elementCount0){ +this.growBy(required); +}var count=this.elementCount-location; +if(count>0){ +System.arraycopy(this.elementData,location,this.elementData,location+size,count); +}var it=collection.iterator(); +while(it.hasNext()){ +this.elementData[location++]=it.next(); +} +this.elementCount+=size; +this.modCount++; +return true; +}throw new ArrayIndexOutOfBoundsException(location); +},"~N,java.util.Collection"); +Clazz.defineMethod(c$,"addAll", +function(collection){ +return this.addAll(this.elementCount,collection); +},"java.util.Collection"); +Clazz.defineMethod(c$,"addElement", +function(object){ +if(this.elementCount==this.elementData.length){ +this.growByOne(); +}this.elementData[this.elementCount++]=object; +this.modCount++; +},"~O"); +Clazz.defineMethod(c$,"capacity", +function(){ +return this.elementData.length; +}); +Clazz.overrideMethod(c$,"clear", +function(){ +this.removeAllElements(); +}); +Clazz.defineMethod(c$,"clone", +function(){ +try{ +var vector=Clazz.superCall(this,java.util.Vector,"clone",[]); +vector.elementData=this.elementData.clone(); +return vector; +}catch(e){ +if(Clazz.instanceOf(e,CloneNotSupportedException)){ +return null; +}else{ +throw e; +} +} +}); +Clazz.overrideMethod(c$,"contains", +function(object){ +return this.indexOf(object,0)!=-1; +},"~O"); +Clazz.defineMethod(c$,"copyInto", +function(elements){ +System.arraycopy(this.elementData,0,elements,0,this.elementCount); +},"~A"); +Clazz.defineMethod(c$,"elementAt", +function(location){ +if(locationnext?minimumCapacity:next); +}},"~N"); +Clazz.overrideMethod(c$,"equals", +function(object){ +if(this===object){ +return true; +}if(Clazz.instanceOf(object,java.util.List)){ +var list=object; +if(list.size()!=this.size()){ +return false; +}var index=0; +var it=list.iterator(); +while(it.hasNext()){ +var e1=this.elementData[index++]; +var e2=it.next(); +if(!(e1==null?e2==null:e1.equals(e2))){ +return false; +}} +return true; +}return false; +},"~O"); +Clazz.defineMethod(c$,"firstElement", +function(){ +if(this.elementCount>0){ +return this.elementData[0]; +}throw new java.util.NoSuchElementException(); +}); +Clazz.overrideMethod(c$,"get", +function(location){ +return this.elementAt(location); +},"~N"); +Clazz.defineMethod(c$,"grow", +($fz=function(newCapacity){ +var newData=this.newElementArray(newCapacity); +System.arraycopy(this.elementData,0,newData,0,this.elementCount); +this.elementData=newData; +},$fz.isPrivate=true,$fz),"~N"); +Clazz.defineMethod(c$,"growByOne", +($fz=function(){ +var adding=0; +if(this.capacityIncrement<=0){ +if((adding=this.elementData.length)==0){ +adding=1; +}}else{ +adding=this.capacityIncrement; +}var newData=this.newElementArray(this.elementData.length+adding); +System.arraycopy(this.elementData,0,newData,0,this.elementCount); +this.elementData=newData; +},$fz.isPrivate=true,$fz)); +Clazz.defineMethod(c$,"growBy", +($fz=function(required){ +var adding=0; +if(this.capacityIncrement<=0){ +if((adding=this.elementData.length)==0){ +adding=required; +}while(adding0){ +System.arraycopy(this.elementData,location,this.elementData,location+1,count); +}this.elementData[location]=object; +this.elementCount++; +this.modCount++; +}else{ +throw new ArrayIndexOutOfBoundsException(location); +}},"~O,~N"); +Clazz.overrideMethod(c$,"isEmpty", +function(){ +return this.elementCount==0; +}); +Clazz.defineMethod(c$,"lastElement", +function(){ +try{ +return this.elementData[this.elementCount-1]; +}catch(e){ +if(Clazz.instanceOf(e,IndexOutOfBoundsException)){ +throw new java.util.NoSuchElementException(); +}else{ +throw e; +} +} +}); +Clazz.defineMethod(c$,"lastIndexOf", +function(object){ +return this.lastIndexOf(object,this.elementCount-1); +},"~O"); +Clazz.defineMethod(c$,"lastIndexOf", +function(object,location){ +if(location=0;i--){ +if(object.equals(this.elementData[i])){ +return i; +}} +}else{ +for(var i=location;i>=0;i--){ +if(this.elementData[i]==null){ +return i; +}} +}return-1; +}throw new ArrayIndexOutOfBoundsException(location); +},"~O,~N"); +Clazz.defineMethod(c$,"remove", +function(location){ +if(location0){ +System.arraycopy(this.elementData,location+1,this.elementData,location,size); +}this.elementData[this.elementCount]=null; +this.modCount++; +return result; +}throw new ArrayIndexOutOfBoundsException(location); +},"~N"); +Clazz.defineMethod(c$,"remove", +function(object){ +return this.removeElement(object); +},"~O"); +Clazz.defineMethod(c$,"removeAllElements", +function(){ +java.util.Arrays.fill(this.elementData,0,this.elementCount,null); +this.modCount++; +this.elementCount=0; +}); +Clazz.defineMethod(c$,"removeElement", +function(object){ +var index; +if((index=this.indexOf(object,0))==-1){ +return false; +}this.removeElementAt(index); +return true; +},"~O"); +Clazz.defineMethod(c$,"removeElementAt", +function(location){ +if(0<=location&&location0){ +System.arraycopy(this.elementData,location+1,this.elementData,location,size); +}this.elementData[this.elementCount]=null; +this.modCount++; +}else{ +throw new ArrayIndexOutOfBoundsException(location); +}},"~N"); +Clazz.overrideMethod(c$,"removeRange", +function(start,end){ +if(start>=0&&start<=end&&end<=this.size()){ +if(start==end){ +return; +}if(end!=this.elementCount){ +System.arraycopy(this.elementData,end,this.elementData,start,this.elementCount-end); +var newCount=this.elementCount-(end-start); +java.util.Arrays.fill(this.elementData,newCount,this.elementCount,null); +this.elementCount=newCount; +}else{ +java.util.Arrays.fill(this.elementData,start,this.elementCount,null); +this.elementCount=start; +}this.modCount++; +}else{ +throw new IndexOutOfBoundsException(); +}},"~N,~N"); +Clazz.overrideMethod(c$,"set", +function(location,object){ +if(locationlength){ +java.util.Arrays.fill(this.elementData,length,this.elementCount,null); +}this.elementCount=length; +this.modCount++; +},"~N"); +Clazz.overrideMethod(c$,"size", +function(){ +return this.elementCount; +}); +Clazz.overrideMethod(c$,"subList", +function(start,end){ +return new java.util.Collections.SynchronizedRandomAccessList(Clazz.superCall(this,java.util.Vector,"subList",[start,end]),this); +},"~N,~N"); +Clazz.defineMethod(c$,"toArray", +function(){ +var result=new Array(this.elementCount); +System.arraycopy(this.elementData,0,result,0,this.elementCount); +return result; +}); +Clazz.defineMethod(c$,"toArray", +function(contents){ +if(this.elementCount>contents.length){ +var ct=contents.getClass().getComponentType(); +contents=java.lang.reflect.Array.newInstance(ct,this.elementCount); +}System.arraycopy(this.elementData,0,contents,0,this.elementCount); +if(this.elementCount