org.apache.empire.db
Class DBColumn

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
All Implemented Interfaces:
ErrorInfo, 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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject
ErrorObject.ObjectErrorInfo
 
Field Summary
protected  java.lang.String comment
           
static java.lang.String DBCOLATTR_MANDATORY
          Mandatory column (Boolean)
static java.lang.String DBCOLATTR_MAXVALUE
          Maximum value (Integer)
static java.lang.String DBCOLATTR_MINVALUE
          Minimum value (Integer)
static java.lang.String DBCOLATTR_READONLY
          Read only column (Boolean)
protected  java.lang.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, log
 
Constructor Summary
protected DBColumn(DBRowSet rowset, java.lang.String name)
          Constructs a DBColumn object and set the specified parameters to this object.
 
Method Summary
 void addReferencedColumns(java.util.Set<DBColumn> list)
          Internal function to obtain all DBColumnExpr-objects used by this expression.
 void addSQL(java.lang.StringBuilder buf, long context)
          Adds the colunm name to the SQL-Command.
abstract  org.w3c.dom.Element addXml(org.w3c.dom.Element parent, long flags)
          Add a description of this column with relevant metadata to the supplied parent XML Element.
abstract  boolean checkValue(java.lang.Object value)
           
 java.lang.Object getAttribute(java.lang.String name)
          Returns the value of a column attribute.
 java.lang.String getComment()
          Returns a comment describing the column in the data scheme.
 DBDatabase getDatabase()
          Returns the database object to which this object belongs to.
 java.lang.String getFullName()
          Returns the full qualified column name.
 java.lang.String getName()
          Returns the column name.
 Options getOptions()
          Returns the list of options for this column containing all possbile 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
abstract  boolean isReadOnly()
          Returns true if the column is read-only.
abstract  boolean isRequired()
          Returns true if the column is required.
 void setComment(java.lang.String comment)
          Sets a comment describing the current column.
 DBSetExpr to(java.lang.Object value)
          Creates and returns a new DBSetExpr object.
 java.lang.String toString()
          Override the toString method.
 
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 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, getDataType, getSourceColumn, getTitle
 

Field Detail

DBCOLATTR_MANDATORY

public static final java.lang.String DBCOLATTR_MANDATORY
Mandatory column (Boolean)

See Also:
Constant Field Values

DBCOLATTR_READONLY

public static final java.lang.String DBCOLATTR_READONLY
Read only column (Boolean)

See Also:
Constant Field Values

DBCOLATTR_MINVALUE

public static final java.lang.String DBCOLATTR_MINVALUE
Minimum value (Integer)

See Also:
Constant Field Values

DBCOLATTR_MAXVALUE

public static final java.lang.String DBCOLATTR_MAXVALUE
Maximum value (Integer)

See Also:
Constant Field Values

rowset

protected final DBRowSet rowset

name

protected final java.lang.String name

comment

protected java.lang.String comment
Constructor Detail

DBColumn

protected DBColumn(DBRowSet rowset,
                   java.lang.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

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

checkValue

public abstract boolean checkValue(java.lang.Object value)

addXml

public abstract org.w3c.dom.Element addXml(org.w3c.dom.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 - currenly 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(java.util.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(java.lang.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 java.lang.String getName()
Returns the column name.

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

getFullName

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

Returns:
the full qualified column name

getAttribute

public java.lang.Object getAttribute(java.lang.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 possbile 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(java.lang.Object value)
Creates and returns a new DBSetExpr object.

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

toString

public java.lang.String toString()
Override the toString method.

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

getComment

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

Returns:
Returns the comment.

setComment

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

Parameters:
comment - the column comment


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