public class FilteringFeatureReader<T extends FeatureType,F extends Feature> extends Object implements DelegatingFeatureReader<T,F>
Jody here - changed hasNext() to peek as required.
Modifier and Type | Field and Description |
---|---|
protected FeatureReader<T,F> |
featureReader |
protected Filter |
filter |
protected F |
next |
Constructor and Description |
---|
FilteringFeatureReader(FeatureReader<T,F> featureReader,
Filter filter)
Creates a new instance of AbstractFeatureReader
Please don't call this method with Filter.INCLUDE or Filter.EXCLUDE (consider not
filtering and EmptyFeatureReader instead)
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Release the underlying resources associated with this stream.
|
FeatureReader<T,F> |
getDelegate() |
T |
getFeatureType()
Return the FeatureType this reader has been configured to create.
|
boolean |
hasNext()
Query for additional content.
|
F |
next()
Reads the next Feature in the FeatureReader.
|
protected final FeatureReader<T extends FeatureType,F extends Feature> featureReader
protected final Filter filter
public FilteringFeatureReader(FeatureReader<T,F> featureReader, Filter filter)
Please don't call this method with Filter.INCLUDE or Filter.EXCLUDE (consider not filtering and EmptyFeatureReader instead)
featureReader
- FeatureReaderfilter
- Filter used to limit the results of featureReaderpublic FeatureReader<T,F> getDelegate()
getDelegate
in interface DelegatingFeatureReader<T extends FeatureType,F extends Feature>
public F next() throws IOException, IllegalAttributeException, NoSuchElementException
FeatureReader
next
in interface FeatureReader<T extends FeatureType,F extends Feature>
IOException
- If an error occurs reading the Feature.IllegalAttributeException
- If the attributes read do not comply with the FeatureType.NoSuchElementException
- If there are no more Features in the Reader.public void close() throws IOException
FeatureReader
close
in interface Closeable
close
in interface AutoCloseable
close
in interface FeatureReader<T extends FeatureType,F extends Feature>
IOException
- if an I/O error occurspublic T getFeatureType()
FeatureReader
getFeatureType
in interface FeatureReader<T extends FeatureType,F extends Feature>
public boolean hasNext() throws IOException
This class will peek ahead to see if there is additional content.
Chris has pointed out that we could make use of AttributeReader based filtering:
"Also doing things in the Attribute Reader would allow us to do the smart filtering, only
looking at the attributes needed for comparison, whereas doing filtering here means we have
to create an entire feature each time."
hasNext
in interface FeatureReader<T extends FeatureType,F extends Feature>
true
if we have additional contentIOException
- If the reader we are filtering encounters a problemDataSourceException
- See IOExceptionCopyright © 1996–2022 Geotools. All rights reserved.