org.geotools.data.jdbc
Class QueryData

java.lang.Object
  extended byorg.geotools.data.jdbc.QueryData
All Implemented Interfaces:
AttributeReader, AttributeWriter

public class QueryData
extends java.lang.Object
implements AttributeReader, AttributeWriter

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

Author:
aaime

Field Summary
protected  AttributeIO[] attributeHandlers
           
protected  int baseIndex
           
protected  java.sql.Connection connection
           
protected  FeatureTypeInfo featureTypeInfo
           
protected  java.lang.Object[] fidAttributes
           
protected  FIDMapper mapper
           
protected  java.sql.ResultSet resultSet
           
protected  java.sql.Statement statement
           
protected  Transaction transaction
           
 
Constructor Summary
QueryData(FeatureTypeInfo featureTypeInfo, JDBC1DataStore parentDataStore, java.sql.Connection connection, java.sql.Statement statement, java.sql.ResultSet resultSet, Transaction transaction)
          Creates a new QueryData object.
 
Method Summary
 void close()
          Release any resources associated with this reader
 void close(java.sql.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
 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
 AttributeType getAttributeType(int index)
          Retrieve the AttributeType at the given index.
 java.sql.Connection getConnection()
          DOCUMENT ME!
 FeatureType getFeatureType()
          Returns the current feature type
 FeatureTypeInfo getFeatureTypeInfo()
          DOCUMENT ME!
 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.
 java.lang.Object read(int index)
          Read the attribute at the given index.
 java.lang.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, java.lang.Object currAtt)
          Write the given attribute value at the position indicated.
 void writeFidColumn(int index, java.lang.Object value)
          Writes a column of the primary key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fidAttributes

protected java.lang.Object[] fidAttributes

featureTypeInfo

protected FeatureTypeInfo featureTypeInfo

resultSet

protected java.sql.ResultSet resultSet

connection

protected java.sql.Connection connection

transaction

protected Transaction transaction

statement

protected java.sql.Statement statement

mapper

protected FIDMapper mapper

attributeHandlers

protected AttributeIO[] attributeHandlers

baseIndex

protected int baseIndex
Constructor Detail

QueryData

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

Parameters:
featureTypeInfo -
parentDataStore -
connection -
statement -
resultSet -
transaction -
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
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

Returns:

getConnection

public java.sql.Connection getConnection()
DOCUMENT ME!

Returns:

getMapper

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

Returns:

getTransaction

public Transaction getTransaction()
Returns the current transation

Returns:

close

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

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

close

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

Parameters:
sqlException -

read

public java.lang.Object read(int index)
                      throws java.io.IOException,
                             java.lang.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:
java.io.IOException
java.lang.ArrayIndexOutOfBoundsException
See Also:
AttributeReader.read(int)

write

public void write(int i,
                  java.lang.Object currAtt)
           throws java.io.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:
java.io.IOException
See Also:
AttributeWriter.write(int, java.lang.Object)

readFidColumn

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

Parameters:
index - the column index among the primary key columns (as reported by the FIDMapper)
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
DataSourceException - DOCUMENT ME!

writeFidColumn

public void writeFidColumn(int index,
                           java.lang.Object value)
                    throws java.io.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:
java.io.IOException
DataSourceException

getFeatureType

public FeatureType getFeatureType()
Returns the current feature type

Returns:

startInsert

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

Throws:
java.sql.SQLException

deleteCurrentRow

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

Throws:
java.sql.SQLException

updateRow

public void updateRow()
               throws java.sql.SQLException
Update the current record

Throws:
java.sql.SQLException

doInsert

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

Throws:
java.sql.SQLException

getFeatureTypeInfo

public FeatureTypeInfo getFeatureTypeInfo()
DOCUMENT ME!

Returns:

isClosed

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

next

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

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

hasNext

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

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

getAttributeType

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

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


Copyright © GeoTools. All Rights Reserved.