org.geotools.data.jdbc
Class QueryData

Object
  extended by QueryData
All Implemented Interfaces:
AttributeReader, AttributeWriter

public class QueryData
extends Object
implements AttributeReader, AttributeWriter

QueryData holds the ResultSet obtained from the sql query and has the following responsibilities:

Author:
aaime
Module:
trunk/gt/modules   (gt-modules.jar) (Maven report) (SVN head)

Field Summary
protected  AttributeIO[] attributeHandlers
           
protected  int baseIndex
           
protected  Connection connection
           
protected  FeatureTypeInfo featureTypeInfo
           
protected  Object[] fidAttributes
           
protected  Hints hints
           
protected  FeatureListenerManager listenerManager
           
protected static Logger LOGGER
          The logger for the data module.
protected  FIDMapper mapper
           
protected  ResultSet resultSet
           
protected  Statement statement
           
protected  Transaction transaction
           
 
Constructor Summary
QueryData(FeatureTypeInfo featureTypeInfo, JDBC1DataStore parentDataStore, Connection connection, Statement statement, ResultSet resultSet, Transaction transaction)
          Creates a new QueryData object.
QueryData(FeatureTypeInfo featureTypeInfo, JDBC1DataStore parentDataStore, Connection connection, Statement statement, ResultSet resultSet, Transaction transaction, Hints hints)
          Creates a new QueryData object.
 
Method Summary
 void close()
          Release any resources associated with this reader
 void close(SQLException sqlException)
          Closes the JDBC objects associated to the queryData and reports the sqlException on the LOG
 void deleteCurrentRow()
          Deletes the current record in the result set
 void doInsert()
          Insert a record in the current result set
protected  void finalize()
           
 void fireChangeRemoved(ReferencedEnvelope bounds, boolean isCommit)
          Call after deleteCurrentRow()
 void fireFeaturesAdded(ReferencedEnvelope bounds, boolean isCommit)
          Call after doUpdate
 void fireFeaturesChanged(ReferencedEnvelope bounds, boolean isCommit)
          Call after updateRow
 int getAttributeCount()
          The number of attributes this reader can read, i.e the length of a row.
 AttributeIO[] getAttributeHandlers()
          Returns the AttributeIO objects used to parse and encode the column values stored in the database
 AttributeDescriptor getAttributeType(int index)
          Retrieve the AttributeType at the given index.
 Connection getConnection()
          DOCUMENT ME!
 SimpleFeatureType getFeatureType()
          Returns the current feature type
 FeatureTypeInfo getFeatureTypeInfo()
          DOCUMENT ME!
 Hints getHints()
           
 FeatureListenerManager getListenerManager()
           
 FIDMapper getMapper()
          Returns the FID mapper to be used when reading/writing features
 Transaction getTransaction()
          Returns the current transation
 boolean hasNext()
          Does another set of attributes exist in this reader?
 boolean isClosed()
           
 void next()
          Advance the reader to the next set of attributes.
 Object read(int index)
          Read the attribute at the given index.
 Object readFidColumn(int index)
          Reads a column of the primary key
 void startInsert()
          Moves the result set to the insert row.
 void updateRow()
          Update the current record
 void write(int i, Object currAtt)
          Write the given attribute value at the position indicated.
 void writeFidColumn(int index, Object value)
          Writes a column of the primary key
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER
The logger for the data module.


fidAttributes

protected Object[] fidAttributes

featureTypeInfo

protected FeatureTypeInfo featureTypeInfo

resultSet

protected ResultSet resultSet

connection

protected Connection connection

transaction

protected Transaction transaction

statement

protected Statement statement

mapper

protected FIDMapper mapper

attributeHandlers

protected AttributeIO[] attributeHandlers

baseIndex

protected int baseIndex

listenerManager

protected FeatureListenerManager listenerManager

hints

protected Hints hints
Constructor Detail

QueryData

public QueryData(FeatureTypeInfo featureTypeInfo,
                 JDBC1DataStore parentDataStore,
                 Connection connection,
                 Statement statement,
                 ResultSet resultSet,
                 Transaction transaction)
          throws IOException
Creates a new QueryData object.

Parameters:
featureTypeInfo -
parentDataStore -
connection -
statement -
resultSet -
transaction -
Throws:
IOException

QueryData

public QueryData(FeatureTypeInfo featureTypeInfo,
                 JDBC1DataStore parentDataStore,
                 Connection connection,
                 Statement statement,
                 ResultSet resultSet,
                 Transaction transaction,
                 Hints hints)
          throws IOException
Creates a new QueryData object.

Parameters:
featureTypeInfo -
parentDataStore -
connection -
statement -
resultSet -
transaction -
Throws:
IOException
Method Detail

getAttributeCount

public int getAttributeCount()
Description copied from interface: AttributeReader
The number of attributes this reader can read, i.e the length of a row.

Specified by:
getAttributeCount in interface AttributeReader
Specified by:
getAttributeCount in interface AttributeWriter
Returns:
Number of attribtues this reader can read
See Also:
AttributeWriter.getAttributeCount()

getAttributeHandlers

public AttributeIO[] getAttributeHandlers()
Returns the AttributeIO objects used to parse and encode the column values stored in the database


getConnection

public Connection getConnection()
DOCUMENT ME!


getMapper

public FIDMapper getMapper()
Returns the FID mapper to be used when reading/writing features


getTransaction

public Transaction getTransaction()
Returns the current transation


close

public void close()
Description copied from interface: AttributeReader
Release any resources associated with this reader

Specified by:
close in interface AttributeReader
Specified by:
close in interface AttributeWriter
See Also:
AttributeWriter.close()

close

public void close(SQLException sqlException)
Closes the JDBC objects associated to the queryData and reports the sqlException on the LOG

Parameters:
sqlException -

read

public Object read(int index)
            throws IOException,
                   ArrayIndexOutOfBoundsException
Description copied from interface: AttributeReader
Read the attribute at the given index.

Specified by:
read in interface AttributeReader
Returns:
Object Attribute at given index
Throws:
IOException
ArrayIndexOutOfBoundsException
See Also:
AttributeReader.read(int)

write

public void write(int i,
                  Object currAtt)
           throws IOException
Description copied from interface: AttributeWriter
Write the given attribute value at the position indicated. Implementations can choose to immediately flush the write or buffer it.

Specified by:
write in interface AttributeWriter
Throws:
IOException
See Also:
AttributeWriter.write(int, java.lang.Object)

readFidColumn

public Object readFidColumn(int index)
                     throws IOException
Reads a column of the primary key

Parameters:
index - the column index among the primary key columns (as reported by the FIDMapper)
Returns:
fid value
Throws:
IOException
DataSourceException

writeFidColumn

public void writeFidColumn(int index,
                           Object value)
                    throws IOException
Writes a column of the primary key

Parameters:
index - the FID column index among the primary key columns (as reported by the FIDMapper)
value - the column value
Throws:
IOException
DataSourceException

getFeatureType

public SimpleFeatureType getFeatureType()
Returns the current feature type


startInsert

public void startInsert()
                 throws SQLException
Moves the result set to the insert row. Must be called before writing the attribute values for the new Feature

Throws:
SQLException

deleteCurrentRow

public void deleteCurrentRow()
                      throws SQLException
Deletes the current record in the result set

Throws:
SQLException

updateRow

public void updateRow()
               throws SQLException
Update the current record

Throws:
SQLException

doInsert

public void doInsert()
              throws SQLException
Insert a record in the current result set

Throws:
SQLException

getFeatureTypeInfo

public FeatureTypeInfo getFeatureTypeInfo()
DOCUMENT ME!


isClosed

public boolean isClosed()
Returns:
true if the QueryData has been closed, false otherwise

next

public void next()
          throws IOException
Description copied from interface: AttributeReader
Advance the reader to the next set of attributes.

Specified by:
next in interface AttributeReader
Specified by:
next in interface AttributeWriter
Throws:
IOException
See Also:
AttributeWriter.next()

hasNext

public boolean hasNext()
                throws IOException
Description copied from interface: AttributeReader
Does another set of attributes exist in this reader?

Specified by:
hasNext in interface AttributeReader
Specified by:
hasNext in interface AttributeWriter
Returns:
true if additional content exists for AttributeReader
Throws:
IOException
See Also:
AttributeWriter.hasNext()

getAttributeType

public AttributeDescriptor getAttributeType(int index)
                                     throws ArrayIndexOutOfBoundsException
Description copied from interface: AttributeReader
Retrieve the AttributeType at the given index.

Specified by:
getAttributeType in interface AttributeReader
Specified by:
getAttributeType in interface AttributeWriter
Returns:
AttributeType at given index
Throws:
ArrayIndexOutOfBoundsException
See Also:
AttributeReader.getAttributeType(int)

getListenerManager

public FeatureListenerManager getListenerManager()

fireChangeRemoved

public void fireChangeRemoved(ReferencedEnvelope bounds,
                              boolean isCommit)
Call after deleteCurrentRow()


fireFeaturesChanged

public void fireFeaturesChanged(ReferencedEnvelope bounds,
                                boolean isCommit)
Call after updateRow


fireFeaturesAdded

public void fireFeaturesAdded(ReferencedEnvelope bounds,
                              boolean isCommit)
Call after doUpdate


finalize

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

getHints

public Hints getHints()


Copyright © 1996-2009 Geotools. All Rights Reserved.