Package org.geotools.jdbc
Class JDBCFeatureReader
Object
JDBCFeatureReader
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FeatureReader<SimpleFeatureType,
SimpleFeature>
- Direct Known Subclasses:
JDBCInsertFeatureWriter
,JDBCJoiningFeatureReader
,JDBCUpdateFeatureWriter
public class JDBCFeatureReader
extends Object
implements FeatureReader<SimpleFeatureType,SimpleFeature>
Reader for jdbc datastore
- Author:
- Justin Deoliveira, The Open Plannign Project.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Feature wrapper around a result set. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SimpleFeatureBuilder
feature builderprotected JDBCReaderCallback
protected String[]
protected Connection
protected JDBCDataStore
the datastoreprotected JDBCFeatureSource
The feature source the reader originated from.protected SimpleFeatureType
schema of featuresprotected GeometryFactory
geometry factory used to create geometry objectsprotected Hints
hintsprotected static final Logger
protected ResultSetMetaData
protected Boolean
flag indicating if the iterator has another featureprotected int
offset/column index to start reading from result setprotected PrimaryKey
The primary keyprotected Query
the queryprotected ResultSet
protected ScreenMap
Screenmap for feature skipping behaviourprotected Statement
statement,result set that is being worked from.protected static final Boolean
When true, the stack trace that created a reader that wasn't closed is recorded and then printed out when warning the user about this.protected Exception
protected Transaction
current transaction -
Constructor Summary
ConstructorsConstructorDescriptionJDBCFeatureReader
(String sql, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) JDBCFeatureReader
(PreparedStatement st, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) JDBCFeatureReader
(ResultSet rs, Connection cx, int offset, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup()
Cleans up the reader state without closing the accessory resultset, statement and connection.void
close()
Release the underlying resources associated with this stream.protected void
protected void
protected void
finalize()
Return the FeatureType this reader has been configured to create.getQuery()
boolean
hasNext()
Query whether this FeatureReader has another Feature.protected void
init
(JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) next()
Reads the next Feature in the FeatureReader.protected SimpleFeature
void
-
Field Details
-
LOGGER
-
TRACE_ENABLED
When true, the stack trace that created a reader that wasn't closed is recorded and then printed out when warning the user about this. -
featureSource
The feature source the reader originated from. -
dataStore
the datastore -
featureType
schema of features -
geometryFactory
geometry factory used to create geometry objects -
query
the query -
hints
hints -
screenMap
Screenmap for feature skipping behaviour -
tx
current transaction -
next
flag indicating if the iterator has another feature -
builder
feature builder -
pkey
The primary key -
st
statement,result set that is being worked from. -
rs
-
cx
-
md
-
tracer
-
columnNames
-
offset
protected int offsetoffset/column index to start reading from result set -
callback
-
-
Constructor Details
-
JDBCFeatureReader
public JDBCFeatureReader(String sql, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException - Throws:
SQLException
-
JDBCFeatureReader
public JDBCFeatureReader(PreparedStatement st, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException - Throws:
SQLException
-
JDBCFeatureReader
public JDBCFeatureReader(ResultSet rs, Connection cx, int offset, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Query query) throws SQLException - Throws:
SQLException
-
JDBCFeatureReader
-
-
Method Details
-
init
-
setNext
-
getFeatureType
Description copied from interface:FeatureReader
Return the FeatureType this reader has been configured to create.- Specified by:
getFeatureType
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- the FeatureType of the Features this FeatureReader will create.
-
getPrimaryKey
-
getQuery
-
hasNext
Description copied from interface:FeatureReader
Query whether this FeatureReader has another Feature.- Specified by:
hasNext
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- True if there are more Features to be read. In other words, true if calls to next would return a feature rather than throwing an exception.
- Throws:
IOException
- If an error occurs determining if there are more Features.
-
readNextFeature
-
ensureNext
protected void ensureNext() -
ensureOpen
- Throws:
IOException
-
next
Description copied from interface:FeatureReader
Reads the next Feature in the FeatureReader.- Specified by:
next
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Returns:
- The next feature in the reader.
- Throws:
IOException
- If an error occurs reading the Feature.NoSuchElementException
- If there are no more Features in the Reader.IllegalArgumentException
-
close
Description copied from interface:FeatureReader
Release the underlying resources associated with this stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFeatureReader<SimpleFeatureType,
SimpleFeature> - Throws:
IOException
- if an I/O error occurs
-
cleanup
Cleans up the reader state without closing the accessory resultset, statement and connection. Use only if the above are shared with another object that will take care of closing them.- Throws:
IOException
-
finalize
-