|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.afcs.warts.db.ColumnDescription
The ColumnDescription class stores information about a
specific column in a database table. A TableDescription
contains an
list of ColumnDescription instances, one for each column.
LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.
Constructor Summary | |
ColumnDescription(java.lang.String name,
int sqlType,
java.lang.String sqlTypeName,
int size,
int decimalDigits,
boolean isNullable,
java.lang.String defaultValue)
Initialises a new instance with the specified information. |
Method Summary | |
void |
bindValue(java.sql.PreparedStatement statement,
int variableIndex,
java.lang.Object value)
This method is responsible for binding the specified value to the specified index in the specified statement. |
java.lang.String |
describeFirstEquivalenceIssue(ColumnDescription anotherColumnDescription)
Returns a text description of the first reason that can be found for this column not being equivalent to the specified column. |
boolean |
equals(java.lang.Object otherObj)
Returns true if the specified object is a ColumnDescription instance that has an identical configuration to this one, where all fields other than column size are considered. |
int |
getDecimalDigits()
Returns the number of digits allowed on the right of the decimal point in a numeric column. |
java.lang.String |
getDefaultValue()
Returns the default value for the column, if one exists. |
java.lang.String |
getName()
Returns the name of the column. |
int |
getSize()
Returns the total width of the data that can be stored in this column for numeric and character data types (excluding CLOBs). |
int |
getSqlType()
Returns the constant from java.sql.Types that was specified
as the column type at initialisation. |
java.lang.String |
getSqlTypeName()
Returns the data type name specified at initialisation, which is obtained from the column metadata. |
int |
hashCode()
Returns a hashcode based on the configuration of this instance. |
protected boolean |
initializeDataHandler(TableDescription tableDescription)
This is used during the initialization phase of an TableDescription
instance to initialize a data handler for each column. |
boolean |
isCharacterData()
Returns true if the current column contains character data, and should therefore be loaded when performing non-ascii character scanning on a table. |
boolean |
isNullable()
Returns true if the column allows nulls. |
java.lang.Object |
loadValue(java.sql.ResultSet resultSet,
int columnIndex)
This method is responsible for constructing and returning an object from the specified column of the specified result set, delegating the operation to a datatype specific handler. |
void |
postProcessBind(java.sql.Connection connection,
java.util.List primaryKeyValues,
java.lang.Object value)
This method is called when requiresBindPostProcessing() returns true
to finish writing data to the database for which simple binding isn't
sufficient. |
java.lang.String |
printValue(java.lang.Object value)
This method returns a string containing a representation of the specified value appropriate for use in a SQL script. |
boolean |
requiresBindPostProcessing()
Returns true if writing of the data contained in this column requires additional post-processing of the bind step. |
boolean |
requiresStreamedLoading()
Returns true if the loading of this data requires streaming outside the standard result set, which is true for LOB data. |
java.lang.String |
toString()
Returns a text description of the current instance that can be used for debugging purposes. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ColumnDescription(java.lang.String name, int sqlType, java.lang.String sqlTypeName, int size, int decimalDigits, boolean isNullable, java.lang.String defaultValue)
name
- The name of the column.sqlType
- The type of data stored in the column, which will be one
of the constants from java.sql.Types
, and
is obtained by querying the table metadata.sqlTypeName
- The name of the datatype stored in the column. This is
database-specific, and is obtained by querying the table
metadata.size
- The size of the column.decimalDigits
- The number of decimal digits (precision) of the
column.isNullable
- Whether the column takes null values.defaultValue
- The default value of the column, if specified.
java.lang.NullPointerException
- If name or sqlTypeName is null.Method Detail |
public java.lang.String getName()
public int getSqlType()
java.sql.Types
that was specified
as the column type at initialisation. This type is always obtained from
the column metadata.
public java.lang.String getSqlTypeName()
public int getSize()
public int getDecimalDigits()
public boolean equals(java.lang.Object otherObj)
Column size is not considered because of a bug in the Oracle JDBC drivers that prevents the correct column size from being returned for character columns with character length semantics.
otherObj
- The object to compare this instance to.
public java.lang.String describeFirstEquivalenceIssue(ColumnDescription anotherColumnDescription)
equals(java.lang.Object)
returns false for the same column, this is useful for finding out why. It
will return null if the columns are equal.
anotherColumnDescription
- The other column to compare the current
instance to.
java.lang.NullPointerException
- If anotherColumnDescription is null.public int hashCode()
Column size is not considered because of a bug in the Oracle JDBC drivers that prevents the correct column size from being returned for character columns with character length semantics.
public boolean isCharacterData()
loadValue(java.sql.ResultSet, int)
for character data
columns will always be of type
DataHighBitAnalysis
.
public boolean isNullable()
public java.lang.String getDefaultValue()
public void bindValue(java.sql.PreparedStatement statement, int variableIndex, java.lang.Object value) throws java.sql.SQLException
statement
- The statement to bind the value in.variableIndex
- The index of the variable to bind.value
- The value to bind to the statement. This value should
be of the appropriate type for the data handler subclass,
or null.
java.sql.SQLException
- If a SQL error occurs during binding.public java.lang.Object loadValue(java.sql.ResultSet resultSet, int columnIndex) throws java.sql.SQLException
resultSet
- The result set to load data from.columnIndex
- The index of the column to load data from.
java.sql.SQLException
- If a SQL exception occurs while loading data.public void postProcessBind(java.sql.Connection connection, java.util.List primaryKeyValues, java.lang.Object value) throws java.sql.SQLException
requiresBindPostProcessing()
returns true
to finish writing data to the database for which simple binding isn't
sufficient. This is the case with LOB data, for example.
connection
- The database connection to use.primaryKeyValues
- The primary key values identifying the row that
the specified value has to be written to.value
- The value to write to the database.
java.sql.SQLException
- If a SQL error occurs during binding.public java.lang.String printValue(java.lang.Object value)
value
- The object value to print.
public boolean requiresBindPostProcessing()
postProcessBind(java.sql.Connection, java.util.List, java.lang.Object)
will be called after the initial INSERT or UDPATE
statement that handled the bind step is executed.
public boolean requiresStreamedLoading()
public java.lang.String toString()
protected boolean initializeDataHandler(TableDescription tableDescription)
TableDescription
instance to initialize a data handler for each column. If no suitable
data handler can be found for this column by
DataHandlerFactory
,
then true is returned to indicate that the "null" handler is being used.
The null handler is, of course, not much use for primary key columns.
tableDescription
- The table containing the column.
java.lang.NullPointerException
- If tableDescription is null.
java.lang.IllegalArgumentException
- If tableDescription does not contain
this column.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |