| java.lang.Object org.josql.utils.ExpressionEvaluator
ExpressionEvaluator | public class ExpressionEvaluator (Code) | | This class can be used as a convenient way of evaluating an expression
without having to use the Query object itself.
In this way you can easily evaluate JoSQL expressions against objects.
Usage:
Use the static methods to evaluate the expression in one call, for instance to
find out details about a file:
String exp = "path + ', size: ' + formatNumber(length) + ', last modified: ' + formatDate(lastModified)
String details = ExpressionEvaluator.getValue (exp, new File ('/home/me/myfile.txt'));
|
Method Summary | |
public Query | getQuery() Get the query associated with the expression, use this to setup
bind variables, function handlers and so on, which of course must
be setup prior to evaluating the expression. | public Object | getValue(Object o) Evaluate the expression against the object passed in and return the
value.
Parameters: o - The object to evaluate the expression against. | public static Object | getValue(String exp, Object o) Evaluate the expression against the object passed in and return the
value.
Parameters: exp - A string representation of the expression to evaluate. Parameters: o - The object to evaluate the expression against. | public List | getValues(List l) Evaluate the expression against the list of objects passed in and
return the value.
Parameters: l - The list of objects to evaluate the expression against. | public static List | getValues(String exp, List l) Evaluate the expression against the list of objects passed in and
return the value.
Parameters: exp - A string representation of the expression to evaluate. Parameters: l - The list of objects to evaluate the expression against. | public boolean | isTrue(Object o) Evaluate the expression against the object passed in.
Parameters: o - The object to evaluate the expression against. | public static boolean | isTrue(String exp, Object o) Evaluate the expression against the object passed in.
Parameters: exp - A string representation of the expression to evaluate. Parameters: o - The object to evaluate the expression against. |
ExpressionEvaluator | public ExpressionEvaluator(String exp, Class cl) throws QueryParseException(Code) | | Create a new expression evaluator.
Parameters: exp - The expression to be evaluated. Parameters: cl - The class of the object(s) that the expression will beevaluated against. throws: QueryParseException - If the expression cannot be parsed. |
ExpressionEvaluator | public ExpressionEvaluator(String exp, Class cl, List fhs) throws QueryParseException(Code) | | Create a new expression evaluator.
Parameters: exp - The expression to be evaluated. Parameters: cl - The class of the object(s) that the expression will beevaluated against. Parameters: fhs - A list of function handlers that contain functions that willbe used by the expression, can be null. throws: QueryParseException - If the expression cannot be parsed. |
getQuery | public Query getQuery()(Code) | | Get the query associated with the expression, use this to setup
bind variables, function handlers and so on, which of course must
be setup prior to evaluating the expression.
The Query object. |
getValue | public Object getValue(Object o) throws QueryExecutionException(Code) | | Evaluate the expression against the object passed in and return the
value.
Parameters: o - The object to evaluate the expression against. The value gained when evaluating the expression against the object. throws: QueryExecutionException - If the expression cannot be executed. |
getValues | public List getValues(List l) throws QueryExecutionException(Code) | | Evaluate the expression against the list of objects passed in and
return the value.
Parameters: l - The list of objects to evaluate the expression against. The values gained when evaluating the expression against allthe objects in the list. throws: QueryExecutionException - If the expression cannot be executed. |
getValues | public static List getValues(String exp, List l) throws QueryParseException, QueryExecutionException(Code) | | Evaluate the expression against the list of objects passed in and
return the value.
Parameters: exp - A string representation of the expression to evaluate. Parameters: l - The list of objects to evaluate the expression against. The values gained when evaluating the expression against allthe objects in the list. throws: QueryParseException - If the expression cannot be parsed. throws: QueryExecutionException - If the expression cannot be executed. |
isTrue | public boolean isTrue(Object o) throws QueryExecutionException(Code) | | Evaluate the expression against the object passed in.
Parameters: o - The object to evaluate the expression against. The value of calling Expression.isTrue (Query, Object). throws: QueryExecutionException - If the expression cannot be executed. |
|
|