org.apache.empire.db
Class DBColumn

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
All Implemented Interfaces:
Serializable, Column, ColumnExpr
Direct Known Subclasses:
DBCommandExpr.DBCmdColumn, DBQuery.DBQueryColumn, DBTableColumn, DBView.DBViewColumn

public abstract class DBColumn
extends DBColumnExpr
implements Column

This is the base class for all database columns that have a physical representation. i.e. either table or view columns (DBTableColumn oder DBViewColumn)

The column object describes a database column and thus provides metadata. Other non data model specific metadata may be added through attributes.

See Also:
DBTableColumn, DBView.DBViewColumn, Serialized Form

Field Summary
protected  String comment
           
static String DBCOLATTR_MANDATORY
          Mandatory column (Boolean)
static String DBCOLATTR_MAXVALUE
          Maximum value (Integer)
static String DBCOLATTR_MINVALUE
          Minimum value (Integer)
static String DBCOLATTR_READONLY
          Read only column (Boolean)
static String DBCOLATTR_SINGLEBYTECHARS
          Read only column (Boolean)
protected  String name
           
protected  DBRowSet 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
protected DBColumn(DBRowSet rowset, String name)
          Constructs a DBColumn object and set the specified parameters to this object.
 
Method Summary
 void addReferencedColumns(Set<DBColumn> list)
          Internal function to obtain all DBColumnExpr-objects used by this expression.
 void addSQL(StringBuilder buf, long context)
          Adds the colunm name to the SQL-Command.
abstract  Element addXml(Element parent, long flags)
          Add a description of this column with relevant metadata to the supplied parent XML Element.
 void checkValue(Object value)
          Deprecated. use validate() instead
 boolean equals(Object other)
           
static DBColumn findById(String columnId)
          returns a rowset by its identifier
 Object getAttribute(String name)
          Returns the value of a column attribute.
 String getComment()
          Returns a comment describing the column in the data scheme.
 DBDatabase getDatabase()
          Returns the database object to which this object belongs to.
 String getFullName()
          Returns the full qualified column name.
 String getId()
          Gets an identifier for this RowSet Object
 String getName()
          Returns the column name.
 Options getOptions()
          Returns the list of options for this column containing all possible field values.
 DBRowSet getRowSet()
          Returns DBTable, DBQuery or DBView object.
abstract  double getSize()
          Returns the size of the column.
 DBColumn getUpdateColumn()
          Returns this object.
 boolean isAggregate()
          Always returns false since DBColumns cannot be aggregates.
abstract  boolean isAutoGenerated()
          Returns true if column is a columns value is an automatically generated value
 boolean isDateColumn()
          Returns true if column the column is a date based column (date or datetime)
 boolean isLOBColumn()
          Returns true if column the column is a large object (LOB) column
 boolean isNumericColumn()
          Returns true if column the column is a numeric column (integer, decimal, float)
abstract  boolean isReadOnly()
          Returns true if the column is read-only.
abstract  boolean isRequired()
          Returns true if the column is required.
 boolean isTextColumn()
          Returns true if column the column is a character based column (char, text or clob)
 void setComment(String comment)
          Sets a comment describing the current column.
 DBSetExpr to(Object value)
          Creates and returns a new DBSetExpr object.
 String toString()
          Override the toString method.
abstract  void validate(Object value)
          Checks if the given value is a valid value for this column If not, an exception is thrown
 
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, getDataType, 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, getDataType, getSourceColumn, getTitle
 

Field Detail

DBCOLATTR_MANDATORY

public static final String DBCOLATTR_MANDATORY
Mandatory column (Boolean)

See Also:
Constant Field Values

DBCOLATTR_READONLY

public static final String DBCOLATTR_READONLY
Read only column (Boolean)

See Also:
Constant Field Values

DBCOLATTR_MINVALUE

public static final String DBCOLATTR_MINVALUE
Minimum value (Integer)

See Also:
Constant Field Values

DBCOLATTR_MAXVALUE

public static final String DBCOLATTR_MAXVALUE
Maximum value (Integer)

See Also:
Constant Field Values

DBCOLATTR_SINGLEBYTECHARS

public static final String DBCOLATTR_SINGLEBYTECHARS
Read only column (Boolean)

See Also:
Constant Field Values

rowset

protected final transient DBRowSet rowset

name

protected final String name

comment

protected String comment
Constructor Detail

DBColumn

protected DBColumn(DBRowSet rowset,
                   String name)
Constructs a DBColumn object and set the specified parameters to this object.

Parameters:
rowset - the rowset (i.e. Table or View) that this column belongs to
name - the column name
Method Detail

getId

public String getId()
Gets an identifier for this RowSet Object

Returns:
the rowset identifier

findById

public static DBColumn findById(String columnId)
returns a rowset by its identifier

Parameters:
rowsetId - the id of the rowset
Returns:
the rowset object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

getSize

public abstract double getSize()
Returns the size of the column.

Specified by:
getSize in interface Column
Returns:
Returns the size of the column

isRequired

public abstract boolean isRequired()
Returns true if the column is required.

Specified by:
isRequired in interface Column
Returns:
Returns true if the column is required

isAutoGenerated

public abstract boolean isAutoGenerated()
Returns true if column is a columns value is an automatically generated value

Specified by:
isAutoGenerated in interface Column
Returns:
true if column is auto-generated

isReadOnly

public abstract boolean isReadOnly()
Returns true if the column is read-only.

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

validate

public abstract void validate(Object value)
Checks if the given value is a valid value for this column If not, an exception is thrown

Specified by:
validate in interface Column

checkValue

@Deprecated
public final void checkValue(Object value)
Deprecated. use validate() instead


isTextColumn

public boolean isTextColumn()
Returns true if column the column is a character based column (char, text or clob)

Returns:
true if column is a character based column

isNumericColumn

public boolean isNumericColumn()
Returns true if column the column is a numeric column (integer, decimal, float)

Returns:
true if column is a numeric column

isDateColumn

public boolean isDateColumn()
Returns true if column the column is a date based column (date or datetime)

Returns:
true if column is a date based column

isLOBColumn

public boolean isLOBColumn()
Returns true if column the column is a large object (LOB) column

Returns:
true if column is a large object column

addXml

public abstract Element addXml(Element parent,
                               long flags)
Description copied from class: DBColumnExpr
Add a description of this column with relevant metadata to the supplied parent XML Element.

Specified by:
addXml in class DBColumnExpr
Parameters:
parent - the parent element to which to append the column description
flags - currently not used
Returns:
the newly created child element

getDatabase

public DBDatabase getDatabase()
Description copied from class: DBObject
Returns the database object to which this object belongs to. For the database object itself this function will return the this pointer.

Specified by:
getDatabase in class DBObject
Returns:
the current DBDatabase object

addReferencedColumns

public void addReferencedColumns(Set<DBColumn> list)
Description copied from class: DBExpr
Internal function to obtain all DBColumnExpr-objects used by this expression.

Specified by:
addReferencedColumns in class DBExpr
Parameters:
list - list to which all used column expressions must be added
See Also:
DBExpr.addReferencedColumns(Set)

addSQL

public void addSQL(StringBuilder buf,
                   long context)
Adds the colunm name to the SQL-Command.
This can be either a qualified or unqualified name depending on the context.

Specified by:
addSQL in class DBExpr
Parameters:
buf - the SQL statment
context - the current SQL-Command context

getUpdateColumn

public DBColumn getUpdateColumn()
Returns this object.

Specified by:
getUpdateColumn in class DBColumnExpr
Returns:
this object

isAggregate

public boolean isAggregate()
Always returns false since DBColumns cannot be aggregates.

Specified by:
isAggregate in class DBColumnExpr
Returns:
false

getRowSet

public DBRowSet getRowSet()
Returns DBTable, DBQuery or DBView object.

Returns:
the DBTable, DBQuery or DBView object

getName

public String getName()
Returns the column name.

Specified by:
getName in interface ColumnExpr
Specified by:
getName in class DBColumnExpr
Returns:
the column name

getFullName

public String getFullName()
Returns the full qualified column name.

Returns:
the full qualified column name

getAttribute

public Object getAttribute(String name)
Description copied from class: DBColumnExpr
Returns the value of a column attribute. Column attributes are used to provide metadata for a column.

Specified by:
getAttribute in interface ColumnExpr
Overrides:
getAttribute in class DBColumnExpr
Parameters:
name - the attribute name
Returns:
value of the attribute if it exists or null otherwise
See Also:
DBColumnExpr.getAttribute(String)

getOptions

public Options getOptions()
Description copied from class: DBColumnExpr
Returns the list of options for this column containing all possible field values.

Specified by:
getOptions in interface ColumnExpr
Overrides:
getOptions in class DBColumnExpr
Returns:
the list of options
See Also:
DBColumnExpr.getOptions()

to

public DBSetExpr to(Object value)
Creates and returns a new DBSetExpr object.

Parameters:
value - the Object value
Returns:
the new DBSetExpr object
See Also:
DBSetExpr

toString

public String toString()
Override the toString method.

Overrides:
toString in class Object
Returns:
the table name and the column name (e.g. CUSTOMER.ID)

getComment

public String getComment()
Returns a comment describing the column in the data scheme.

Returns:
Returns the comment.

setComment

public void setComment(String comment)
Sets a comment describing the current column.

Parameters:
comment - the column comment


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