function ArrayList()
{this.array=new Array();this.add=function(obj)
{this.array[this.array.length]=obj;}
this.toJson=function()
{return this.array.toJSON();}
this.getTextList=function()
{var retVal='';for(var i=0;i<this.array.length;++i)
{if(i==0)
retVal+=this.array[i];else
retVal+=(','+this.array[i]);}
return retVal;}
this.remove=function(index)
{if(index>=this.array.length||index<0)
throw"Index is out of scope";if(index==0)
{this.array.reverse();this.array.pop();this.array.reverse();}
else
{var idx=0;var temp_array=new ArrayList();for(idx=0;idx<index;++idx)
{temp_array.add(this.array[idx]);}
for(idx=index+1;idx<this.array.length;++idx)
{temp_array.add(this.array[idx]);}
this.replaceAll(temp_array);}}
this.isElement=function(obj)
{var retVal=false;var i=0;for(i=0;i<this.array.length;++i)
{if(this.get(i)==obj)
{retVal=true;break;}}
return retVal;}
this.removeElement=function(obj)
{for(var i=0;i<this.array.length;++i)
{if(this.array[i]==obj)
{this.remove(i);break;}}}
this.getIndex=function(obj)
{var retVal=-1;for(var i=0;i<this.array.length;++i)
{if(this.array[i]==obj)
{retVal=i;break;}}
return retVal;}
this.iterator=function()
{return new Iterator(this)}
this.listLength=function()
{return this.array.length;}
this.get=function(index)
{return this.array[index];}
this.set=function(index,obj)
{this.array[index]=obj;}
this.addAll=function(obj)
{var offsetIndex=(this.listLength());if(obj instanceof Array)
{for(var i=offsetIndex;i<offsetIndex+obj.length;++i)
{this.add(obj[i]);}}
else if(obj instanceof ArrayList)
{for(var i=offsetIndex;i<offsetIndex+obj.listLength();++i)
{this.add(obj.get(i));}}}
this.replaceAll=function(obj)
{this.removeAll();if(obj instanceof Array)
{for(var i=0;i<obj.length;++i)
{this.add(obj[i]);}}
else if(obj instanceof ArrayList)
{for(var i=0;i<obj.listLength();++i)
{this.add(obj.get(i));}}}
this.removeAll=function()
{this.array=new Array();}}
function Iterator(arrayList)
{this.arrayList=arrayList;this.index=0;this.hasNext=function()
{return this.index<this.arrayList.listLength();}
this.next=function()
{return this.arrayList.get(this.index++);}
this.currentIndex=function()
{return this.index;}}
