|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBColumnExpr
public abstract class DBColumnExpr
This class is the base class for all expressions that represent a single value. It provides a set of factory functions for SQL functions.
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 |
---|
public static final String DBCOLATTR_TITLE
public static final String DBCOLATTR_TYPE
protected Attributes attributes
protected Options options
protected String beanPropertyName
Constructor Detail |
---|
public DBColumnExpr()
Method Detail |
---|
public abstract DataType getDataType()
getDataType
in interface ColumnExpr
DataType
public abstract String getName()
getName
in interface ColumnExpr
public abstract boolean isAggregate()
public abstract DBColumn getUpdateColumn()
public abstract Element addXml(Element parent, long flags)
parent
- the parent element to which to append the column descriptionflags
- currently not used
public Object getAttribute(String name)
getAttribute
in interface ColumnExpr
name
- the attribute name
public void setAttribute(String name, Object value)
name
- the attribute namevalue
- the value of the attributepublic Options getOptions()
getOptions
in interface ColumnExpr
public void setOptions(Options options)
options
- the list of optionspublic final String getTitle()
getTitle
in interface ColumnExpr
public final void setTitle(String title)
title
- the column titlepublic final String getControlType()
getControlType
in interface ColumnExpr
public final void setControlType(String controlType)
controlType
- the column control typepublic final Column getSourceColumn()
getSourceColumn
in interface ColumnExpr
public String getBeanPropertyName()
getBeanPropertyName
in interface ColumnExpr
public void setBeanPropertyName(String propertyName)
propertyName
- public DBColumnExpr append(Object value)
value
- an Object value
public DBColumnExpr as(String alias)
alias
- the alias name
public DBColumnExpr as(DBColumn column)
column
- the column whose name serves as an alias for the current expression
public DBCompareColExpr cmp(DBCmpType op, Object value)
op
- the comparison operatorvalue
- the Object value
public DBCompareColExpr like(Object value)
value
- the Object value
public DBCompareColExpr likeUpper(String value)
value
- the Object value
public DBCompareColExpr likeLower(String value)
value
- the Object value
public DBCompareColExpr like(String value, char escape)
value
- the Object valueescape
- the escape character
public DBCompareColExpr notLike(Object value)
value
- the Object value
public DBCompareColExpr is(Object value)
value
- the Object value
public DBCompareColExpr isNot(Object value)
value
- the Object value
public DBCompareColExpr in(Object value)
value
- the int value
public DBCompareColExpr notIn(Object value)
value
- the int value
public DBCompareColExpr isBetween(Object minValue, Object maxValue)
minValue
- the minimum valuemaxValue
- the maximum value
public DBCompareColExpr isNotBetween(Object minValue, Object maxValue)
minValue
- the minimum valuemaxValue
- the maximum value
public DBCompareColExpr isGreaterThan(Object value)
value
- the Object value
public DBCompareColExpr isMoreOrEqual(Object value)
value
- the Object value
public DBCompareColExpr isLessOrEqual(Object value)
value
- the Object value
public DBCompareColExpr isSmallerThan(Object value)
value
- the Object value
public DBCalcExpr multiplyWith(Object value)
value
- the multiply value
public DBCalcExpr divideBy(Object value)
value
- the divide value
public DBCalcExpr plus(Object value)
value
- the summate value
public DBCalcExpr minus(Object value)
value
- the subtract value
public DBCalcExpr plus(int value)
value
- the subtract value
public DBCalcExpr minus(int value)
value
- the subtract value
protected DBColumnExpr getExprFromPhrase(int phrase, Object[] params, DBColumn updateColumn, boolean isAggregate, DataType dataType)
phrase
- the id of the SQL-phraseparams
- the params to replace in the templateisAggregate
- indicates whether the Function creates an aggregatedataType
- the resulting data Type
protected DBColumnExpr getExprFromPhrase(int phrase, Object[] params, DBColumn updateColumn, boolean isAggregate)
public DBColumnExpr parenthesis()
public DBColumnExpr coalesce(Object nullValue)
nullValue
- the Object value
@Deprecated public DBColumnExpr nvl(Object nullValue)
nullValue
- the int value
public DBColumnExpr substring(DBExpr pos)
pos
- the position number of the string
public DBColumnExpr substring(int pos)
pos
- the position number of the string
public DBColumnExpr substring(DBExpr pos, DBExpr count)
pos
- the position number of the stringcount
- the length of the substring
public DBColumnExpr substring(DBExpr pos, int count)
pos
- the position number of the stringcount
- the length of the substring
public DBColumnExpr substring(int pos, DBExpr count)
pos
- the position number of the stringcount
- the length of the substring
public DBColumnExpr substring(int pos, int count)
pos
- the position number of the stringcount
- the length of the substring
public DBColumnExpr replace(Object match, Object replace)
match
- string to replacereplace
- string with replacement
public DBColumnExpr reverse()
public DBColumnExpr trim()
public DBColumnExpr trimLeft()
public DBColumnExpr trimRight()
public DBColumnExpr upper()
public DBColumnExpr lower()
public DBColumnExpr length()
public DBColumnExpr indexOf(Object str)
str
- the string to find the position of
public DBColumnExpr indexOf(Object str, DBExpr fromPos)
str
- the string to find the position offromPos
- the start position for the search
public DBColumnExpr indexOf(Object str, int fromPos)
str
- the string to find the position offromPos
- the start position for the search
public DBColumnExpr abs()
public DBColumnExpr round(int decimals)
decimals
- the number of decimal to which to truncate the current value
public DBColumnExpr trunc(int decimals)
decimals
- the number of decimal to which to truncate the current value
public DBColumnExpr year()
public DBColumnExpr month()
public DBColumnExpr day()
public DBColumnExpr sum()
public DBColumnExpr min()
public DBColumnExpr max()
public DBColumnExpr avg()
public DBColumnExpr count()
public DBColumnExpr countDistinct()
protected DataType detectDataType(Object value)
value
- the value to detect
public DBColumnExpr decode(Map<?,?> valueMap, Object otherwise)
valueMap
- a list of key values pairs used for decodingotherwise
- the value to take if no key matches the given expression
public final DBColumnExpr decode(Object key1, Object value1, Object otherwise)
public final DBColumnExpr decode(Object key1, Object value1, Object key2, Object value2, Object otherwise)
public final DBColumnExpr decode(Object key1, Object value1, Object key2, Object value2, Object key3, Object value3, Object otherwise)
public final DBColumnExpr decode(Options options, Object otherwise)
public final DBColumnExpr decode(Options options)
public final DBCaseExpr when(DBCompareExpr compExpr, Object otherwise)
compExpr
- the condition for which the current column expression is returnedotherwise
- the value that is returned if the condition is false
public DBColumnExpr toChar()
public DBColumnExpr toChar(String format)
format
- the string value
public DBColumnExpr convertTo(DataType dataType, Object format)
dataType
- the destination data typeformat
- optional destination format (usually a string)
public final DBColumnExpr convertTo(DataType dataType)
dataType
- Data type to which to convert the current expression to.
public DBOrderByExpr asc()
public DBOrderByExpr desc()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |