package com.xagasoft.gats; import java.io.InputStream; import java.io.OutputStream; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; /** * Represents an ordered list of Gats objects. The order of the objects in the * list is always preserved, unlike the values in a * com.xagasoft.gats.GatsDictionary. This class implements all java List * interface features, and is implemented internally as a LinkedList. */ public class GatsList extends GatsObject implements List { private LinkedList lValue = new LinkedList(); public GatsList() { } public GatsList( Collection c ) { lValue = new LinkedList( c ); } public int getType() { return GatsObject.LIST; } void read( InputStream is, char cType ) throws java.io.IOException { for(;;) { GatsObject obj = GatsObject.read( is ); if( obj == null ) break; add( obj ); } } void write( OutputStream os ) throws java.io.IOException { os.write( (int)'l' ); for( GatsObject obj : this ) { obj.write( os ); } os.write( (int)'e' ); } public String toString() { return lValue.toString(); } public boolean add( GatsObject value ) { return lValue.add( value ); } public void add( int iPos, GatsObject value ) { lValue.add( iPos, value ); } public boolean addAll( Collection src ) { return lValue.addAll( src ); } public boolean addAll( int iPos, Collection src ) { return lValue.addAll( iPos, src ); } public void clear() { lValue.clear(); } public boolean contains( Object value ) { return lValue.contains( value ); } public boolean containsAll( Collection src ) { return lValue.containsAll( src ); } public GatsObject get( int iPos ) { return lValue.get( iPos ); } public int indexOf( Object value ) { return lValue.indexOf( value ); } public boolean isEmpty() { return lValue.isEmpty(); } public Iterator iterator() { return lValue.iterator(); } public int lastIndexOf( Object value ) { return lValue.lastIndexOf( value ); } public ListIterator listIterator() { return lValue.listIterator(); } public ListIterator listIterator( int iPos ) { return lValue.listIterator( iPos ); } public GatsObject remove( int iPos ) { return lValue.remove( iPos ); } public boolean remove( Object value ) { return lValue.remove( value ); } public boolean removeAll( Collection src ) { return lValue.removeAll( src ); } public boolean retainAll( Collection src ) { return lValue.retainAll( src ); } public GatsObject set( int iPos, GatsObject src ) { return lValue.set( iPos, src ); } public int size() { return lValue.size(); } public List subList( int iBegin, int iEnd ) { return new GatsList( lValue.subList( iBegin, iEnd ) ); } public Object[] toArray() { return lValue.toArray(); } public T[] toArray( T[] src ) { return lValue.toArray( src ); } };