public class ReTypeFeatureReader extends Object implements DelegatingFeatureReader<SimpleFeatureType,SimpleFeature>
This may be used to have a DataStore work with your own representation of Feature information.
Example Use:
FeatureReader reader = dataStore.getFeatureReader( query, Transaction.AUTO_COMMIT );
reader = new ReTypeFeatureReader( reader, myFeatureType );
try {
while( reader.hasNext() ){
Feature f = reader.next();
System.out.println( f );
}
}
finally {
reader.close(); // will close both
}
This Reader makes a simple one to one between the original schema and the target schema based on descriptor name.
| Constructor and Description |
|---|
ReTypeFeatureReader(FeatureReader<SimpleFeatureType,SimpleFeature> reader,
SimpleFeatureType featureType)
Constructs a FetureReader that will ReType streaming content.
|
ReTypeFeatureReader(FeatureReader<SimpleFeatureType,SimpleFeature> reader,
SimpleFeatureType featureType,
boolean clone)
Constructs a FetureReader that will ReType streaming content.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Release the underlying resources associated with this stream.
|
FeatureReader<SimpleFeatureType,SimpleFeature> |
getDelegate() |
SimpleFeatureType |
getFeatureType()
Return the FeatureType this reader has been configured to create.
|
boolean |
hasNext()
Query whether this FeatureReader has another Feature.
|
SimpleFeature |
next()
Reads the next Feature in the FeatureReader.
|
protected AttributeDescriptor[] |
typeAttributes(SimpleFeatureType target,
SimpleFeatureType origional)
Supplies mapping from original to target FeatureType.
|
public ReTypeFeatureReader(FeatureReader<SimpleFeatureType,SimpleFeature> reader, SimpleFeatureType featureType)
reader - Original FeatureReaderfeatureType - Target FeatureTypepublic ReTypeFeatureReader(FeatureReader<SimpleFeatureType,SimpleFeature> reader, SimpleFeatureType featureType, boolean clone)
reader - Original FeatureReaderfeatureType - Target FeatureTypeclone - true to clone the contentpublic FeatureReader<SimpleFeatureType,SimpleFeature> getDelegate()
getDelegate in interface DelegatingFeatureReader<SimpleFeatureType,SimpleFeature>protected AttributeDescriptor[] typeAttributes(SimpleFeatureType target, SimpleFeatureType origional)
Will also ensure that mapping results in a valid selection of values from the original. Only the xpath expression and binding are checked.
target - Desired FeatureTypeorigional - Original FeatureTypeIllegalArgumentException - if unable to provide a mappingpublic SimpleFeatureType getFeatureType()
FeatureReadergetFeatureType in interface FeatureReader<SimpleFeatureType,SimpleFeature>FeatureReader.getFeatureType()public SimpleFeature next() throws IOException, IllegalAttributeException, NoSuchElementException
FeatureReadernext in interface FeatureReader<SimpleFeatureType,SimpleFeature>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.FeatureReader.next()public boolean hasNext()
throws IOException
FeatureReaderhasNext in interface FeatureReader<SimpleFeatureType,SimpleFeature>IOException - If an error occurs determining if there are more Features.FeatureReader.hasNext()public void close()
throws IOException
FeatureReaderclose in interface Closeableclose in interface AutoCloseableclose in interface FeatureReader<SimpleFeatureType,SimpleFeature>IOException - if an I/O error occursFeatureReader.close()Copyright © 1996–2021 Geotools. All rights reserved.