org.apache.empire.db
Class DBTableColumn

java.lang.Object
  extended by org.apache.empire.commons.ErrorObject
      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:
ErrorInfo, 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).


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject
ErrorObject.ObjectErrorInfo
 
Field Summary
protected  java.lang.Object defValue
           
protected  boolean required
           
protected  double size
           
protected  DataType type
           
 
Fields inherited from class org.apache.empire.db.DBColumn
comment, DBCOLATTR_MANDATORY, DBCOLATTR_MAXVALUE, DBCOLATTR_MINVALUE, DBCOLATTR_READONLY, 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, log
 
Constructor Summary
  DBTableColumn(DBTable table, DataType type, java.lang.String name, double size, boolean required, java.lang.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
 org.w3c.dom.Element addXml(org.w3c.dom.Element parent, long flags)
          Sets field elements, default attributes and all otions to the specified Element object (XML tag).
 boolean checkValue(java.lang.Object value)
          Checks whether the supplied value is valid for this column.
 DataType getDataType()
          Returns the data type.
 java.lang.Object getDefaultValue()
          Returns the default column value.
 java.lang.Object getRecordDefaultValue(java.sql.Connection conn)
          Returns the default column value.
 double getSize()
          Gets the the column width.
 boolean isReadOnly()
          Checks whether the column is read only.
 boolean isRequired()
          Returns true if column is mandatory.
 DBRelation.DBReference referenceOn(DBTableColumn target)
          Creates a foreign key relation for this column.
 void setDefaultValue(java.lang.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 requied property of the table column
Use for dynamic data model changes only.
 void setSize(double size)
          Changes the size of the table column
Use for dynamic data model changes only.
 
Methods inherited from class org.apache.empire.db.DBColumn
addReferencedColumns, addSQL, getAttribute, getComment, getDatabase, getFullName, getName, getOptions, getRowSet, getUpdateColumn, isAggregate, setComment, to, toString
 
Methods inherited from class org.apache.empire.db.DBColumnExpr
abs, append, as, as, avg, cmp, coalesce, convertTo, convertTo, count, countDistinct, day, decode, decode, decode, decode, decode, decode, detectDataType, divideBy, getBeanPropertyName, getControlType, 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 org.apache.empire.db.DBObject
error, error
 
Methods inherited from class org.apache.empire.commons.ErrorObject
clearError, clearErrorInfo, error, error, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success
 
Methods inherited from class java.lang.Object
clone, equals, 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

required

protected boolean required

defValue

protected java.lang.Object defValue
Constructor Detail

DBTableColumn

public DBTableColumn(DBTable table,
                     DataType type,
                     java.lang.String name,
                     double size,
                     boolean required,
                     java.lang.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
required - true if not null column
defValue - the object value

DBTableColumn

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

Method Detail

getDefaultValue

public java.lang.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(java.lang.Object defValue)
Sets the default column value.

Parameters:
defValue - the default column value

getRecordDefaultValue

public java.lang.Object getRecordDefaultValue(java.sql.Connection conn)
Returns the default column value. Unklike 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

setRequired

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

Parameters:
required - true if the column is requried 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

checkValue

public boolean checkValue(java.lang.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:
checkValue in class DBColumn
Parameters:
value - the checked to check for validity
Returns:
true if the value is valid or false otherwise.

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 org.w3c.dom.Element addXml(org.w3c.dom.Element parent,
                                  long flags)
Sets field elements, default attributes and all otions 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


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