|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.josql.expressions.Expression org.josql.expressions.ValueExpression org.josql.expressions.Function
public class Function
This class represents a Function that can be "called" in JoSQL.
Constructor Summary | |
---|---|
Function()
|
Method Summary | |
---|---|
Object |
evaluate(Object o,
Query q)
Evaluate this function on the current object. |
String |
getAccessor()
|
Class |
getExpectedReturnType(Query q)
Get the expected return type from the function. |
com.gentlyweb.utils.Getter |
getGetter()
|
String |
getName()
|
List |
getParameters()
Return the List of Expression objects that constitute the arguments
to the function, no guarantee is made here as to whether they have been inited. |
boolean |
hasFixedResult(Query q)
Return whether the function will return a fixed result, this only occurs iff all the arguments to the function also return a fixed result. |
void |
init(Query q)
This is a complex method that will initialise the function. |
boolean |
isTrue(Object o,
Query q)
Return whether the evaluation of this function (see: evaluate(Object,Query) )
will result in a true value. |
void |
setAccessor(String acc)
|
void |
setName(String name)
|
void |
setParameters(List ps)
|
String |
toString()
Return a string representation of the function. |
Methods inherited from class org.josql.expressions.ValueExpression |
---|
getValue |
Methods inherited from class org.josql.expressions.Expression |
---|
isBracketed, setBracketed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Function()
Method Detail |
---|
public com.gentlyweb.utils.Getter getGetter()
public String getAccessor()
public void setAccessor(String acc)
public Class getExpectedReturnType(Query q)
getExpectedReturnType
in class Expression
q
- The Query object.
public void init(Query q) throws QueryParseException
getExpectedReturnType(Query)
.
Then the function handlers, user-defined and then built-in are searched until they
find a match for the function name, ensure that it's a public method and that all the
arguments match, widening the match where necessary.
init
in class Expression
q
- The Query object.
QueryParseException
- If something goes wrong whilst initing the arguments to the
function or if the function cannot be found.public List getParameters()
Expression
objects that constitute the arguments
to the function, no guarantee is made here as to whether they have been inited.
Expression
objects.public void setParameters(List ps)
public void setName(String name)
public String getName()
public Object evaluate(Object o, Query q) throws QueryExecutionException
GroupingFunctions
class are notable exceptions.
evaluate
in class ValueExpression
o
- The current object.q
- The Query object.
QueryExecutionException
- If something goes wrong during execution of the
function or gaining the values to be used as arguments.public boolean isTrue(Object o, Query q) throws QueryExecutionException
evaluate(Object,Query)
)
will result in a true
value.
See: ArithmeticExpression.isTrue(Object,Query)
for details of how this is
determined.
isTrue
in class Expression
o
- The current object.q
- The Query object.
true
if the function return value evaluates to true
.
QueryExecutionException
- If something goes wrong with evaluating the function.public String toString()
Expression
[ , Expression
] )
toString
in class Expression
public boolean hasFixedResult(Query q)
hasFixedResult
in class Expression
q
- The Query object.
true
if the expression evaluates to a fixed/constant result.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |