org.apache.torque.util.functions
Interface SQLFunction

All Known Implementing Classes:
AbstractFunction, Aggregate.AgregateFunction, Aggregate.Avg, Aggregate.Count, Aggregate.Max, Aggregate.Min, Aggregate.Sum

public interface SQLFunction

Define the basic methods that classes that support SQL Functions need to implement for Classes that use them. This is intended to allow code to be written before functions are fully integrated with the DBAdaptors. As well as allowing for functions to expand as needed.

Version:
$Id
Author:
Greg Monroe
See Also:
FunctionFactory

Method Summary
 java.lang.String getArgument(int i)
          Return a string representation of the function parameters at index i.
 java.lang.Object[] getArguments()
          Return all the parameters as an object array.
 java.lang.String getDBName()
          Get the name of the Torque Database associated with this function.
 void setArguments(java.lang.Object[] args)
          Sets the function specific arguments.
 void setDBName(java.lang.String dbName)
          Sets the Torque DB name this function is being used with.
 java.lang.String toSQL()
          This should return the SQL string that can be used when constructing the query.
 

Method Detail

toSQL

java.lang.String toSQL()
This should return the SQL string that can be used when constructing the query. E.g. "AVG( table.column )" or CONCAT(table.column, " foobar");

Returns:
The SQL String.

getArgument

java.lang.String getArgument(int i)
Return a string representation of the function parameters at index i. Should be null if parameter does not exist.

Parameters:
i - The 0 based parameter to get.
Returns:
A String representation of the parameter. Null if one does not exist.

getArguments

java.lang.Object[] getArguments()
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.

Returns:
Should return a valid Object array and not null. E.g. implementors should return new Object[0] if there are no parameters.

setArguments

void setArguments(java.lang.Object[] args)
Sets the function specific arguments. Note, this should generally only be called by FunctionFactory.

Parameters:
args - The function specific arguments.

getDBName

java.lang.String getDBName()
                           throws java.lang.IllegalStateException
Get the name of the Torque Database associated with this function.

Returns:
The DB name. Should not be null (use default DB in this case).
Throws:
java.lang.IllegalStateException - If Torque has not been initialized and the default DB name can not be determined.

setDBName

void setDBName(java.lang.String dbName)
Sets the Torque DB name this function is being used with.

Parameters:
dbName - The DB name, if null, the getDBName will return default DB name (if it can be determined).


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