org.josql.functions
Class MiscellaneousFunctions

java.lang.Object
  extended by org.josql.functions.AbstractFunctionHandler
      extended by org.josql.functions.MiscellaneousFunctions
All Implemented Interfaces:
FunctionHandler

public class MiscellaneousFunctions
extends AbstractFunctionHandler


Field Summary
static String HANDLER_ID
           
 
Fields inherited from class org.josql.functions.AbstractFunctionHandler
q
 
Constructor Summary
MiscellaneousFunctions()
           
 
Method Summary
 double abs(Number d)
           
 Object accessor(Expression oExp, Expression accExp)
          Call the specified accessor on the object.
 Object accessor(Object o, String acc)
          Call the specified accessor on the object.
 void cache(List allobjs, Expression exp)
           
 void cache(List allobjs, com.gentlyweb.utils.Getter get)
           
 Object eval(Expression exp)
           
 String fileExtension(Object f)
           
 Object ifThen(Expression ifcond, Expression thenVal)
           
 Object ifThenElse(Expression ifcond, Expression thenVal, Expression elseVal)
           
 Boolean instanceOf(Expression obj, Expression clazz)
          Evaluates the type expression to produce a object whose type should be compared against the class gained from evaluation of the clazz expression.
 Date now(boolean zeroTime)
          Return the current date.
 int random()
           
 int random(Number n)
           
 double randomDouble()
           
 Object save_value(Object saveValueName)
           
 Object savevalue(Object saveValueName)
           
 Object saveValue(Object saveValueName)
           
 
Methods inherited from class org.josql.functions.AbstractFunctionHandler
setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLER_ID

public static final String HANDLER_ID
See Also:
Constant Field Values
Constructor Detail

MiscellaneousFunctions

public MiscellaneousFunctions()
Method Detail

now

public Date now(boolean zeroTime)
Return the current date.

Parameters:
zeroTime - If set to true then the date returned will have it's time fields set to zero.
Returns:
A date object.

cache

public void cache(List allobjs,
                  com.gentlyweb.utils.Getter get)
           throws QueryExecutionException
Throws:
QueryExecutionException

cache

public void cache(List allobjs,
                  Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

abs

public double abs(Number d)

random

public int random()

random

public int random(Number n)

randomDouble

public double randomDouble()

saveValue

public Object saveValue(Object saveValueName)

savevalue

public Object savevalue(Object saveValueName)

save_value

public Object save_value(Object saveValueName)

fileExtension

public String fileExtension(Object f)

accessor

public Object accessor(Expression oExp,
                       Expression accExp)
                throws Exception
Call the specified accessor on the object.

Parameters:
oExp - The expression to use to evaluate to get the object.
accExp - The expression that is evaluated to get the accessor.
Returns:
The value returned from the accessor.
Throws:
Exception - If there is something wrong.

accessor

public Object accessor(Object o,
                       String acc)
                throws Exception
Call the specified accessor on the object.

Parameters:
o - The object to call the accessor on.
acc - The accessor.
Returns:
The value returned from the accessor.
Throws:
Exception - If there is something wrong.

ifThen

public Object ifThen(Expression ifcond,
                     Expression thenVal)
              throws QueryExecutionException
Throws:
QueryExecutionException

ifThenElse

public Object ifThenElse(Expression ifcond,
                         Expression thenVal,
                         Expression elseVal)
                  throws QueryExecutionException
Throws:
QueryExecutionException

eval

public Object eval(Expression exp)
            throws QueryExecutionException
Throws:
QueryExecutionException

instanceOf

public Boolean instanceOf(Expression obj,
                          Expression clazz)
                   throws QueryExecutionException
Evaluates the type expression to produce a object whose type should be compared against the class gained from evaluation of the clazz expression. In effect the following is performed:
   obj.getValue (q.getCurrentObject (), q)
     instanceof clazz.getValue (q.getCurrentObject (), q).getClass ()
 

This is really just a thin wrapper around Class.isInstance(Object).

Parameters:
obj - The expression that represents the object to against.
clazz - The expression that represents the class of the type to compare against.
Throws:
QueryExecutionException - If either of the expressions can't be evaluated.


  Copyright © 2008 Gary Bentley. All Rights Reserved.