org.geotools.data.jdbc
Class ResultSetAttributeIO

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

public class ResultSetAttributeIO
extends AbstractAttributeIO
implements QueryDataListener, AttributeWriter, AttributeReader

Provides an AttriuteReader over a result set limiting the columns to a defined range. This uses the default SQL->Java type mappings of the result set.

Ranges are based on JDBC ResultSet column indexes which begin at 1

This reader does not handle any geometries.

Author:
Sean Geoghegan, Defence Science and Technology Organisation

Field Summary
 
Fields inherited from class org.geotools.data.AbstractAttributeIO
metaData
 
Constructor Summary
ResultSetAttributeIO(AttributeType[] metadata, JDBCDataStore.QueryData querydata, int startColumn, int endColumn)
          Creates a new RangedResultSetAttributeReader.
 
Method Summary
 void close()
          This closes the QueryData object that the Read was constructed with.
 boolean hasNext()
          Returns true if there are more rows.
 boolean isClosed()
           
 void next()
          Moves to the next row in the result set.
 void queryDataClosed(JDBCDataStore.QueryData queryData)
           
 java.lang.Object read(int i)
          Reads an attribute from the given column in the current row.
 void rowDeleted(JDBCDataStore.QueryData queryData)
           
 void write(int position, java.lang.Object attribute)
          This writes the attribute to the position within the ResultSet.
 
Methods inherited from class org.geotools.data.AbstractAttributeIO
copy, getAttributeCount, getAttributeType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.geotools.data.AttributeWriter
getAttributeCount, getAttributeType
 
Methods inherited from interface org.geotools.data.AttributeReader
getAttributeCount, getAttributeType
 

Constructor Detail

ResultSetAttributeIO

public ResultSetAttributeIO(AttributeType[] metadata,
                            JDBCDataStore.QueryData querydata,
                            int startColumn,
                            int endColumn)
Creates a new RangedResultSetAttributeReader. This will read all the attributes in the columns from startColumn to endColumn - 1. These indexes are 1 based.

Parameters:
metadata - The meta data of the columns.
startColumn - The starting column, inclusive.
endColumn - The ending index, exclusive.
Method Detail

close

public void close()
           throws java.io.IOException
This closes the QueryData object that the Read was constructed with. Closing this object will force all other Readers using the queryData object to be notified of the close if they are registered as QueryDataListeners of the queryData object.

This method will also set a flag to indicate that the results have been closed elsewhere and future calls to the read methods of the reader will throw errors.

Specified by:
close in interface AttributeWriter
Throws:
java.io.IOException - This will never be thrown by this class.
See Also:
AttributeReader.close()

hasNext

public boolean hasNext()
                throws java.io.IOException
Returns true if there are more rows.

Specified by:
hasNext in interface AttributeWriter
Returns:
Throws:
java.io.IOException - This will only occur if an SQLException occurs on the result set.
See Also:
AttributeReader.hasNext()

next

public void next()
          throws java.io.IOException
Moves to the next row in the result set.

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

read

public java.lang.Object read(int i)
                      throws java.io.IOException,
                             java.lang.ArrayIndexOutOfBoundsException
Reads an attribute from the given column in the current row.

Specified by:
read in interface AttributeReader
Parameters:
i - The zero based index into the attributes of this attribute reader. This index is based on the index of the attribute in the array of AttributeTypes this Reader uses as meta data. The index is internally mapped to the result set column index so this is transparent to the user.
Returns:
Object Attribute at given index
Throws:
java.io.IOException - If an error occurs setting thr row or retreiving the value from the column or the Reader has previously bee closed.
java.lang.ArrayIndexOutOfBoundsException - If the index passed as i is greater than the number of attributes in the schema or outside the range of this reader. i is outside the range of the reader if (startColumn + i) < startColumn or (startColumn + i) >= endColumn.
See Also:
AttributeReader.read(int)

write

public void write(int position,
                  java.lang.Object attribute)
           throws java.io.IOException
This writes the attribute to the position within the ResultSet.

Currently uses the update methods of result set to write the data.

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

queryDataClosed

public void queryDataClosed(JDBCDataStore.QueryData queryData)
Specified by:
queryDataClosed in interface QueryDataListener

rowDeleted

public void rowDeleted(JDBCDataStore.QueryData queryData)
Specified by:
rowDeleted in interface QueryDataListener
Parameters:
queryData -
See Also:
QueryDataListener.rowDeleted(org.geotools.data.jdbc.JDBCDataStore.QueryData)

isClosed

public boolean isClosed()


Copyright © 1996-2003 GeoTools. All Rights Reserved.