org.geotools.jdbc
Class JDBCFeatureReader

Object
  extended by JDBCFeatureReader
All Implemented Interfaces:
Closeable, 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
protected  class JDBCFeatureReader.ResultSetFeature
          Feature wrapper around a result set.
 
Field Summary
protected  SimpleFeatureBuilder builder
          feature builder
protected  String[] columnNames
           
protected  Connection cx
           
protected  JDBCDataStore dataStore
          the datastore
protected  JDBCFeatureSource featureSource
          The feature source the reader originated from.
protected  SimpleFeatureType featureType
          schema of features
protected  GeometryFactory geometryFactory
          geometry factory used to create geometry objects
protected  Hints hints
          hints
protected static Logger LOGGER
           
protected  Boolean next
          flag indicating if the iterator has another feature
protected  int offset
          offset/column index to start reading from result set
protected  PrimaryKey pkey
          The primary key
protected  ResultSet rs
           
protected  Statement st
          statement,result set that is being worked from.
protected static Boolean 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.
protected  Exception tracer
           
protected  Transaction tx
          current transaction
 
Constructor Summary
JDBCFeatureReader(JDBCFeatureReader other)
           
JDBCFeatureReader(PreparedStatement st, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Hints hints)
           
JDBCFeatureReader(ResultSet rs, Connection cx, int offset, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Hints hints)
           
JDBCFeatureReader(String sql, Connection cx, JDBCFeatureSource featureSource, SimpleFeatureType featureType, Hints hints)
           
 
Method Summary
protected  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 ensureNext()
           
protected  void ensureOpen()
           
protected  void finalize()
           
 SimpleFeatureType getFeatureType()
          Return the FeatureType this reader has been configured to create.
 PrimaryKey getPrimaryKey()
           
 boolean hasNext()
          Query whether this FeatureReader has another Feature.
protected  void init(JDBCFeatureSource featureSource, SimpleFeatureType featureType, Hints hints)
           
 SimpleFeature next()
          Reads the next Feature in the FeatureReader.
 void setNext(Boolean next)
           
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER

TRACE_ENABLED

protected static final Boolean 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

protected JDBCFeatureSource featureSource
The feature source the reader originated from.


dataStore

protected JDBCDataStore dataStore
the datastore


featureType

protected SimpleFeatureType featureType
schema of features


geometryFactory

protected GeometryFactory geometryFactory
geometry factory used to create geometry objects


hints

protected Hints hints
hints


tx

protected Transaction tx
current transaction


next

protected Boolean next
flag indicating if the iterator has another feature


builder

protected SimpleFeatureBuilder builder
feature builder


pkey

protected PrimaryKey pkey
The primary key


st

protected Statement st
statement,result set that is being worked from.


rs

protected ResultSet rs

cx

protected Connection cx

tracer

protected Exception tracer

columnNames

protected String[] columnNames

offset

protected int offset
offset/column index to start reading from result set

Constructor Detail

JDBCFeatureReader

public JDBCFeatureReader(String sql,
                         Connection cx,
                         JDBCFeatureSource featureSource,
                         SimpleFeatureType featureType,
                         Hints hints)
                  throws SQLException
Throws:
SQLException

JDBCFeatureReader

public JDBCFeatureReader(PreparedStatement st,
                         Connection cx,
                         JDBCFeatureSource featureSource,
                         SimpleFeatureType featureType,
                         Hints hints)
                  throws SQLException
Throws:
SQLException

JDBCFeatureReader

public JDBCFeatureReader(ResultSet rs,
                         Connection cx,
                         int offset,
                         JDBCFeatureSource featureSource,
                         SimpleFeatureType featureType,
                         Hints hints)
                  throws SQLException
Throws:
SQLException

JDBCFeatureReader

public JDBCFeatureReader(JDBCFeatureReader other)
Method Detail

init

protected void init(JDBCFeatureSource featureSource,
                    SimpleFeatureType featureType,
                    Hints hints)

setNext

public void setNext(Boolean next)

getFeatureType

public SimpleFeatureType getFeatureType()
Description copied from interface: FeatureReader
Return the FeatureType this reader has been configured to create.

Specified by:
getFeatureType in interface FeatureReader<SimpleFeatureType,SimpleFeature>
Returns:
the FeatureType of the Features this FeatureReader will create.

getPrimaryKey

public PrimaryKey getPrimaryKey()

hasNext

public boolean hasNext()
                throws IOException
Description copied from interface: FeatureReader
Query whether this FeatureReader has another Feature.

Specified by:
hasNext in interface FeatureReader<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.

ensureNext

protected void ensureNext()

ensureOpen

protected void ensureOpen()
                   throws IOException
Throws:
IOException

next

public SimpleFeature next()
                   throws IOException,
                          IllegalArgumentException,
                          NoSuchElementException
Description copied from interface: FeatureReader
Reads the next Feature in the FeatureReader.

Specified by:
next in interface FeatureReader<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

public void close()
           throws IOException
Description copied from interface: FeatureReader
Release the underlying resources associated with this stream.

Specified by:
close in interface Closeable
Specified by:
close in interface FeatureReader<SimpleFeatureType,SimpleFeature>
Throws:
IOException - if an I/O error occurs

cleanup

protected void 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.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable


Copyright © 1996-2014 Geotools. All Rights Reserved.