org.datanucleus.store.rdbms.table
Class ColumnImpl

java.lang.Object
  extended by org.datanucleus.store.rdbms.table.ColumnImpl
All Implemented Interfaces:
org.datanucleus.store.mapped.DatastoreField, Column

public class ColumnImpl
extends java.lang.Object
implements Column

Implementation of a Column in an RDBMS datastore. Contains the full definition of the column, its type, size, whether it is identity, nullable, part of the PK etc. The SQL column definition is generated here.


Field Summary
protected  org.datanucleus.metadata.ColumnMetaData columnMetaData
          ColumnMetaData for this column.
protected  java.lang.String constraints
          Optional constraints to apply to this column in its SQL specification.
protected  org.datanucleus.store.mapped.mapping.DatastoreMapping datastoreMapping
          Datastore mapping for this column.
protected  java.lang.Object defaultValue
          Default value accepted by the datastore for this column, from DatabaseMetaData.
protected  byte flags
          Operational flags, for nullability, PK, autoinc, etc.
protected  org.datanucleus.store.mapped.DatastoreIdentifier identifier
          Identifier for the column in the datastore.
protected  java.lang.String storedJavaType
          Java type that this column is storing.
protected  org.datanucleus.store.mapped.DatastoreContainerObject table
          Table containing this column in the datastore.
protected  SQLTypeInfo typeInfo
          SQL Type info for the JDBC type being stored in this column
protected  java.lang.String[] wrapperFunction
          Function wrapping the column (for example, SQRT(COLUMN)).
 
Fields inherited from interface org.datanucleus.store.rdbms.table.Column
WRAPPER_FUNCTION_INSERT, WRAPPER_FUNCTION_SELECT, WRAPPER_FUNCTION_UPDATE
 
Constructor Summary
ColumnImpl(org.datanucleus.store.mapped.DatastoreContainerObject table, java.lang.String javaType, org.datanucleus.store.mapped.DatastoreIdentifier identifier, org.datanucleus.metadata.ColumnMetaData colmd)
          Constructor.
 
Method Summary
 java.lang.String applySelectFunction(java.lang.String replacementValue)
           
 void checkDecimal()
          Checks the column definition as a decimal.
 void checkInteger()
          Checks the column definition as an integer.
 void checkPrimitive()
          Checks the column definition as a primitive.
 void checkString()
          Checks the column definition as a string.
 void copyConfigurationTo(org.datanucleus.store.mapped.DatastoreField field)
           
 boolean equals(java.lang.Object obj)
           
 org.datanucleus.metadata.ColumnMetaData getColumnMetaData()
           
 java.lang.String getConstraints()
           
 org.datanucleus.store.mapped.DatastoreContainerObject getDatastoreContainerObject()
           
 org.datanucleus.store.mapped.mapping.DatastoreMapping getDatastoreMapping()
           
 java.lang.Object getDefaultValue()
           
 org.datanucleus.store.mapped.DatastoreIdentifier getIdentifier()
           
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getJavaTypeMapping()
           
 int getJdbcType()
          Accessor for the JDBC type being used for this Column
 org.datanucleus.metadata.AbstractMemberMetaData getMemberMetaData()
           
 java.lang.String getSQLDefinition()
          Accessor for the SQL definition of this column.
 java.lang.String getStoredJavaType()
           
 org.datanucleus.store.mapped.MappedStoreManager getStoreManager()
           
 SQLTypeInfo getTypeInfo()
          Accessor for the type info for this column.
 java.lang.String getWrapperFunction(int wrapperMode)
          Gets the wrapper for parameters.
 int hashCode()
           
 void initializeColumnInfoFromDatastore(RDBMSColumnInfo ci)
          Initialize the default column value and auto increment
 boolean isDefaultable()
           
 boolean isIdentity()
           
 boolean isNullable()
           
 boolean isPrimaryKey()
           
 boolean isUnique()
           
 boolean isUnlimitedLength()
          Convenience method to check if the length is required to be unlimited (BLOB/CLOB).
 void setAsPrimaryKey()
           
 void setColumnMetaData(org.datanucleus.metadata.ColumnMetaData colmd)
           
 Column setConstraints(java.lang.String constraints)
          Mutator for the constraints of the column.
 void setDatastoreMapping(org.datanucleus.store.mapped.mapping.DatastoreMapping mapping)
           
 org.datanucleus.store.mapped.DatastoreField setDefaultable()
           
 void setDefaultValue(java.lang.Object object)
           
 void setIdentifier(org.datanucleus.store.mapped.DatastoreIdentifier identifier)
           
 org.datanucleus.store.mapped.DatastoreField setIdentity(boolean identity)
           
 org.datanucleus.store.mapped.DatastoreField setNullable()
           
 Column setTypeInfo(SQLTypeInfo typeInfo)
          Mutator for the type information of the column.
 org.datanucleus.store.mapped.DatastoreField setUnique()
           
 void setWrapperFunction(java.lang.String wrapperFunction, int wrapperMode)
          Sets a function to wrap the column.
 java.lang.String toString()
           
 void validate(RDBMSColumnInfo ci)
          Method to validate the contents of the column.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

identifier

protected org.datanucleus.store.mapped.DatastoreIdentifier identifier
Identifier for the column in the datastore.


columnMetaData

protected org.datanucleus.metadata.ColumnMetaData columnMetaData
ColumnMetaData for this column.


table

protected final org.datanucleus.store.mapped.DatastoreContainerObject table
Table containing this column in the datastore.


datastoreMapping

protected org.datanucleus.store.mapped.mapping.DatastoreMapping datastoreMapping
Datastore mapping for this column.


storedJavaType

protected final java.lang.String storedJavaType
Java type that this column is storing. (can we just get this from the mapping above ?)


typeInfo

protected SQLTypeInfo typeInfo
SQL Type info for the JDBC type being stored in this column


constraints

protected java.lang.String constraints
Optional constraints to apply to this column in its SQL specification.


flags

protected byte flags
Operational flags, for nullability, PK, autoinc, etc.


defaultValue

protected java.lang.Object defaultValue
Default value accepted by the datastore for this column, from DatabaseMetaData.


wrapperFunction

protected java.lang.String[] wrapperFunction
Function wrapping the column (for example, SQRT(COLUMN)).

Constructor Detail

ColumnImpl

public ColumnImpl(org.datanucleus.store.mapped.DatastoreContainerObject table,
                  java.lang.String javaType,
                  org.datanucleus.store.mapped.DatastoreIdentifier identifier,
                  org.datanucleus.metadata.ColumnMetaData colmd)
Constructor.

Parameters:
table - The table in the datastore that this column belongs to.
javaType - The type of data being stored in this column
identifier - The identifier of the column (in the datastore).
colmd - The ColumnMetaData for this column
Method Detail

isUnlimitedLength

public boolean isUnlimitedLength()
Description copied from interface: Column
Convenience method to check if the length is required to be unlimited (BLOB/CLOB).

Specified by:
isUnlimitedLength in interface Column
Returns:
Whether unlimited length required.

getIdentifier

public org.datanucleus.store.mapped.DatastoreIdentifier getIdentifier()
Specified by:
getIdentifier in interface org.datanucleus.store.mapped.DatastoreField

setIdentifier

public void setIdentifier(org.datanucleus.store.mapped.DatastoreIdentifier identifier)
Specified by:
setIdentifier in interface org.datanucleus.store.mapped.DatastoreField

getDatastoreContainerObject

public org.datanucleus.store.mapped.DatastoreContainerObject getDatastoreContainerObject()
Specified by:
getDatastoreContainerObject in interface org.datanucleus.store.mapped.DatastoreField

getDatastoreMapping

public org.datanucleus.store.mapped.mapping.DatastoreMapping getDatastoreMapping()
Specified by:
getDatastoreMapping in interface org.datanucleus.store.mapped.DatastoreField

setDatastoreMapping

public void setDatastoreMapping(org.datanucleus.store.mapped.mapping.DatastoreMapping mapping)
Specified by:
setDatastoreMapping in interface org.datanucleus.store.mapped.DatastoreField

getJavaTypeMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getJavaTypeMapping()
Specified by:
getJavaTypeMapping in interface org.datanucleus.store.mapped.DatastoreField

getStoredJavaType

public java.lang.String getStoredJavaType()
Specified by:
getStoredJavaType in interface org.datanucleus.store.mapped.DatastoreField

getTypeInfo

public final SQLTypeInfo getTypeInfo()
Description copied from interface: Column
Accessor for the type info for this column.

Specified by:
getTypeInfo in interface Column
Returns:
The type info

getJdbcType

public int getJdbcType()
Description copied from interface: Column
Accessor for the JDBC type being used for this Column

Specified by:
getJdbcType in interface Column
Returns:
The JDBC data type

getStoreManager

public org.datanucleus.store.mapped.MappedStoreManager getStoreManager()
Specified by:
getStoreManager in interface org.datanucleus.store.mapped.DatastoreField

getSQLDefinition

public java.lang.String getSQLDefinition()
Description copied from interface: Column
Accessor for the SQL definition of this column.

Specified by:
getSQLDefinition in interface Column
Returns:
The SQL definition of the column

initializeColumnInfoFromDatastore

public void initializeColumnInfoFromDatastore(RDBMSColumnInfo ci)
Description copied from interface: Column
Initialize the default column value and auto increment

Specified by:
initializeColumnInfoFromDatastore in interface Column
Parameters:
ci - The column information

validate

public void validate(RDBMSColumnInfo ci)
Description copied from interface: Column
Method to validate the contents of the column. This method can throw IncompatibleDataTypeException, WrongScaleException, WrongPrecisionException, IsNullableException if the data in the column is not compatible with the supplied ColumnInfo.

Specified by:
validate in interface Column
Parameters:
ci - The column information taken from the database

setTypeInfo

public final Column setTypeInfo(SQLTypeInfo typeInfo)
Description copied from interface: Column
Mutator for the type information of the column.

Specified by:
setTypeInfo in interface Column
Parameters:
typeInfo - The type info
Returns:
The column with the updated info

setConstraints

public final Column setConstraints(java.lang.String constraints)
Description copied from interface: Column
Mutator for the constraints of the column.

Specified by:
setConstraints in interface Column
Parameters:
constraints - The constraints
Returns:
The column with the updated info

setAsPrimaryKey

public final void setAsPrimaryKey()
Specified by:
setAsPrimaryKey in interface org.datanucleus.store.mapped.DatastoreField

setNullable

public final org.datanucleus.store.mapped.DatastoreField setNullable()
Specified by:
setNullable in interface org.datanucleus.store.mapped.DatastoreField

setDefaultable

public final org.datanucleus.store.mapped.DatastoreField setDefaultable()
Specified by:
setDefaultable in interface org.datanucleus.store.mapped.DatastoreField

setUnique

public final org.datanucleus.store.mapped.DatastoreField setUnique()
Specified by:
setUnique in interface org.datanucleus.store.mapped.DatastoreField

setIdentity

public org.datanucleus.store.mapped.DatastoreField setIdentity(boolean identity)
Specified by:
setIdentity in interface org.datanucleus.store.mapped.DatastoreField

isPrimaryKey

public final boolean isPrimaryKey()
Specified by:
isPrimaryKey in interface org.datanucleus.store.mapped.DatastoreField

isNullable

public final boolean isNullable()
Specified by:
isNullable in interface org.datanucleus.store.mapped.DatastoreField

isDefaultable

public final boolean isDefaultable()
Specified by:
isDefaultable in interface org.datanucleus.store.mapped.DatastoreField

isUnique

public final boolean isUnique()
Specified by:
isUnique in interface org.datanucleus.store.mapped.DatastoreField

isIdentity

public boolean isIdentity()
Specified by:
isIdentity in interface org.datanucleus.store.mapped.DatastoreField

applySelectFunction

public java.lang.String applySelectFunction(java.lang.String replacementValue)
Specified by:
applySelectFunction in interface org.datanucleus.store.mapped.DatastoreField

getDefaultValue

public java.lang.Object getDefaultValue()
Specified by:
getDefaultValue in interface org.datanucleus.store.mapped.DatastoreField

setDefaultValue

public void setDefaultValue(java.lang.Object object)
Specified by:
setDefaultValue in interface org.datanucleus.store.mapped.DatastoreField

getColumnMetaData

public final org.datanucleus.metadata.ColumnMetaData getColumnMetaData()
Specified by:
getColumnMetaData in interface org.datanucleus.store.mapped.DatastoreField

getMemberMetaData

public org.datanucleus.metadata.AbstractMemberMetaData getMemberMetaData()
Specified by:
getMemberMetaData in interface org.datanucleus.store.mapped.DatastoreField

setColumnMetaData

public void setColumnMetaData(org.datanucleus.metadata.ColumnMetaData colmd)
Specified by:
setColumnMetaData in interface org.datanucleus.store.mapped.DatastoreField

getConstraints

public java.lang.String getConstraints()
Specified by:
getConstraints in interface Column
Returns:
Returns the constraints.

checkPrimitive

public final void checkPrimitive()
                          throws org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException
Description copied from interface: Column
Checks the column definition as a primitive.

Specified by:
checkPrimitive in interface Column
Throws:
org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException

checkInteger

public final void checkInteger()
                        throws org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException
Description copied from interface: Column
Checks the column definition as an integer.

Specified by:
checkInteger in interface Column
Throws:
org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException

checkDecimal

public final void checkDecimal()
                        throws org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException
Description copied from interface: Column
Checks the column definition as a decimal.

Specified by:
checkDecimal in interface Column
Throws:
org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException

checkString

public final void checkString()
                       throws org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException
Description copied from interface: Column
Checks the column definition as a string.

Specified by:
checkString in interface Column
Throws:
org.datanucleus.store.mapped.exceptions.DatastoreFieldDefinitionException

copyConfigurationTo

public void copyConfigurationTo(org.datanucleus.store.mapped.DatastoreField field)
Specified by:
copyConfigurationTo in interface org.datanucleus.store.mapped.DatastoreField

setWrapperFunction

public void setWrapperFunction(java.lang.String wrapperFunction,
                               int wrapperMode)
Description copied from interface: Column
Sets a function to wrap the column. The wrapper function String must use "?" to be replaced later by the column name. For example
SQRT(?) generates: SQRT(COLUMN)

Specified by:
setWrapperFunction in interface Column
Parameters:
wrapperFunction - The wrapperFunction to set.
wrapperMode - whether select, insert or update

getWrapperFunction

public java.lang.String getWrapperFunction(int wrapperMode)
Description copied from interface: Column
Gets the wrapper for parameters.

Specified by:
getWrapperFunction in interface Column
Parameters:
wrapperMode - whether select, insert or update
Returns:
Returns the wrapperFunction.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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


Copyright © 2009. All Rights Reserved.