org.apache.derby.impl.sql
Class GenericResultDescription

java.lang.Object
  extended by org.apache.derby.impl.sql.GenericResultDescription
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, ResultDescription

public final class GenericResultDescription
extends java.lang.Object
implements ResultDescription, Formatable

GenericResultDescription: basic implementation of result description, used in conjunction with the other implementations in this package. This implementation of ResultDescription may be used by anyone.

See Also:
Serialized Form

Field Summary
private  java.util.Map columnNameMap
          A map which maps a column name to a column number.
private  ResultColumnDescriptor[] columns
          This class implements Formatable.
private  java.sql.ResultSetMetaData metaData
          Saved JDBC ResultSetMetaData object.
private  java.lang.String statementType
           
 
Constructor Summary
GenericResultDescription()
          Niladic constructor for Formatable
GenericResultDescription(ResultColumnDescriptor[] columns, java.lang.String statementType)
          Build a GenericResultDescription from columns and type
GenericResultDescription(ResultDescription rd, int[] theCols)
          Build a GenericResultDescription
 
Method Summary
 int findColumnInsenstive(java.lang.String columnName)
          Find a column name based upon the JDBC rules for getXXX and setXXX.
 int getColumnCount()
          Returns the number of columns in the result set.
 ResultColumnDescriptor getColumnDescriptor(int position)
          position is 1-based.
 ResultColumnDescriptor[] getColumnInfo()
          Return information about all the columns.
 java.sql.ResultSetMetaData getMetaData()
          Get the saved meta data.
 java.lang.String getStatementType()
          Returns an identifier that tells what type of statement has been executed.
 int getTypeFormatId()
          Get the formatID which corresponds to this class.
 void readExternal(java.io.ObjectInput in)
          Read this object from a stream of stored objects.
 void setMetaData(java.sql.ResultSetMetaData rsmd)
          Set the meta data if it has not already been set.
 java.lang.String toString()
           
 ResultDescription truncateColumns(int truncateFrom)
          Get a new result description that has been truncated from input column number.
 void writeExternal(java.io.ObjectOutput out)
          Write this object out
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

columns

private ResultColumnDescriptor[] columns
This class implements Formatable. That means that it can write itself to and from a formatted stream. If you add more fields to this class, make sure that you also write/read them with the writeExternal()/readExternal() methods. If, inbetween releases, you add more fields to this class, then you should bump the version number emitted by the getTypeFormatId() method.


statementType

private java.lang.String statementType

metaData

private transient java.sql.ResultSetMetaData metaData
Saved JDBC ResultSetMetaData object.

See Also:
ResultDescription.setMetaData(java.sql.ResultSetMetaData)

columnNameMap

private java.util.Map columnNameMap
A map which maps a column name to a column number. Entries only added when accessing columns with the name.

Constructor Detail

GenericResultDescription

public GenericResultDescription()
Niladic constructor for Formatable


GenericResultDescription

public GenericResultDescription(ResultColumnDescriptor[] columns,
                                java.lang.String statementType)
Build a GenericResultDescription from columns and type

Parameters:
columns - an array of col descriptors
statementType - the type

GenericResultDescription

public GenericResultDescription(ResultDescription rd,
                                int[] theCols)
Build a GenericResultDescription

Parameters:
rd - the result description
theCols - the columns to take from the input rd
Method Detail

getStatementType

public java.lang.String getStatementType()
Description copied from interface: ResultDescription
Returns an identifier that tells what type of statement has been executed. This can be used to determine what other methods to call to get the results back from a statement. For example, a SELECT statement returns rows and columns, while other statements don't, so you would only call getColumnCount() or getColumnType() for SELECT statements.

Specified by:
getStatementType in interface ResultDescription
Returns:
A String identifier telling what type of statement this is.
See Also:
ResultDescription.getStatementType()

getColumnCount

public int getColumnCount()
Description copied from interface: ResultDescription
Returns the number of columns in the result set.

Specified by:
getColumnCount in interface ResultDescription
Returns:
The number of columns in the result set.
See Also:
ResultDescription.getColumnCount()

getColumnInfo

public ResultColumnDescriptor[] getColumnInfo()
Description copied from interface: ResultDescription
Return information about all the columns.

Specified by:
getColumnInfo in interface ResultDescription

getColumnDescriptor

public ResultColumnDescriptor getColumnDescriptor(int position)
position is 1-based.

Specified by:
getColumnDescriptor in interface ResultDescription
Parameters:
position - The oridinal position of a column in the ResultSet.
Returns:
A ResultColumnDescriptor describing the column in the ResultSet.
See Also:
ResultDescription.getColumnDescriptor(int)

truncateColumns

public ResultDescription truncateColumns(int truncateFrom)
Get a new result description that has been truncated from input column number. If the input column is 5, then columns 5 to getColumnCount() are removed. The new ResultDescription points to the same ColumnDescriptors (this method performs a shallow copy.

Specified by:
truncateColumns in interface ResultDescription
Parameters:
truncateFrom - the starting column to remove
Returns:
a new ResultDescription

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write this object out

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - write bytes here
Throws:
java.io.IOException - thrown on error

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read this object from a stream of stored objects.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - read this.
Throws:
java.io.IOException - thrown on error
java.lang.ClassNotFoundException - thrown on error

getTypeFormatId

public int getTypeFormatId()
Get the formatID which corresponds to this class.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
the formatID of this class

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setMetaData

public void setMetaData(java.sql.ResultSetMetaData rsmd)
Set the meta data if it has not already been set.

Specified by:
setMetaData in interface ResultDescription

getMetaData

public java.sql.ResultSetMetaData getMetaData()
Get the saved meta data.

Specified by:
getMetaData in interface ResultDescription

findColumnInsenstive

public int findColumnInsenstive(java.lang.String columnName)
Find a column name based upon the JDBC rules for getXXX and setXXX. Name matching is case-insensitive, matching the first name (1-based) if there are multiple columns that map to the same name.

Specified by:
findColumnInsenstive in interface ResultDescription
Returns:
Position of the column (1-based), -1 if no match.

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.