[Schmitzm-commits] r457 - branches/1.0-gt2-2.6/src/schmitzm/geotools/feature
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Oct 11 23:52:48 CEST 2009
Author: alfonx
Date: 2009-10-11 23:52:47 +0200 (Sun, 11 Oct 2009)
New Revision: 457
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureCollectionReader.java
Log:
* Closing the featureIterator
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureCollectionReader.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureCollectionReader.java 2009-10-11 21:43:40 UTC (rev 456)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureCollectionReader.java 2009-10-11 21:52:47 UTC (rev 457)
@@ -42,70 +42,81 @@
* Diese Klasse implementiert einen {@link FeatureReader} ueber den
* {@link FeatureIterator} einer {@link FeatureCollection}.<br>
* <b>Beachte:</b><br>
- * Die <code>FeatureCollection</code> muss mindestens ein Element enthalten! Ansonsten
- * kann der {@link SimpleFeatureType} nicht ermittelt werden!
- * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a> (University of Bonn/Germany)
+ * Die <code>FeatureCollection</code> muss mindestens ein Element enthalten!
+ * Ansonsten kann der {@link SimpleFeatureType} nicht ermittelt werden!
+ *
+ * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+ * (University of Bonn/Germany)
* @version 1.0
*/
-public class FeatureCollectionReader implements FeatureReader<SimpleFeatureType, SimpleFeature> {
- private FeatureIterator<SimpleFeature> iterator = null;
- private boolean closed = false;
- private SimpleFeatureType featureType = null;
- private FeatureCollection<SimpleFeatureType, SimpleFeature> fc = null;
+public class FeatureCollectionReader implements
+ FeatureReader<SimpleFeatureType, SimpleFeature> {
+ private FeatureIterator<SimpleFeature> iterator = null;
+ private boolean closed = false;
+ private SimpleFeatureType featureType = null;
+ private FeatureCollection<SimpleFeatureType, SimpleFeature> fc = null;
- /**
- * Erzeugt einen neuen FeatureReader.
- * @param fc FeatureCollection aus der gelesen wird.
- * @throws java.lang.UnsupportedOperationException falls die FeatureCollection
- * kein Element enthaelt.
- */
- public FeatureCollectionReader(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
- if ( fc.isEmpty() )
- throw new UnsupportedOperationException("FeatureCollection must contain at least one SimpleFeature!");
- this.fc = fc;
-
- this.featureType = new FeatureIteratorImpl<SimpleFeature>(fc).next().getType();
- reset();
- }
+ /**
+ * Erzeugt einen neuen FeatureReader.
+ *
+ * @param fc
+ * FeatureCollection aus der gelesen wird.
+ * @throws java.lang.UnsupportedOperationException
+ * falls die FeatureCollection kein Element enthaelt.
+ */
+ public FeatureCollectionReader(
+ FeatureCollection<SimpleFeatureType, SimpleFeature> fc) {
+ if (fc.isEmpty())
+ throw new UnsupportedOperationException(
+ "FeatureCollection must contain at least one SimpleFeature!");
+ this.fc = fc;
- /**
- * Liefert die Art der Features.
- */
- public SimpleFeatureType getFeatureType() {
- return featureType;
- }
+ this.featureType = new FeatureIteratorImpl<SimpleFeature>(fc).next()
+ .getType();
+ reset();
+ }
- /**
- * Prueft, ob ein weiteres SimpleFeature gelesen werden kann.
- */
- public boolean hasNext() {
- return !closed && iterator.hasNext();
- }
+ /**
+ * Liefert die Art der Features.
+ */
+ public SimpleFeatureType getFeatureType() {
+ return featureType;
+ }
- /**
- * Liefert das naechste SimpleFeature (aus der FeatureCollection).
- * @exception IOException falls der Reader bereits geschlossen ist.
- */
- public SimpleFeature next() throws IOException {
- if (closed)
- throw new IOException("FeatureReader already closed!");
- return iterator.next();
- }
+ /**
+ * Prueft, ob ein weiteres SimpleFeature gelesen werden kann.
+ */
+ public boolean hasNext() {
+ return !closed && iterator.hasNext();
+ }
- /**
- * Schliesst den Reader. Danach koennen keine weiteren Features mehr
- * gelesen werden. Ueber {@link #reset()} kann der Reader wieder geoeffnet
- * werden.
- */
- public void close() {
- closed = true;
- }
+ /**
+ * Liefert das naechste SimpleFeature (aus der FeatureCollection).
+ *
+ * @exception IOException
+ * falls der Reader bereits geschlossen ist.
+ */
+ public SimpleFeature next() throws IOException {
+ if (closed)
+ throw new IOException("FeatureReader already closed!");
+ return iterator.next();
+ }
- /**
- * Setzt den Reader auf den Anfang der {@link FeatureCollection} zurueck.
- */
- public void reset() {
- this.closed = false;
- this.iterator = new FeatureIteratorImpl(this.fc);
- }
+ /**
+ * Schliesst den Reader. Danach koennen keine weiteren Features mehr gelesen
+ * werden. Ueber {@link #reset()} kann der Reader wieder geoeffnet werden.
+ */
+ public void close() {
+ if (fc != null && iterator != null)
+ fc.close(iterator);
+ closed = true;
+ }
+
+ /**
+ * Setzt den Reader auf den Anfang der {@link FeatureCollection} zurueck.
+ */
+ public void reset() {
+ this.closed = false;
+ this.iterator = new FeatureIteratorImpl(this.fc);
+ }
}
More information about the Schmitzm-commits
mailing list