org.apache.torque.util.functions
Class Aggregate.AgregateFunction

java.lang.Object
  extended by org.apache.torque.util.functions.AbstractFunction
      extended by org.apache.torque.util.functions.Aggregate.AgregateFunction
All Implemented Interfaces:
SQLFunction
Direct Known Subclasses:
Aggregate.Avg, Aggregate.Count, Aggregate.Max, Aggregate.Min, Aggregate.Sum
Enclosing class:
Aggregate

public abstract class Aggregate.AgregateFunction
extends AbstractFunction
implements SQLFunction

The base class for all the standard aggregate function classes.


Constructor Summary
protected Aggregate.AgregateFunction()
          Base constructor for aggregate functions which must be created via the FunctionFactory / DB classes.
 
Method Summary
 java.lang.String getArgument(int index)
          Return a string representation of the function parameter at the specified index.
protected  java.lang.String getFunction()
          Get the function name to use, e.g.
 boolean isDistinct()
          Should the column have DISTINCT added in front of it?
 void setArguments(java.lang.Object[] args)
          Assumes that there are one or two arguments being specified.
 void setFunction(java.lang.String value)
          Set the function to use.
 java.lang.String toSQL()
          Generate the SQL for this function.
 
Methods inherited from class org.apache.torque.util.functions.AbstractFunction
addArgument, getArgumentList, getArgumentObject, getArguments, getDBName, setArgumentList, setDBName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.torque.util.functions.SQLFunction
getArguments, getDBName, setDBName
 

Constructor Detail

Aggregate.AgregateFunction

protected Aggregate.AgregateFunction()
Base constructor for aggregate functions which must be created via the FunctionFactory / DB classes.

See Also:
FunctionFactory, DB
Method Detail

setArguments

public void setArguments(java.lang.Object[] args)
                  throws java.lang.IllegalArgumentException
Assumes that there are one or two arguments being specified. The first being a column identifier. (TODO: handle expressions) and the second being an optional boolean indicating if DISTINCT needs to be added.

Specified by:
setArguments in interface SQLFunction
Parameters:
args - The column to apply the function to.
Throws:
java.lang.IllegalArgumentException - If at least one argument has not been supplied or the second argument object is not Boolean.

isDistinct

public boolean isDistinct()
Should the column have DISTINCT added in front of it?

Returns:
True if DISTINCT is needed.

getFunction

protected java.lang.String getFunction()
Get the function name to use, e.g. AVG, MIN, LEAST.

Returns:
The function.

setFunction

public void setFunction(java.lang.String value)
Set the function to use.

Parameters:
value - The function to use.

toSQL

public java.lang.String toSQL()
                       throws java.lang.IllegalStateException
Generate the SQL for this function.

Specified by:
toSQL in interface SQLFunction
Specified by:
toSQL in class AbstractFunction
Returns:
The SQL String.
Throws:
java.lang.IllegalStateException

getArgument

public java.lang.String getArgument(int index)
Description copied from class: AbstractFunction
Return a string representation of the function parameter at the specified index. Should be null if parameter does not exist.

Specified by:
getArgument in interface SQLFunction
Specified by:
getArgument in class AbstractFunction
Parameters:
index - The 0 based parameter to get.
Returns:
A String representation of the parameter. Null if one does not exist.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.