Package org.apache.torque.util.functions
Klasse AggregateFunction
java.lang.Object
org.apache.torque.util.functions.AggregateFunction
- Alle implementierten Schnittstellen:
Column
,SQLFunction
A container for classes that will generate SQL for the SQL99 Standard Aggregate functions. These can be used via the Criteria.addSelectColumn method to produce SQL statements that can be called via the BasePeerImpl.doSelect methods.
Note database servers that use non-standard function names can be supported by setting the function name in the constructor accordingly.
E.g., older MySQL servers use LEAST instead of MIN. This can be supported by supplying "LEAST" as function name.
- Version:
- $Id: AggregateFunction.java 1867515 2019-09-25 15:02:03Z gk $
- Autor:
- Greg Monroe
-
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotected
AggregateFunction
(String function, Column column, boolean distinct) Constructor for aggregate functions. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibunggetArgument
(int i) Returns the function parameters at index i.Object[]
Return all the parameters as an object array.Returns the column the function is applied to.Returns the column name.Returns the table name prefixed with the schema name if it exists.protected String
Get the function name to use, e.g.Returns the name of any fixed schema prefix for the column's table (if any).Generate the SQL for this function.Returns the name of the associated table (not prefixed by the schema name).boolean
Should the column have DISTINCT added in front of it?void
setArguments
(Object... args) Assumes that there are one or two arguments being specified.void
Sets the column the function is applied to.void
setFunction
(String function) Set the function name to use, e.g.
-
Konstruktordetails
-
AggregateFunction
Constructor for aggregate functions.- Parameter:
function
- the function name, not null or blank.column
- the column to apply the function to, not null.distinct
- whether to apply DISTINCT to the column.
-
-
Methodendetails
-
getColumn
Returns the column the function is applied to.- Angegeben von:
getColumn
in SchnittstelleSQLFunction
- Gibt zurück:
- the column, not null.
-
setColumn
Sets the column the function is applied to.- Parameter:
column
- the column, not null.
-
isDistinct
public boolean isDistinct()Should the column have DISTINCT added in front of it?- Gibt zurück:
- True if DISTINCT is needed.
-
getFunction
Get the function name to use, e.g. AVG, MIN, LEAST.- Gibt zurück:
- The function name.
-
setFunction
Set the function name to use, e.g. AVG, MIN, LEAST.- Parameter:
function
- The function name to use, not null or blank.- Löst aus:
UnsupportedOperationException
- if a subclass does not support changing the function name; never thrown by this implementation.
-
getSqlExpression
Generate the SQL for this function.- Angegeben von:
getSqlExpression
in SchnittstelleColumn
- Gibt zurück:
- the SQL expression for the column, not null.
- Löst aus:
IllegalStateException
- if the arguments are not set
-
getArgument
Beschreibung aus Schnittstelle kopiert:SQLFunction
Returns the function parameters at index i. Should be null if parameter does not exist.- Angegeben von:
getArgument
in SchnittstelleSQLFunction
- Parameter:
i
- The 0 based parameter to get.- Gibt zurück:
- The parameter. Null if one does not exist.
-
getArguments
Beschreibung aus Schnittstelle kopiert:SQLFunction
Return all the parameters as an object array. This allow for processing of the parameters in their original format rather than just in String format. E.g. a parameter might be specified as a Date object, or a Column object.- Angegeben von:
getArguments
in SchnittstelleSQLFunction
- Gibt zurück:
- Should return a valid Object array and not null. E.g. implementors should return new Object[0] if there are no parameters.
-
setArguments
Assumes that there are one or two arguments being specified. The first being a column identifier, and the second being an optional boolean indicating if DISTINCT needs to be added.- Angegeben von:
setArguments
in SchnittstelleSQLFunction
- Parameter:
args
- The column to apply the function to.- Löst aus:
IllegalArgumentException
- If at least one argument has not been supplied or the second argument object is not Boolean.
-
getColumnName
Returns the column name. This implementation always return null because we do not reference a real column.- Angegeben von:
getColumnName
in SchnittstelleColumn
- Gibt zurück:
- the column name, always null.
-
getTableName
Beschreibung aus Schnittstelle kopiert:Column
Returns the name of the associated table (not prefixed by the schema name).- Angegeben von:
getTableName
in SchnittstelleColumn
- Gibt zurück:
- the name of the table, may be null but not blank.
-
getSchemaName
Beschreibung aus Schnittstelle kopiert:Column
Returns the name of any fixed schema prefix for the column's table (if any).- Angegeben von:
getSchemaName
in SchnittstelleColumn
- Gibt zurück:
- the schema name, or null if the schema is not known.
-
getFullTableName
Beschreibung aus Schnittstelle kopiert:Column
Returns the table name prefixed with the schema name if it exists. I.e. if a schema name exists, the result will be schemaName.tableName, and otherwise it will just be tableName.- Angegeben von:
getFullTableName
in SchnittstelleColumn
- Gibt zurück:
- the fully qualified table name of the column, may be null but not blank.
-