org.geotools.data.memory
Class MemoryFeatureCollection

Object
  extended by AbstractFeatureCollection
      extended by MemoryFeatureCollection
All Implemented Interfaces:
Iterable<SimpleFeature>, Collection<SimpleFeature>, SimpleFeatureCollection, RandomFeatureAccess, FeatureCollection<SimpleFeatureType,SimpleFeature>

public class MemoryFeatureCollection
extends AbstractFeatureCollection
implements RandomFeatureAccess, Collection<SimpleFeature>

Implement a SimpleFeatureCollection by burning memory!

Contents are maintained in a sorted TreeMap by FID, this serves as a reference implementation when exploring the SimpleFeatureCollection api.

This is similar to DefaultFeatureCollection, although additional methods are supported and test cases have been written. Unlike DefaultFeatureCollection the type information must be known at construction time.

Author:
Jody Garnett, Refractions Research

Field Summary
 
Fields inherited from class AbstractFeatureCollection
id, schema
 
Constructor Summary
MemoryFeatureCollection(SimpleFeatureType schema)
           
 
Method Summary
 boolean add(SimpleFeature o)
           
 boolean addAll(Collection<? extends SimpleFeature> c)
           
 void clear()
           
 ReferencedEnvelope getBounds()
          Calculates the bounds of the features without caching.
 SimpleFeature getFeatureMember(String id)
          Access Feature content by feature id.
 MemoryFeatureCollection.MemoryIterator openIterator()
          Factory method used to open an iterator over collection contents for use by AbstractFeatureCollection.iterator() and AbstractFeatureCollection.features().
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 SimpleFeature removeFeatureMember(String id)
          Optional Method
 boolean retainAll(Collection<?> c)
           
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class AbstractFeatureCollection
accepts, contains, containsAll, features, getID, getSchema, isEmpty, iterator, sort, subCollection, toArray, toArray
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface SimpleFeatureCollection
features, sort, subCollection
 
Methods inherited from interface FeatureCollection
accepts, contains, containsAll, getID, getSchema, isEmpty, toArray, toArray
 
Methods inherited from interface Collection
contains, containsAll, equals, hashCode, isEmpty, iterator, toArray, toArray
 

Constructor Detail

MemoryFeatureCollection

public MemoryFeatureCollection(SimpleFeatureType schema)
Method Detail

add

public boolean add(SimpleFeature o)
Specified by:
add in interface Collection<SimpleFeature>

size

public int size()
Description copied from class: AbstractFeatureCollection
Returns the number of elements in this collection.

Specified by:
size in interface Collection<SimpleFeature>
Specified by:
size in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Specified by:
size in class AbstractFeatureCollection
Returns:
Number of items, or Interger.MAX_VALUE
See Also:
Collection.size()

openIterator

public MemoryFeatureCollection.MemoryIterator openIterator()
Description copied from class: AbstractFeatureCollection
Factory method used to open an iterator over collection contents for use by AbstractFeatureCollection.iterator() and AbstractFeatureCollection.features().

If you return an instance of FeatureIterator some effort is taken to call the FeatureIterator.close() internally, however we cannot offer any assurance that client code using AbstractFeatureCollection.iterator() will perform the same check.

Specified by:
openIterator in class AbstractFeatureCollection
Returns:
Iterator over collection contents

getFeatureMember

public SimpleFeature getFeatureMember(String id)
                               throws NoSuchElementException
Description copied from interface: RandomFeatureAccess
Access Feature content by feature id.

Specified by:
getFeatureMember in interface RandomFeatureAccess
Returns:
Feature with the indicated or id
Throws:
NoSuchElementException - if a Feature with the indicated id is not present

removeFeatureMember

public SimpleFeature removeFeatureMember(String id)
Description copied from interface: RandomFeatureAccess
Optional Method

Specified by:
removeFeatureMember in interface RandomFeatureAccess

getBounds

public ReferencedEnvelope getBounds()
Calculates the bounds of the features without caching.

Specified by:
getBounds in interface FeatureCollection<SimpleFeatureType,SimpleFeature>
Specified by:
getBounds in class AbstractFeatureCollection
Returns:
An Envelope containing the total bounds of this collection.

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<SimpleFeature>

addAll

public boolean addAll(Collection<? extends SimpleFeature> c)
Specified by:
addAll in interface Collection<SimpleFeature>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<SimpleFeature>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<SimpleFeature>

clear

public void clear()
Specified by:
clear in interface Collection<SimpleFeature>


Copyright © 1996-2014 Geotools. All Rights Reserved.