org.geotools.data.store
Class ReTypingFeatureCollection

Object
  extended by DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
      extended by ReTypingFeatureCollection
All Implemented Interfaces:
FeatureCollection<SimpleFeatureType,SimpleFeature>

public class ReTypingFeatureCollection
extends DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>

FeatureCollection decorator which decorates a feature collection "re-typing" its schema based on attributes specified in a query.

Author:
Justin Deoliveira, The Open Planning Project

Field Summary
 
Fields inherited from class DecoratingFeatureCollection
delegate
 
Constructor Summary
ReTypingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate, SimpleFeatureType featureType)
           
 
Method Summary
 void close(FeatureIterator<SimpleFeature> close)
          Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.
 void close(Iterator close)
          Clean up after any resources associated with this itterator in a manner similar to JDO collections.
 FeatureIterator<SimpleFeature> features()
          Obtain a FeatureIterator of the Features within this collection.
 SimpleFeatureType getSchema()
          The schema for the child features of this collection.
 Iterator<SimpleFeature> iterator()
          An iterator over this collection, which must be closed after use.
 FeatureReader<SimpleFeatureType,SimpleFeature> reader()
           
 
Methods inherited from class DecoratingFeatureCollection
accepts, accepts, add, addAll, addAll, addListener, clear, contains, containsAll, equals, getBounds, getID, hashCode, isEmpty, purge, remove, removeAll, removeListener, retainAll, size, sort, subCollection, toArray, toArray
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReTypingFeatureCollection

public ReTypingFeatureCollection(FeatureCollection<SimpleFeatureType,SimpleFeature> delegate,
                                 SimpleFeatureType featureType)
Method Detail

getSchema

public SimpleFeatureType getSchema()
Description copied from interface: FeatureCollection
The schema for the child features of this collection.

There is a difference between getFeatureType() and getSchema()represents the LCD FeatureType that best represents the contents of this collection.

The method getSchema() is named for compatability with the geotools 2.0 API. In the Geotools 2.2 time frame we should be able to replace this method with a careful check of getFeatureType() and its attributes.

Specified by:
getSchema in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
getSchema in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
FeatureType describing the "common" schema to all child features of this collection

reader

public FeatureReader<SimpleFeatureType,SimpleFeature> reader()
                                                      throws IOException
Throws:
IOException

features

public FeatureIterator<SimpleFeature> features()
Description copied from interface: FeatureCollection
Obtain a FeatureIterator of the Features within this collection.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

This is almost equivalent to:

  • a Type-Safe call to: getAttribute(getFeatureType().getAttributeType(0).getName()).iterator();.
  • A Java 5:Iterator<Feature>

Example (safe) use:

 FeatureIterator iterator=collection.features();
 try {
     while( iterator.hasNext()  ){
          Feature feature = iterator.next();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

GML Note: The contents of this iterator are considered to be defined by featureMember tags (and/or the single allowed FeatureMembers tag). Please see getFeatureType for more details.

Specified by:
features in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
features in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
A FeatureIterator.

close

public void close(FeatureIterator<SimpleFeature> close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this FeatureIterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
close in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>

iterator

public Iterator<SimpleFeature> iterator()
Description copied from interface: FeatureCollection
An iterator over this collection, which must be closed after use.

Collection is not guaranteed to be ordered in any manner.

The implementation of Collection must adhere to the rules of fail-fast concurrent modification. In addition (to allow for resource backed collections, the close( Iterator ) method must be called.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     while( iterator.hasNext();){
          Feature feature = (Feature) iterator.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
iterator in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
iterator in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>
Returns:
Iterator

close

public void close(Iterator close)
Description copied from interface: FeatureCollection
Clean up after any resources associated with this itterator in a manner similar to JDO collections.

Example (safe) use:

 Iterator iterator = collection.iterator();
 try {
     for( Iterator i=collection.iterator(); i.hasNext();){
          Feature feature = (Feature) i.hasNext();
          System.out.println( feature.getID() );
     }
 }
 finally {
     collection.close( iterator );
 }
 

Specified by:
close in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Overrides:
close in class DecoratingFeatureCollection<SimpleFeatureType,SimpleFeature>


Copyright © 1996-2009 Geotools. All Rights Reserved.