org.apache.empire.db
Class DBColumnExpr

java.lang.Object
  extended by org.apache.empire.db.DBObject
      extended by org.apache.empire.db.DBExpr
          extended by org.apache.empire.db.DBColumnExpr
All Implemented Interfaces:
Serializable, ColumnExpr
Direct Known Subclasses:
DBAbstractFuncExpr, DBAliasExpr, DBCalcExpr, DBCaseExpr, DBColumn, DBConcatExpr, DBCountExpr, DBValueExpr, OracleRowNumExpr

public abstract class DBColumnExpr
extends DBExpr
implements ColumnExpr

This class is the base class for all expressions that represent a single value. It provides a set of factory functions for SQL functions.

See Also:
Serialized Form

Field Summary
protected  Attributes attributes
           
protected  String beanPropertyName
           
static String DBCOLATTR_TITLE
           
static String DBCOLATTR_TYPE
           
protected  Options 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
DBColumnExpr()
           
 
Method Summary
 DBColumnExpr abs()
          Creates and returns a sql-expression for the absolute abs() function.
abstract  Element addXml(Element parent, long flags)
          Add a description of this column with relevant metadata to the supplied parent XML Element.
 DBColumnExpr append(Object value)
          Creates a new DBConcatExpr object with the specified value.
 DBColumnExpr as(DBColumn column)
          creates a new DBAliasExpr which renames the current expression to the name of the supplied column.
 DBColumnExpr as(String alias)
          creates a new DBAliasExpr which renames the current expression to the supplied name.
 DBOrderByExpr asc()
          creates a new DBOrderByExpr for ascending order
 DBColumnExpr avg()
          Creates and returns an aggregation function object which returns the average value for the current expression over a group of rows.
 DBCompareColExpr cmp(DBCmpType op, Object value)
          Creates and returns a new comparison object for the given comparison operator and value.
 DBColumnExpr coalesce(Object nullValue)
          Creates a sql-expression for the nvl() or coalesce() function.
 DBColumnExpr convertTo(DataType dataType)
          Creates and returns a new DBFuncExpr object that will convert the current column to the destination data type specified.
 DBColumnExpr convertTo(DataType dataType, Object format)
          Creates a new DBFuncExpr object that will convert the current column to the destination data type specified.
 DBColumnExpr count()
          Creates and returns an expression for the SQL "count()" function which returns the number of rows in the result set.
 DBColumnExpr countDistinct()
          Creates and returns an expression for the SQL "count()" function which returns the number of unique values in the result set.
 DBColumnExpr day()
          Creates and returns an function object that calculates the day of a date value.
 DBColumnExpr decode(Map<?,?> valueMap, Object otherwise)
          Creates and returns a sql-expression that compares the current column expression with a list of values and returns the corresponding alternative value.
 DBColumnExpr decode(Object key1, Object value1, Object otherwise)
           
 DBColumnExpr decode(Object key1, Object value1, Object key2, Object value2, Object otherwise)
           
 DBColumnExpr decode(Object key1, Object value1, Object key2, Object value2, Object key3, Object value3, Object otherwise)
           
 DBColumnExpr decode(Options options)
           
 DBColumnExpr decode(Options options, Object otherwise)
           
 DBOrderByExpr desc()
          creates a new DBOrderByExpr for descending order
protected  DataType detectDataType(Object value)
          Detects the DataType of a given value.
 DBCalcExpr divideBy(Object value)
          Creates and returns a new calculation object for the SQL "/" (divide) operator.
 Object getAttribute(String name)
          Returns the value of a column attribute.
 String getBeanPropertyName()
          Gets the Java bean property name for this column i.e.
 String getControlType()
          Returns the column control type.
abstract  DataType getDataType()
          Returns the data type of this column expression.
protected  DBColumnExpr getExprFromPhrase(int phrase, Object[] params, DBColumn updateColumn, boolean isAggregate)
           
protected  DBColumnExpr getExprFromPhrase(int phrase, Object[] params, DBColumn updateColumn, boolean isAggregate, DataType dataType)
          Creates a new DBFuncExpr from a given SQL-PRHASE and optional additional parameters.
abstract  String getName()
          Returns the column name for this column expression.
 Options getOptions()
          Returns the list of options for this column containing all possible field values.
 Column getSourceColumn()
          Returns the source column.
 String getTitle()
          Returns the title attribute.
abstract  DBColumn getUpdateColumn()
          Returns the underlying physical column which may be used for updates.
 DBCompareColExpr in(Object value)
          Creates and returns a new comparison object for the SQL "in" operator.
 DBColumnExpr indexOf(Object str)
          Creates and returns a sql-expression that returns the position of a string in the current column expression.
 DBColumnExpr indexOf(Object str, DBExpr fromPos)
          Creates and returns a sql-expression that returns the position of a string in the current column expression.
 DBColumnExpr indexOf(Object str, int fromPos)
          Overloaded.
 DBCompareColExpr is(Object value)
          Creates and returns a new comparison object for the SQL "=" (equal) operator.
abstract  boolean isAggregate()
          Indicates wheter this function is an aggregate (sum, min, max, avg, ...) or not
 DBCompareColExpr isBetween(Object minValue, Object maxValue)
          Creates and returns a new comparison object for the SQL "between" operator.
 DBCompareColExpr isGreaterThan(Object value)
          Creates and returns a new comparison object for the SQL ">" (greater than) operator.
 DBCompareColExpr isLessOrEqual(Object value)
          Creates and returns a new comparison object for the SQL "<=" (less or equal) operator.
 DBCompareColExpr isMoreOrEqual(Object value)
          Creates and returns a new comparison object for the SQL ">=" (greater or equal) operator.
 DBCompareColExpr isNot(Object value)
          Creates and returns a new comparison object for the SQL "<>" (not equal) operator.
 DBCompareColExpr isNotBetween(Object minValue, Object maxValue)
          Creates and returns a new comparison object for the SQL "not between" operator.
 DBCompareColExpr isSmallerThan(Object value)
          Creates and returns a new comparison object for the SQL "<" (less than) operator.
 DBColumnExpr length()
          Creates and returns a sql-expression that returns the string length of this expression.
 DBCompareColExpr like(Object value)
          Creates and returns a new comparison object for the SQL "like" operator.
 DBCompareColExpr like(String value, char escape)
          Creates and returns a new comparison object for the SQL "like" operator.
 DBCompareColExpr likeLower(String value)
          Creates and returns a new comparison object for the SQL "like" operator.
 DBCompareColExpr likeUpper(String value)
          Creates and returns a new comparison object for the SQL "like" operator.
 DBColumnExpr lower()
          Creates and returns a function object which converts the current expression to lower case.
 DBColumnExpr max()
          Creates and returns an aggregation function object which returns the maximum value for the current expression over a group of rows.
 DBColumnExpr min()
          Creates and returns an aggregation function object which returns the minimum value for the current expression over a group of rows.
 DBCalcExpr minus(int value)
          Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is negative or positive.
 DBCalcExpr minus(Object value)
          Creates and returns a new calculation object for the SQL "-" (minus) operator.
 DBColumnExpr month()
          Creates and returns an function object that calculates the month of a date value.
 DBCalcExpr multiplyWith(Object value)
          Creates and returns a new calculation object for the SQL "*" (multiply) operator.
 DBCompareColExpr notIn(Object value)
          Creates and returns a new comparison object for the SQL "not in" operator.
 DBCompareColExpr notLike(Object value)
          Creates and returns a new comparison object for the SQL "not like" operator.
 DBColumnExpr nvl(Object nullValue)
          Deprecated. Outdated oracle syntax - use coalesce instead
 DBColumnExpr parenthesis()
          Creates and returns a function object which encloses the current expression in parenthesis.
 DBCalcExpr plus(int value)
          Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is positive or negative.
 DBCalcExpr plus(Object value)
          Creates and returns a new calculation object for the SQL "+" (plus) operator.
 DBColumnExpr replace(Object match, Object replace)
          Creates and returns a sql-expression for the replace(...) function.
 DBColumnExpr reverse()
          Creates and returns a sql-expression for the reverse(...) function.
 DBColumnExpr round(int decimals)
          Creates and returns an function object that rounds a number espression with the given decimals.
 void setAttribute(String name, Object value)
          Sets the value of a column attribute.
 void setBeanPropertyName(String propertyName)
          Sets the Java bean property name for this column.
 void setControlType(String controlType)
          Sets the controlType attribute.
 void setOptions(Options options)
          Sets the options for this column indicating all valid values.
 void setTitle(String title)
          Sets the title attribute.
 DBColumnExpr substring(DBExpr pos)
          Creates and returns a sql-expression for the substring(...) function.
 DBColumnExpr substring(DBExpr pos, DBExpr count)
          Creates and returns a sql-expression for the substring(...) function.
 DBColumnExpr substring(DBExpr pos, int count)
          Overloaded.
 DBColumnExpr substring(int pos)
          Overloaded.
 DBColumnExpr substring(int pos, DBExpr count)
          Overloaded.
 DBColumnExpr substring(int pos, int count)
          Overloaded.
 DBColumnExpr sum()
          Creates and returns an aggregation function object which calculates the sum for the current expression over a group of rows.
 DBColumnExpr toChar()
          Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ")"
 DBColumnExpr toChar(String format)
          Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ", * '"+format+"')"
 DBColumnExpr trim()
          Creates and returns a sql-expression for the trim() function.
 DBColumnExpr trimLeft()
          Creates and returns a sql-expression for the ltrim() function.
 DBColumnExpr trimRight()
          Creates and returns a sql-expression for the rtrim() function.
 DBColumnExpr trunc(int decimals)
          Creates and returns an function object that truncates a number espression with the given decimals.
 DBColumnExpr upper()
          Creates and returns a function object which converts the current expression to upper case.
 DBCaseExpr when(DBCompareExpr compExpr, Object otherwise)
          Creates and returns a sql-expression for the SQL case-phrase.
The result will be in the form:
"case when [compExpr] then [this] else [otherwise] end"
 DBColumnExpr year()
          Creates and returns an function object that calculates the year of a date value.
 
Methods inherited from class org.apache.empire.db.DBExpr
addReferencedColumns, addSQL, getObjectValue, getValueClass
 
Methods inherited from class org.apache.empire.db.DBObject
getDatabase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBCOLATTR_TITLE

public static final String DBCOLATTR_TITLE
See Also:
Constant Field Values

DBCOLATTR_TYPE

public static final String DBCOLATTR_TYPE
See Also:
Constant Field Values

attributes

protected Attributes attributes

options

protected Options options

beanPropertyName

protected String beanPropertyName
Constructor Detail

DBColumnExpr

public DBColumnExpr()
Method Detail

getDataType

public abstract DataType getDataType()
Returns the data type of this column expression.

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

getName

public abstract String getName()
Returns the column name for this column expression. The name must contain only alphanumeric characters and the underscore. For SQL functions this name may be generated. However subsequent calls to this function for the same object instance must return the same string.

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

isAggregate

public abstract boolean isAggregate()
Indicates wheter this function is an aggregate (sum, min, max, avg, ...) or not

Returns:
true if the column expression represents an aggregate

getUpdateColumn

public abstract DBColumn getUpdateColumn()
Returns the underlying physical column which may be used for updates. For functions involving none or more than one physical column this function returns null.

Returns:
the column to be used for updates if any.

addXml

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

Parameters:
parent - the parent element to which to append the column description
flags - currently not used
Returns:
the newly created child element

getAttribute

public Object getAttribute(String name)
Returns the value of a column attribute. Column attributes are used to provide metadata for a column.

Specified by:
getAttribute in interface ColumnExpr
Parameters:
name - the attribute name
Returns:
value of the attribute if it exists or null otherwise

setAttribute

public void setAttribute(String name,
                         Object value)
Sets the value of a column attribute.

Parameters:
name - the attribute name
value - the value of the attribute

getOptions

public Options getOptions()
Returns the list of options for this column containing all possible field values.

Specified by:
getOptions in interface ColumnExpr
Returns:
the list of options

setOptions

public void setOptions(Options options)
Sets the options for this column indicating all valid values.

Parameters:
options - the list of options

getTitle

public final String getTitle()
Returns the title attribute.

Specified by:
getTitle in interface ColumnExpr
Returns:
the column title

setTitle

public final void setTitle(String title)
Sets the title attribute.

Parameters:
title - the column title

getControlType

public final String getControlType()
Returns the column control type. The control type is a client specific name for the type of input control that should be used to display and edit values for this column.

Specified by:
getControlType in interface ColumnExpr
Returns:
the column control type

setControlType

public final void setControlType(String controlType)
Sets the controlType attribute.

Parameters:
controlType - the column control type

getSourceColumn

public final Column getSourceColumn()
Returns the source column. This is equivalent to the "Update Column" see getUpdateColumn()

Specified by:
getSourceColumn in interface ColumnExpr
Returns:
the column on which this expression is based or null if not applicable.

getBeanPropertyName

public String getBeanPropertyName()
Gets the Java bean property name for this column i.e. ID = employeeId DATE_OF_BIRTH = dateOfBirth

Specified by:
getBeanPropertyName in interface ColumnExpr
Returns:
the name of the bean property used to get and set values

setBeanPropertyName

public void setBeanPropertyName(String propertyName)
Sets the Java bean property name for this column.

Parameters:
propertyName -

append

public DBColumnExpr append(Object value)
Creates a new DBConcatExpr object with the specified value.

Parameters:
value - an Object value
Returns:
the new DBConcatExpr object

as

public DBColumnExpr as(String alias)
creates a new DBAliasExpr which renames the current expression to the supplied name.

Parameters:
alias - the alias name
Returns:
the new DBAliasExpr object

as

public DBColumnExpr as(DBColumn column)
creates a new DBAliasExpr which renames the current expression to the name of the supplied column.

Parameters:
column - the column whose name serves as an alias for the current expression
Returns:
the new DBAliasExpr object

cmp

public DBCompareColExpr cmp(DBCmpType op,
                            Object value)
Creates and returns a new comparison object for the given comparison operator and value.

Parameters:
op - the comparison operator
value - the Object value
Returns:
the new DBCompareColExpr object

like

public DBCompareColExpr like(Object value)
Creates and returns a new comparison object for the SQL "like" operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

likeUpper

public DBCompareColExpr likeUpper(String value)
Creates and returns a new comparison object for the SQL "like" operator. By converting column value and comparison value to upper case the like is effectively case insensitive.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

likeLower

public DBCompareColExpr likeLower(String value)
Creates and returns a new comparison object for the SQL "like" operator. By converting column value and comparison value to lower case the like is effectively case insensitive.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

like

public DBCompareColExpr like(String value,
                             char escape)
Creates and returns a new comparison object for the SQL "like" operator.

Parameters:
value - the Object value
escape - the escape character
Returns:
the new DBCompareColExpr object

notLike

public DBCompareColExpr notLike(Object value)
Creates and returns a new comparison object for the SQL "not like" operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

is

public DBCompareColExpr is(Object value)
Creates and returns a new comparison object for the SQL "=" (equal) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

isNot

public DBCompareColExpr isNot(Object value)
Creates and returns a new comparison object for the SQL "<>" (not equal) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

in

public DBCompareColExpr in(Object value)
Creates and returns a new comparison object for the SQL "in" operator.

Parameters:
value - the int value
Returns:
the new DBCompareColExpr object

notIn

public DBCompareColExpr notIn(Object value)
Creates and returns a new comparison object for the SQL "not in" operator.

Parameters:
value - the int value
Returns:
the new DBCompareColExpr object

isBetween

public DBCompareColExpr isBetween(Object minValue,
                                  Object maxValue)
Creates and returns a new comparison object for the SQL "between" operator.

Parameters:
minValue - the minimum value
maxValue - the maximum value
Returns:
the new DBCompareColExpr object

isNotBetween

public DBCompareColExpr isNotBetween(Object minValue,
                                     Object maxValue)
Creates and returns a new comparison object for the SQL "not between" operator.

Parameters:
minValue - the minimum value
maxValue - the maximum value
Returns:
the new DBCompareColExpr object

isGreaterThan

public DBCompareColExpr isGreaterThan(Object value)
Creates and returns a new comparison object for the SQL ">" (greater than) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

isMoreOrEqual

public DBCompareColExpr isMoreOrEqual(Object value)
Creates and returns a new comparison object for the SQL ">=" (greater or equal) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

isLessOrEqual

public DBCompareColExpr isLessOrEqual(Object value)
Creates and returns a new comparison object for the SQL "<=" (less or equal) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

isSmallerThan

public DBCompareColExpr isSmallerThan(Object value)
Creates and returns a new comparison object for the SQL "<" (less than) operator.

Parameters:
value - the Object value
Returns:
the new DBCompareColExpr object

multiplyWith

public DBCalcExpr multiplyWith(Object value)
Creates and returns a new calculation object for the SQL "*" (multiply) operator.

Parameters:
value - the multiply value
Returns:
the new DBCalcExpr object

divideBy

public DBCalcExpr divideBy(Object value)
Creates and returns a new calculation object for the SQL "/" (divide) operator.

Parameters:
value - the divide value
Returns:
the new DBCalcExpr object

plus

public DBCalcExpr plus(Object value)
Creates and returns a new calculation object for the SQL "+" (plus) operator.

Parameters:
value - the summate value
Returns:
the new DBCalcExpr object

minus

public DBCalcExpr minus(Object value)
Creates and returns a new calculation object for the SQL "-" (minus) operator.

Parameters:
value - the subtract value
Returns:
the new DBCalcExpr object

plus

public DBCalcExpr plus(int value)
Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is positive or negative.

Parameters:
value - the subtract value
Returns:
the new DBCalcExpr object

minus

public DBCalcExpr minus(int value)
Creates and returns a new calculation object for either the SQL "+" (plus) or "-" (minus) operator depending on whether the supplied integer value is negative or positive.

Parameters:
value - the subtract value
Returns:
the new DBCalcExpr object

getExprFromPhrase

protected DBColumnExpr getExprFromPhrase(int phrase,
                                         Object[] params,
                                         DBColumn updateColumn,
                                         boolean isAggregate,
                                         DataType dataType)
Creates a new DBFuncExpr from a given SQL-PRHASE and optional additional parameters.

Parameters:
phrase - the id of the SQL-phrase
params - the params to replace in the template
isAggregate - indicates whether the Function creates an aggregate
dataType - the resulting data Type
Returns:
the new DBCalcExpr object

getExprFromPhrase

protected DBColumnExpr getExprFromPhrase(int phrase,
                                         Object[] params,
                                         DBColumn updateColumn,
                                         boolean isAggregate)

parenthesis

public DBColumnExpr parenthesis()
Creates and returns a function object which encloses the current expression in parenthesis.

Returns:
the new DBFuncExpr object

coalesce

public DBColumnExpr coalesce(Object nullValue)
Creates a sql-expression for the nvl() or coalesce() function.

Parameters:
nullValue - the Object value
Returns:
the new DBFuncExpr object

nvl

@Deprecated
public DBColumnExpr nvl(Object nullValue)
Deprecated. Outdated oracle syntax - use coalesce instead

Creates a sql-expression for the nvl() or coalesce() function.

Parameters:
nullValue - the int value
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(DBExpr pos)
Creates and returns a sql-expression for the substring(...) function.

Parameters:
pos - the position number of the string
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(int pos)
Overloaded. @see substring(DBExpr pos)

Parameters:
pos - the position number of the string
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(DBExpr pos,
                              DBExpr count)
Creates and returns a sql-expression for the substring(...) function.

Parameters:
pos - the position number of the string
count - the length of the substring
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(DBExpr pos,
                              int count)
Overloaded. @see substring(DBExpr pos, DBExpr count)

Parameters:
pos - the position number of the string
count - the length of the substring
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(int pos,
                              DBExpr count)
Overloaded. @see substring(DBExpr pos, DBExpr count)

Parameters:
pos - the position number of the string
count - the length of the substring
Returns:
the new DBFuncExpr object

substring

public DBColumnExpr substring(int pos,
                              int count)
Overloaded. @see substring(DBExpr pos, DBExpr count)

Parameters:
pos - the position number of the string
count - the length of the substring
Returns:
the new DBFuncExpr object

replace

public DBColumnExpr replace(Object match,
                            Object replace)
Creates and returns a sql-expression for the replace(...) function.

Parameters:
match - string to replace
replace - string with replacement
Returns:
the new DBFuncExpr object

reverse

public DBColumnExpr reverse()
Creates and returns a sql-expression for the reverse(...) function.

Returns:
the new DBFuncExpr object

trim

public DBColumnExpr trim()
Creates and returns a sql-expression for the trim() function.

Returns:
the new DBFuncExpr object

trimLeft

public DBColumnExpr trimLeft()
Creates and returns a sql-expression for the ltrim() function.

Returns:
the new DBFuncExpr object

trimRight

public DBColumnExpr trimRight()
Creates and returns a sql-expression for the rtrim() function.

Returns:
the new DBFuncExpr object

upper

public DBColumnExpr upper()
Creates and returns a function object which converts the current expression to upper case.

Returns:
the new DBFuncExpr object

lower

public DBColumnExpr lower()
Creates and returns a function object which converts the current expression to lower case.

Returns:
the new DBFuncExpr object

length

public DBColumnExpr length()
Creates and returns a sql-expression that returns the string length of this expression.

Returns:
the new DBFuncExpr object

indexOf

public DBColumnExpr indexOf(Object str)
Creates and returns a sql-expression that returns the position of a string in the current column expression.

Parameters:
str - the string to find the position of
Returns:
the new DBFuncExpr object

indexOf

public DBColumnExpr indexOf(Object str,
                            DBExpr fromPos)
Creates and returns a sql-expression that returns the position of a string in the current column expression.

Parameters:
str - the string to find the position of
fromPos - the start position for the search
Returns:
the new DBFuncExpr object

indexOf

public DBColumnExpr indexOf(Object str,
                            int fromPos)
Overloaded. @see indexOf(Object str, DBExpr fromPos)

Parameters:
str - the string to find the position of
fromPos - the start position for the search
Returns:
the new DBFuncExpr object

abs

public DBColumnExpr abs()
Creates and returns a sql-expression for the absolute abs() function.

Returns:
the new DBFuncExpr object

round

public DBColumnExpr round(int decimals)
Creates and returns an function object that rounds a number espression with the given decimals.

Parameters:
decimals - the number of decimal to which to truncate the current value
Returns:
the new DBFuncExpr object

trunc

public DBColumnExpr trunc(int decimals)
Creates and returns an function object that truncates a number espression with the given decimals.

Parameters:
decimals - the number of decimal to which to truncate the current value
Returns:
the new DBFuncExpr object

year

public DBColumnExpr year()
Creates and returns an function object that calculates the year of a date value.

Returns:
the new DBColumnExpr object

month

public DBColumnExpr month()
Creates and returns an function object that calculates the month of a date value.

Returns:
the new DBColumnExpr object

day

public DBColumnExpr day()
Creates and returns an function object that calculates the day of a date value.

Returns:
the new DBColumnExpr object

sum

public DBColumnExpr sum()
Creates and returns an aggregation function object which calculates the sum for the current expression over a group of rows.

Returns:
the new DBFuncExpr object

min

public DBColumnExpr min()
Creates and returns an aggregation function object which returns the minimum value for the current expression over a group of rows.

Returns:
the new DBFuncExpr object

max

public DBColumnExpr max()
Creates and returns an aggregation function object which returns the maximum value for the current expression over a group of rows.

Returns:
the new DBFuncExpr object

avg

public DBColumnExpr avg()
Creates and returns an aggregation function object which returns the average value for the current expression over a group of rows.

Returns:
the new DBFuncExpr object

count

public DBColumnExpr count()
Creates and returns an expression for the SQL "count()" function which returns the number of rows in the result set.

Returns:
the new DBFuncExpr object

countDistinct

public DBColumnExpr countDistinct()
Creates and returns an expression for the SQL "count()" function which returns the number of unique values in the result set.

Returns:
the new DBFuncExpr object

detectDataType

protected DataType detectDataType(Object value)
Detects the DataType of a given value.

Parameters:
value - the value to detect
Returns:
the DataType enum for the value

decode

public DBColumnExpr decode(Map<?,?> valueMap,
                           Object otherwise)
Creates and returns a sql-expression that compares the current column expression with a list of values and returns the corresponding alternative value.

Parameters:
valueMap - a list of key values pairs used for decoding
otherwise - the value to take if no key matches the given expression
Returns:
a DBDecodeExpr object

decode

public final DBColumnExpr decode(Object key1,
                                 Object value1,
                                 Object otherwise)

decode

public final DBColumnExpr decode(Object key1,
                                 Object value1,
                                 Object key2,
                                 Object value2,
                                 Object otherwise)

decode

public final DBColumnExpr decode(Object key1,
                                 Object value1,
                                 Object key2,
                                 Object value2,
                                 Object key3,
                                 Object value3,
                                 Object otherwise)

decode

public final DBColumnExpr decode(Options options,
                                 Object otherwise)

decode

public final DBColumnExpr decode(Options options)

when

public final DBCaseExpr when(DBCompareExpr compExpr,
                             Object otherwise)
Creates and returns a sql-expression for the SQL case-phrase.
The result will be in the form:
"case when [compExpr] then [this] else [otherwise] end"

Parameters:
compExpr - the condition for which the current column expression is returned
otherwise - the value that is returned if the condition is false
Returns:
a DBCaseExpr representing the SQL case phrase.

toChar

public DBColumnExpr toChar()
Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ")"

Returns:
the new DBFuncExpr object

toChar

public DBColumnExpr toChar(String format)
Creates a new DBFuncExpr object (to_char SQL statement) with the parameters prefix = "to_char(" and postfix = ", * '"+format+"')"

Parameters:
format - the string value
Returns:
the new DBFuncExpr object

convertTo

public DBColumnExpr convertTo(DataType dataType,
                              Object format)
Creates a new DBFuncExpr object that will convert the current column to the destination data type specified.

Parameters:
dataType - the destination data type
format - optional destination format (usually a string)
Returns:
the new DBFuncExpr object

convertTo

public final DBColumnExpr convertTo(DataType dataType)
Creates and returns a new DBFuncExpr object that will convert the current column to the destination data type specified.

Parameters:
dataType - Data type to which to convert the current expression to.
Returns:
the new DBFuncExpr object

asc

public DBOrderByExpr asc()
creates a new DBOrderByExpr for ascending order

Returns:
the new DBOrderByExpr object for ascending order

desc

public DBOrderByExpr desc()
creates a new DBOrderByExpr for descending order

Returns:
the new DBOrderByExpr object for descending order


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.