org.apache.empire.db
Class DBTableColumn

java.lang.Object
  extended by org.apache.empire.db.DBObject
      extended by org.apache.empire.db.DBExpr
          extended by org.apache.empire.db.DBColumnExpr
              extended by org.apache.empire.db.DBColumn
                  extended by org.apache.empire.db.DBTableColumn
All Implemented Interfaces:
Serializable, Column, ColumnExpr

public class DBTableColumn
extends DBColumn

This class represent one column of a table. It contains all properties of this columns (e.g. the column width).

See Also:
Serialized Form

Field Summary
protected  DataMode dataMode
           
protected  Object defValue
           
protected  double size
           
protected  DataType type
           
 
Fields inherited from class org.apache.empire.db.DBColumn
comment, DBCOLATTR_MANDATORY, DBCOLATTR_MAXVALUE, DBCOLATTR_MINVALUE, DBCOLATTR_READONLY, DBCOLATTR_SINGLEBYTECHARS, name, rowset
 
Fields inherited from class org.apache.empire.db.DBColumnExpr
attributes, beanPropertyName, DBCOLATTR_TITLE, DBCOLATTR_TYPE, options
 
Fields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESES, CTX_VALUE
 
Constructor Summary
  DBTableColumn(DBTable table, DataType type, String name, double size, DataMode dataMode, Object defValue)
          Constructs a DBTableColumn object set the specified parameters to this object.
protected DBTableColumn(DBTable newTable, DBTableColumn other)
          Clone Constructor - use clone()
 
Method Summary
 Element addXml(Element parent, long flags)
          Sets field elements, default attributes and all options to the specified Element object (XML tag).
 DataType getDataType()
          Returns the data type.
 Object getDefaultValue()
          Returns the default column value.
 Object getRecordDefaultValue(Connection conn)
          Returns the default column value.
 String getSequenceName()
          Gets the sequence name for this table's sequence (if it has one) This is derived form the default value or auto generated if no default value is set
 double getSize()
          Gets the the column width.
 boolean isAutoGenerated()
          Returns true if column is a numeric sequence or otherwise generated value
 boolean isReadOnly()
          Checks whether the column is read only.
 boolean isRequired()
          Returns true if column is mandatory.
 boolean isSingleByteChars()
          Returns true if column the column is a single byte text or character column or false otherwise
 DBRelation.DBReference referenceOn(DBTableColumn target)
          Creates a foreign key relation for this column.
 void setDefaultValue(Object defValue)
          Sets the default column value.
 void setReadOnly(boolean readOnly)
          Sets the read only attribute of the column.
 void setRequired(boolean required)
          Changes the required property of the table column
Use for dynamic data model changes only.
 void setSingleByteChars(boolean singleByteChars)
          sets whether this column is a single byte character or text column
 void setSize(double size)
          Changes the size of the table column
Use for dynamic data model changes only.
 void validate(Object value)
          Checks whether the supplied value is valid for this column.
 
Methods inherited from class org.apache.empire.db.DBColumn
addReferencedColumns, addSQL, checkValue, equals, findById, getAttribute, getComment, getDatabase, getFullName, getId, getName, getOptions, getRowSet, getUpdateColumn, isAggregate, isDateColumn, isLOBColumn, isNumericColumn, isTextColumn, setComment, to, toString
 
Methods inherited from class org.apache.empire.db.DBColumnExpr
abs, append, as, as, asc, avg, cmp, coalesce, convertTo, convertTo, count, countDistinct, day, decode, decode, decode, decode, decode, decode, desc, detectDataType, divideBy, getBeanPropertyName, getControlType, getExprFromPhrase, getExprFromPhrase, getSourceColumn, getTitle, in, indexOf, indexOf, indexOf, is, isBetween, isGreaterThan, isLessOrEqual, isMoreOrEqual, isNot, isNotBetween, isSmallerThan, length, like, like, likeLower, likeUpper, lower, max, min, minus, minus, month, multiplyWith, notIn, notLike, nvl, parenthesis, plus, plus, replace, reverse, round, setAttribute, setBeanPropertyName, setControlType, setOptions, setTitle, substring, substring, substring, substring, substring, substring, sum, toChar, toChar, trim, trimLeft, trimRight, trunc, upper, when, year
 
Methods inherited from class org.apache.empire.db.DBExpr
getObjectValue, getValueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.empire.data.ColumnExpr
getBeanPropertyName, getControlType, getSourceColumn, getTitle
 

Field Detail

type

protected DataType type

size

protected double size

dataMode

protected DataMode dataMode

defValue

protected Object defValue
Constructor Detail

DBTableColumn

public DBTableColumn(DBTable table,
                     DataType type,
                     String name,
                     double size,
                     DataMode dataMode,
                     Object defValue)
Constructs a DBTableColumn object set the specified parameters to this object.

Parameters:
table - the table object to add the column to, set to null if you don't want it added to a table
type - the type of the column e.g. integer, text, date
name - the column name
size - the column width
dataMode - determines whether this column is optional, required or auto-generated
defValue - the object value

DBTableColumn

protected DBTableColumn(DBTable newTable,
                        DBTableColumn other)
Clone Constructor - use clone()

Method Detail

getDefaultValue

public Object getDefaultValue()
Returns the default column value. For columns of type DBDataType.AUTOINC this is assumed to be the name of a sequence

Returns:
the default column value

setDefaultValue

public void setDefaultValue(Object defValue)
Sets the default column value.

Parameters:
defValue - the default column value

getRecordDefaultValue

public Object getRecordDefaultValue(Connection conn)
Returns the default column value. Unlike getDefaultValue this function is used when creating or adding records. If the column value is DBDataType AUTOIN this function will return a new sequence value for this record

Parameters:
conn - a valid database connection
Returns:
the default column value

getDataType

public DataType getDataType()
Returns the data type.

Specified by:
getDataType in interface ColumnExpr
Specified by:
getDataType in class DBColumnExpr
Returns:
the data type
See Also:
DataType

getSize

public double getSize()
Gets the the column width.

Specified by:
getSize in interface Column
Specified by:
getSize in class DBColumn
Returns:
the column width

setSize

public void setSize(double size)
Changes the size of the table column
Use for dynamic data model changes only.

Parameters:
size - the new column size

isRequired

public boolean isRequired()
Returns true if column is mandatory. Only for the graphic presentation.

Specified by:
isRequired in interface Column
Specified by:
isRequired in class DBColumn
Returns:
true if column is mandatory

isAutoGenerated

public boolean isAutoGenerated()
Returns true if column is a numeric sequence or otherwise generated value

Specified by:
isAutoGenerated in interface Column
Specified by:
isAutoGenerated in class DBColumn
Returns:
true if column is auto increment

isSingleByteChars

public boolean isSingleByteChars()
Returns true if column the column is a single byte text or character column or false otherwise

Returns:
true if column is a single byte character based column

setSingleByteChars

public void setSingleByteChars(boolean singleByteChars)
sets whether this column is a single byte character or text column


setRequired

public void setRequired(boolean required)
Changes the required property of the table column
Use for dynamic data model changes only.

Parameters:
required - true if the column is required or false otherwise

isReadOnly

public boolean isReadOnly()
Checks whether the column is read only.

Specified by:
isReadOnly in interface Column
Specified by:
isReadOnly in class DBColumn
Returns:
true if the column is read only

setReadOnly

public void setReadOnly(boolean readOnly)
Sets the read only attribute of the column.

Parameters:
readOnly - true if the column should be read only or false otherwise

validate

public void validate(Object value)
Checks whether the supplied value is valid for this column. If the type of the value supplied does not match the columns data type the value will be checked for compatibility.

Specified by:
validate in interface Column
Specified by:
validate in class DBColumn
Parameters:
value - the checked to check for validity

referenceOn

public DBRelation.DBReference referenceOn(DBTableColumn target)
Creates a foreign key relation for this column.

Parameters:
target - the referenced primary key column
Returns:
the reference object

addXml

public Element addXml(Element parent,
                      long flags)
Sets field elements, default attributes and all options to the specified Element object (XML tag).

Specified by:
addXml in class DBColumn
Parameters:
parent - the parent object
flags - a long value
Returns:
the work up Element object

getSequenceName

public String getSequenceName()
Gets the sequence name for this table's sequence (if it has one) This is derived form the default value or auto generated if no default value is set

Returns:
the sequence name


Copyright © 2008-2012 Apache Software Foundation. All Rights Reserved.