org.geotools.data.store
Class EventContentFeatureWriter

Object
  extended by EventContentFeatureWriter
All Implemented Interfaces:
Closeable, FeatureWriter<SimpleFeatureType,SimpleFeature>

public class EventContentFeatureWriter
extends Object
implements FeatureWriter<SimpleFeatureType,SimpleFeature>

FeatureWriter wrapper that issues events modifications as required.

It is the responsibility of a FeatureStore to issue events to interested parties as content is modified. The ContentState keeps track of the listeners, while EventContentFeatureWriter is willing to fire the events as needed.

Event generation happens in two passes:

The only trick is the comment() event contains our only indication of the final FeatureIDs generated for new features. The BatchFeatureEvent maintains a map of BEFORE/AFTER values allowing any interested party to update their seleciton.

Please note that if you are using DiffFeatureWriter it sends out events on its own.

Author:
Jody Garnett (LISASoft)

Constructor Summary
EventContentFeatureWriter(ContentFeatureStore store, FeatureWriter<SimpleFeatureType,SimpleFeature> writer)
          EventContentFeatureWriter construction.
 
Method Summary
 void close()
          Clean up resources associated with this writer.
 SimpleFeatureType getFeatureType()
          Supplys FeatureTypeFrom reader
 boolean hasNext()
          Query for more content.
 SimpleFeature next()
          Next Feature from reader or new content.
 void remove()
          Removes current Feature, must be called before hasNext.
 void write()
          Writes out the current feature.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventContentFeatureWriter

public EventContentFeatureWriter(ContentFeatureStore store,
                                 FeatureWriter<SimpleFeatureType,SimpleFeature> writer)
EventContentFeatureWriter construction.

Parameters:
reader -
diff -
filter -
Method Detail

getFeatureType

public SimpleFeatureType getFeatureType()
Supplys FeatureTypeFrom reader

Specified by:
getFeatureType in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Returns:
FeatureType this writer has been configured to create.
See Also:
FeatureWriter.getFeatureType()

next

public SimpleFeature next()
                   throws IOException
Next Feature from reader or new content.

Specified by:
next in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Returns:
Feature from Query, or newly appended Feature
Throws:
IOException - DOCUMENT ME!
See Also:
FeatureWriter.next()

remove

public void remove()
            throws IOException
Description copied from interface: FeatureWriter
Removes current Feature, must be called before hasNext.

FeatureWriters will need to allow all FeatureSources of the same typeName to issue a FeatureEvent event of type FeatureEvent.FEATURES_REMOVED when this method is called.

If this FeatureWriter is opperating against a Transaction FEATURES_REMOVED events should only be sent to FeatureSources operating on the same Transaction. When Transaction commit() is called other FeatureSources will be informed of the modifications.

When the current Feature has been provided as new content, this method "cancels" the add opperation (and notification needed).

Specified by:
remove in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Throws:
IOException - DOCUMENT ME!
See Also:
FeatureWriter.remove()

write

public void write()
           throws IOException
Writes out the current feature.

Specified by:
write in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Throws:
IOException
See Also:
FeatureWriter.write()

hasNext

public boolean hasNext()
                throws IOException
Query for more content.

Specified by:
hasNext in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Returns:
true if an additional Feature is available.
Throws:
IOException - DOCUMENT ME!
See Also:
FeatureWriter.hasNext()

close

public void close()
           throws IOException
Clean up resources associated with this writer.

Diff is not clear()ed as it is assumed that it belongs to a Transaction.State object and may yet be written out.

Specified by:
close in interface Closeable
Specified by:
close in interface FeatureWriter<SimpleFeatureType,SimpleFeature>
Throws:
IOException - if there there are problems releasing underlying resources, or possibly if close has been called (up to the implementation).
See Also:
FeatureWriter.close()


Copyright © 1996-2014 Geotools. All Rights Reserved.