com.triactive.jdo.store.sql
Class Column

java.lang.Object
  extended bycom.triactive.jdo.store.sql.Column
All Implemented Interfaces:
java.lang.Comparable

public class Column
extends java.lang.Object
implements java.lang.Comparable

A column in a database table. Column objects are used primarily for generating the DDL for a CREATE TABLE statement or for validating against an existing column in the database.

Columns are used as backing by the various Mapping objects. Most columns are mapped 1:1 by a single ColumnMapping object. The column attributes, including SQL type, are usually set by the Mapping.

Author:
Mike Martin

Field Summary
static int FIXED_LENGTH
           
static int LENGTH_NOT_SET
           
static int MAXIMUM_LENGTH
           
static int UNLIMITED_LENGTH
           
 
Constructor Summary
Column(Table table, ColumnName name)
           
 
Method Summary
 void checkDecimal()
           
 void checkInteger()
           
 void checkPrimitive()
           
 void checkString()
           
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object obj)
           
 int getLengthType()
           
 ColumnMapping getMapping()
           
 ColumnName getName()
           
 int getPrecision()
           
 short getScale()
           
 java.lang.String getSqlDefinition()
          Returns a SQL DDL string defining this column as would be included in a CREATE TABLE statement.
 Table getTable()
           
 TypeInfo getTypeInfo()
           
 int hashCode()
           
 boolean isExactPrecision()
           
 boolean isNullable()
           
 boolean isUnique()
           
 void mapWith(ColumnMapping mapping)
           
 Column setConstraints(java.lang.String constraints)
           
 Column setExactPrecision(int precision)
           
 Column setFixedLength(int length)
           
 Column setMaximumLength(int length)
           
 Column setMinimumPrecision(int precision)
           
 Column setNullable(boolean nullable)
           
 Column setOptions(ColumnOptions co)
           
 Column setScale(short scale)
           
 Column setTypeInfo(TypeInfo typeInfo)
           
 Column setUnique(boolean unique)
           
 Column setUnlimitedLength()
           
 java.lang.String toString()
           
 void validate(ColumnInfo ci)
          Asserts that an existing database column matches, or is effectively compatible with, the column described by this Column object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LENGTH_NOT_SET

public static final int LENGTH_NOT_SET
See Also:
Constant Field Values

FIXED_LENGTH

public static final int FIXED_LENGTH
See Also:
Constant Field Values

MAXIMUM_LENGTH

public static final int MAXIMUM_LENGTH
See Also:
Constant Field Values

UNLIMITED_LENGTH

public static final int UNLIMITED_LENGTH
See Also:
Constant Field Values
Constructor Detail

Column

public Column(Table table,
              ColumnName name)
Method Detail

getTable

public Table getTable()

getName

public ColumnName getName()

getMapping

public ColumnMapping getMapping()

mapWith

public void mapWith(ColumnMapping mapping)

getSqlDefinition

public java.lang.String getSqlDefinition()
Returns a SQL DDL string defining this column as would be included in a CREATE TABLE statement.

Returns:
The SQL DDL defining this column.

validate

public void validate(ColumnInfo ci)
Asserts that an existing database column matches, or is effectively compatible with, the column described by this Column object.

Parameters:
ci - Metadata on the existing column obtained from JDBC.
Throws:
SchemaValidationException - If the existing column is not compatible with this Column object.

setOptions

public Column setOptions(ColumnOptions co)

setTypeInfo

public final Column setTypeInfo(TypeInfo typeInfo)

setConstraints

public final Column setConstraints(java.lang.String constraints)

setFixedLength

public final Column setFixedLength(int length)

setMaximumLength

public final Column setMaximumLength(int length)

setUnlimitedLength

public final Column setUnlimitedLength()

setExactPrecision

public final Column setExactPrecision(int precision)

setMinimumPrecision

public final Column setMinimumPrecision(int precision)

setScale

public final Column setScale(short scale)

setNullable

public final Column setNullable(boolean nullable)

setUnique

public final Column setUnique(boolean unique)

getTypeInfo

public final TypeInfo getTypeInfo()

getPrecision

public final int getPrecision()

getScale

public final short getScale()

getLengthType

public int getLengthType()

isExactPrecision

public final boolean isExactPrecision()

isNullable

public final boolean isNullable()

isUnique

public final boolean isUnique()

checkPrimitive

public final void checkPrimitive()
                          throws ColumnDefinitionException
Throws:
ColumnDefinitionException

checkInteger

public final void checkInteger()
                        throws ColumnDefinitionException
Throws:
ColumnDefinitionException

checkDecimal

public final void checkDecimal()
                        throws ColumnDefinitionException
Throws:
ColumnDefinitionException

checkString

public final void checkString()
                       throws ColumnDefinitionException
Throws:
ColumnDefinitionException

hashCode

public int hashCode()

equals

public boolean equals(java.lang.Object obj)

compareTo

public int compareTo(java.lang.Object obj)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. Columns are ordered by their name.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toString

public java.lang.String toString()


Copyright 2001-2007 The TJDO Project All Rights Reserved.