org.geotools.feature.collection
Class SubFeatureCollection

java.lang.Object
  extended by AbstractResourceCollection
      extended by org.geotools.feature.collection.SubFeatureCollection

public class SubFeatureCollection
extends AbstractResourceCollection

Xulu:
Code taken from gt-2.4.2 to optimize the size() method! The original variant always iterates ALL features at every call!.


Used as a reasonable default implementation for subCollection.

Note: to implementors, this is not optimal, please do your own thing - your users will thank you.

Author:
Jody Garnett, Refractions Research, Inc.

Field Summary
protected  FeatureCollection collection
          Origional Collection
protected  FilterFactory ff
           
protected  Filter filter
          Filter
protected  FeatureState state
           
 
Constructor Summary
SubFeatureCollection(FeatureCollection collection)
           
SubFeatureCollection(FeatureCollection collection, Filter subfilter)
           
 
Method Summary
 void accepts(FeatureVisitor visitor, ProgressListener progress)
          Accepts a visitor, which then visits each feature in the collection.
 void addListener(CollectionListener listener)
           
 void close(FeatureIterator close)
           
 void closeIterator(Iterator iterator)
           
 FeatureCollection collection()
           
protected  Filter createFilter()
          Override to implement subsetting
 FeatureIterator features()
           
protected  Filter filter()
           
 Object getAttribute(int index)
           
 Object getAttribute(String xPath)
           
 Object[] getAttributes(Object[] attributes)
           
 ReferencedEnvelope getBounds()
           
 int getCount()
           
 Geometry getDefaultGeometry()
           
 FeatureType getFeatureType()
           
 String getID()
           
 int getNumberOfAttributes()
           
 FeatureCollection getParent()
           
 FeatureType getSchema()
           
 boolean isEmpty()
           
 Iterator openIterator()
           
 void purge()
           
 FeatureReader reader()
           
 void removeListener(CollectionListener listener)
           
 void setAttribute(int position, Object val)
           
 void setAttribute(String xPath, Object attribute)
           
 void setDefaultGeometry(Geometry g)
           
 void setParent(FeatureCollection collection)
           
 int size()
           
 FeatureList sort(SortBy order)
           
 FeatureCollection subCollection(Filter filter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected Filter filter
Filter


collection

protected FeatureCollection collection
Origional Collection


state

protected FeatureState state

ff

protected FilterFactory ff
Constructor Detail

SubFeatureCollection

public SubFeatureCollection(FeatureCollection collection)

SubFeatureCollection

public SubFeatureCollection(FeatureCollection collection,
                            Filter subfilter)
Method Detail

filter

protected Filter filter()

createFilter

protected Filter createFilter()
Override to implement subsetting


getFeatureType

public FeatureType getFeatureType()

features

public FeatureIterator features()

closeIterator

public void closeIterator(Iterator iterator)

close

public void close(FeatureIterator close)

getID

public String getID()

getBounds

public ReferencedEnvelope getBounds()

getDefaultGeometry

public Geometry getDefaultGeometry()

setDefaultGeometry

public void setDefaultGeometry(Geometry g)
                        throws IllegalAttributeException
Throws:
IllegalAttributeException

addListener

public void addListener(CollectionListener listener)
                 throws NullPointerException
Throws:
NullPointerException

removeListener

public void removeListener(CollectionListener listener)
                    throws NullPointerException
Throws:
NullPointerException

getParent

public FeatureCollection getParent()

setParent

public void setParent(FeatureCollection collection)

getAttributes

public Object[] getAttributes(Object[] attributes)

getAttribute

public Object getAttribute(String xPath)

getAttribute

public Object getAttribute(int index)

setAttribute

public void setAttribute(int position,
                         Object val)
                  throws IllegalAttributeException,
                         ArrayIndexOutOfBoundsException
Throws:
IllegalAttributeException
ArrayIndexOutOfBoundsException

getNumberOfAttributes

public int getNumberOfAttributes()

setAttribute

public void setAttribute(String xPath,
                         Object attribute)
                  throws IllegalAttributeException
Throws:
IllegalAttributeException

subCollection

public FeatureCollection subCollection(Filter filter)

size

public int size()

isEmpty

public boolean isEmpty()

openIterator

public Iterator openIterator()

getSchema

public FeatureType getSchema()

accepts

public void accepts(FeatureVisitor visitor,
                    ProgressListener progress)
             throws IOException
Accepts a visitor, which then visits each feature in the collection.

Throws:
IOException

reader

public FeatureReader reader()
                     throws IOException
Throws:
IOException

getCount

public int getCount()
             throws IOException
Throws:
IOException

collection

public FeatureCollection collection()
                             throws IOException
Throws:
IOException

sort

public FeatureList sort(SortBy order)

purge

public void purge()