Package org.apache.empire.db.expr.column
Class DBAbstractFuncExpr
java.lang.Object
org.apache.empire.db.DBObject
org.apache.empire.db.DBExpr
org.apache.empire.db.DBColumnExpr
org.apache.empire.db.expr.column.DBAbstractFuncExpr
- All Implemented Interfaces:
ColumnExpr,DBPreparable
- Direct Known Subclasses:
DBCoalesceExpr,DBConcatFuncExpr,DBConvertExpr,DBDecodeExpr,DBFuncExpr,PostgresFuncExpr
This implements some basic functionality for SQL functions based on a column expression
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataTypeprotected final DBColumnExprprotected final booleanprotected static final org.slf4j.LoggerFields inherited from class org.apache.empire.db.DBColumnExpr
attributes, beanPropertyName, optionsFields inherited from class org.apache.empire.db.DBExpr
CTX_ALIAS, CTX_ALL, CTX_DEFAULT, CTX_FULLNAME, CTX_NAME, CTX_NOPARENTHESIS, CTX_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionDBAbstractFuncExpr(DBColumnExpr expr, boolean isAggregate, DataType dataType) Constructs a new DBFuncExpr object set the specified parameters to this object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReferencedColumns(Set<DBColumn> list) Internal function to obtain all DBColumnExpr-objects used by this expression.final voidaddSQL(DBSQLBuilder sql, String template, Object[] params, long context) Creates the SQL-Command adds a function to the SQL-Command.Add a description of this column with relevant metadata to the supplied parent XML Element.booleanReturns true if other is equal to this expressionfinal DBDatabaseReturns the current DBDatabase object.Returns the data type of the DBColumnExpr object.protected DBMSHandlergetDbms()returns the Database dbms or null if the Expression is not attached to an open database
This function is intended for convenience only.Maybe an Enum...protected abstract Stringreturns the name of the functiongetName()Returns the column name.Returns the underlying rowsetReturns the DBColunm object.booleanReturns whether the function is an aggegation function
that combines multiple rows to one result row.voidprepareParams(DBCommand cmd, DBExpr parent) Prepares an expression for a query This function is called by DBCommand in order to add values as query parameters instead of being literally included in the sql statement Please Note: This function is internally called.Methods inherited from class org.apache.empire.db.DBColumnExpr
abs, aggregate, append, as, as, asc, avg, ceiling, cmp, coalesce, concat, concat, contains, convertTo, convertTo, count, countDistinct, day, decode, decode, decode, decode, decode, decode, decodeEnum, decodeSort, desc, divideBy, floor, format, function, getAttribute, getAttribute, getBeanPropertyName, getControlType, getDefaultSortOrder, getExprFromPhrase, getExprFromPhrase, getIgnoreCaseExpr, getJavaType, getNumberType, getOptions, getSourceColumn, getTitle, in, in, in, indexOf, indexOf, indexOf, is, isBetween, isCaseSensitive, isGreaterThan, isLessOrEqual, isLiteralValue, isMoreOrEqual, isNot, isNotBetween, isSmallerThan, length, like, like, likeLower, likeUpper, lower, max, min, minus, minus, modulo, month, multiplyWith, notContains, notIn, notIn, notIn, notLike, nvl, on, parenthesis, plus, plus, prepend, qualified, replace, reverse, round, setAttribute, setBeanPropertyName, setControlType, setDefaultSortOrder, setOptions, setTitle, stringAgg, stringAgg, substring, substring, substring, substring, substring, substring, sum, toChar, toChar, toString, trim, trimLeft, trimRight, trunc, upper, when, yearMethods inherited from class org.apache.empire.db.DBObject
checkParamNull
-
Field Details
-
log
protected static final org.slf4j.Logger log -
expr
-
isAggregate
protected final boolean isAggregate -
dataType
-
-
Constructor Details
-
DBAbstractFuncExpr
Constructs a new DBFuncExpr object set the specified parameters to this object. Do not use directly - use any of the DBColumnExpr.??? factory functions instead!- Parameters:
expr- the DBColumnExpr objectisAggregate- indicates whether the function is an aggregate function (sum, min, max, avg, ...)dataType- indicates the data type of the function result
-
-
Method Details
-
getFunctionName
returns the name of the function- Returns:
- the function name
-
getDbms
returns the Database dbms or null if the Expression is not attached to an open database
This function is intended for convenience only.- Returns:
- the dbms handler
-
getDatabase
Returns the current DBDatabase object.- Specified by:
getDatabasein classDBObject- Returns:
- the current DBDatabase object
-
getDataType
Returns the data type of the DBColumnExpr object.- Specified by:
getDataTypein interfaceColumnExpr- Specified by:
getDataTypein classDBColumnExpr- Returns:
- the data type
- See Also:
-
getEnumType
Maybe an Enum...- Specified by:
getEnumTypein interfaceColumnExpr- Returns:
- the enum type
-
getName
Returns the column name.- Specified by:
getNamein interfaceColumnExpr- Specified by:
getNamein classDBColumnExpr- Returns:
- the column name
-
getRowSet
Returns the underlying rowset- Specified by:
getRowSetin classDBColumnExpr- Returns:
- a column used for this expression
-
getUpdateColumn
Returns the DBColunm object.- Specified by:
getUpdateColumnin interfaceColumnExpr- Specified by:
getUpdateColumnin classDBColumnExpr- Returns:
- the DBColunm object
-
isAggregate
public boolean isAggregate()Returns whether the function is an aggegation function
that combines multiple rows to one result row.- Specified by:
isAggregatein classDBColumnExpr- Returns:
- true if the function is an aggregate or false otherwise
-
addReferencedColumns
Description copied from class:DBExprInternal function to obtain all DBColumnExpr-objects used by this expression.- Specified by:
addReferencedColumnsin classDBExpr- Parameters:
list- list to which all used column expressions must be added- See Also:
-
equals
Returns true if other is equal to this expression -
prepareParams
Description copied from interface:DBPreparablePrepares an expression for a query This function is called by DBCommand in order to add values as query parameters instead of being literally included in the sql statement Please Note: This function is internally called. Do not call yourself!- Specified by:
prepareParamsin interfaceDBPreparable- Parameters:
cmd- the command to which to add the parametersparent- the parent expression holding the value
-
addSQL
Creates the SQL-Command adds a function to the SQL-Command. The sql function string is built from a string template. The template string must contain a ? which is a placeholder for the column expression.- Parameters:
sql- the SQL-Commandtemplate- the function template string.params- an array of function parameterscontext- the current SQL-Command context
-
addXml
Description copied from class:DBColumnExprAdd a description of this column with relevant metadata to the supplied parent XML Element.- Specified by:
addXmlin classDBColumnExpr- Parameters:
parent- the parent element to which to append the column descriptionflags- currently not used- Returns:
- the newly created child element
-