Top Description Fields Constructors Methods
org.apache.derby.impl.sql

public final Class GenericResultDescription

extends Object
implements ResultDescription, Formatable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable, org.apache.derby.iapi.sql.ResultDescription
Imports
org.apache.derby.iapi.sql.ResultColumnDescriptor, .ResultDescription, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.util.ArrayUtil, org.apache.derby.iapi.services.io.StoredFormatIds, .Formatable, org.apache.derby.iapi.util.StringUtil, java.io.ObjectOutput, .ObjectInput, .IOException, java.sql.ResultSetMetaData, java.util.Collections, .HashMap, .Map

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.

Field Summary

Modifier and TypeField and Description
private Map<String, Integer>
columnNameMap

A map which maps a column name to a column number.

private ResultColumnDescriptor[]
columns

This class implements Formatable.

private transient ResultSetMetaData
metaData

Saved JDBC ResultSetMetaData object.

private String

Constructor Summary

AccessConstructor and Description
public
GenericResultDescription()

Niladic constructor for Formatable

public
GenericResultDescription(ResultColumnDescriptor[]
an array of col descriptors
columns
,
String
the type
statementType
)

Build a GenericResultDescription from columns and type

public
GenericResultDescription(ResultDescription
the result description
rd
,
int[]
the columns to take from the input rd
theCols
)

Build a GenericResultDescription

Method Summary

Modifier and TypeMethod and Description
public int
findColumnInsenstive(String
The column name
columnName
)

Implements org.apache.derby.iapi.sql.ResultDescription.findColumnInsenstive.

Find a column name based upon the JDBC rules for getXXX and setXXX.

public int
getColumnCount()

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnCount.

Returns the number of columns in the result set.

public ResultColumnDescriptor
getColumnDescriptor(int
The oridinal position of a column in the ResultSet.
position
)

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnDescriptor.

position is 1-based.

public ResultColumnDescriptor[]
getColumnInfo()

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Return information about all the columns.

public ResultColumnDescriptor
getColumnInfo(int
The column index
idx
)

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Return the information about a single column (0-based indexing)

public synchronized ResultSetMetaData
public String
getStatementType()

Implements org.apache.derby.iapi.sql.ResultDescription.getStatementType.

Returns an identifier that tells what type of statement has been executed.

public int

Returns:

the formatID of this class
getTypeFormatId
()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

public void
readExternal(ObjectInput
read this.
in
)

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects.

public synchronized void
setMetaData(ResultSetMetaData
The metadata to set
rsmd
)

Implements org.apache.derby.iapi.sql.ResultDescription.setMetaData.

Set the meta data if it has not already been set.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public ResultDescription

Returns:

a new ResultDescription
truncateColumns
(int
the starting column to remove
truncateFrom
)

Implements org.apache.derby.iapi.sql.ResultDescription.truncateColumns.

Get a new result description that has been truncated from input column number.

public void
writeExternal(ObjectOutput
write bytes here
out
)

Implements java.io.Externalizable.writeExternal.

Write this object out

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

columnNameMapback to summary
private Map<String, Integer> columnNameMap

A map which maps a column name to a column number. Entries only added when accessing columns with the name.

columnsback to summary
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.

metaDataback to summary
private transient ResultSetMetaData metaData

Saved JDBC ResultSetMetaData object.

See Also
ResultDescription#setMetaData(java.sql.ResultSetMetaData)
statementTypeback to summary
private String statementType

Constructor Detail

GenericResultDescriptionback to summary
public GenericResultDescription()

Niladic constructor for Formatable

GenericResultDescriptionback to summary
public GenericResultDescription(ResultColumnDescriptor[] columns, String statementType)

Build a GenericResultDescription from columns and type

Parameters
columns:ResultColumnDescriptor[]

an array of col descriptors

statementType:String

the type

GenericResultDescriptionback to summary
public GenericResultDescription(ResultDescription rd, int[] theCols)

Build a GenericResultDescription

Parameters
rd:ResultDescription

the result description

theCols:int[]

the columns to take from the input rd

Method Detail

findColumnInsenstiveback to summary
public int findColumnInsenstive(String columnName)

Implements org.apache.derby.iapi.sql.ResultDescription.findColumnInsenstive.

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.

Parameters
columnName:String

Doc from org.apache.derby.iapi.sql.ResultDescription.findColumnInsenstive.

The column name

Returns:int

Doc from org.apache.derby.iapi.sql.ResultDescription.findColumnInsenstive.

Position of the column (1-based), -1 if no match.

getColumnCountback to summary
public int getColumnCount()

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnCount.

Doc from org.apache.derby.iapi.sql.ResultDescription.getColumnCount.

Returns the number of columns in the result set.

Returns:int

The number of columns in the result set.

See Also
ResultDescription#getColumnCount
getColumnDescriptorback to summary
public ResultColumnDescriptor getColumnDescriptor(int position)

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnDescriptor.

position is 1-based.

Parameters
position:int

Doc from org.apache.derby.iapi.sql.ResultDescription.getColumnDescriptor.

The oridinal position of a column in the ResultSet.

Returns:ResultColumnDescriptor

Doc from org.apache.derby.iapi.sql.ResultDescription.getColumnDescriptor.

A ResultColumnDescriptor describing the column in the ResultSet.

See Also
ResultDescription#getColumnDescriptor
getColumnInfoback to summary
public ResultColumnDescriptor[] getColumnInfo()

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Doc from org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Return information about all the columns.

Returns:ResultColumnDescriptor[]

information about all the columns

getColumnInfoback to summary
public ResultColumnDescriptor getColumnInfo(int idx)

Implements org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Doc from org.apache.derby.iapi.sql.ResultDescription.getColumnInfo.

Return the information about a single column (0-based indexing)

Parameters
idx:int

The column index

Returns:ResultColumnDescriptor

The column descriptor

getMetaDataback to summary
public synchronized ResultSetMetaData getMetaData()

Implements org.apache.derby.iapi.sql.ResultDescription.getMetaData.

Get the saved meta data.

Returns:ResultSetMetaData

Doc from org.apache.derby.iapi.sql.ResultDescription.getMetaData.

the metadata

getStatementTypeback to summary
public String getStatementType()

Implements org.apache.derby.iapi.sql.ResultDescription.getStatementType.

Doc from org.apache.derby.iapi.sql.ResultDescription.getStatementType.

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.

Returns:String

A String identifier telling what type of statement this is.

See Also
ResultDescription#getStatementType
getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

Returns:int

the formatID of this class

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Read this object from a stream of stored objects.

Parameters
in:ObjectInput

read this.

Exceptions
IOException:
thrown on error
ClassNotFoundException:
thrown on error
setMetaDataback to summary
public synchronized void setMetaData(ResultSetMetaData rsmd)

Implements org.apache.derby.iapi.sql.ResultDescription.setMetaData.

Set the meta data if it has not already been set.

Parameters
rsmd:ResultSetMetaData

Doc from org.apache.derby.iapi.sql.ResultDescription.setMetaData.

The metadata to set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

truncateColumnsback to summary
public ResultDescription truncateColumns(int truncateFrom)

Implements org.apache.derby.iapi.sql.ResultDescription.truncateColumns.

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.

Parameters
truncateFrom:int

the starting column to remove

Returns:ResultDescription

a new ResultDescription

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Write this object out

Parameters
out:ObjectOutput

write bytes here

Exceptions
IOException:
thrown on error