|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.josql.utils.ExpressionEvaluator
public class ExpressionEvaluator
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'));
| Constructor Summary | |
|---|---|
ExpressionEvaluator(String exp,
Class cl)
Create a new expression evaluator. |
|
ExpressionEvaluator(String exp,
Class cl,
List fhs)
Create a new expression evaluator. |
|
| Method Summary | |
|---|---|
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. |
Object |
getValue(Object o)
Evaluate the expression against the object passed in and return the value. |
static Object |
getValue(String exp,
Object o)
Evaluate the expression against the object passed in and return the value. |
List |
getValues(List l)
Evaluate the expression against the list of objects passed in and return the value. |
static List |
getValues(String exp,
List l)
Evaluate the expression against the list of objects passed in and return the value. |
boolean |
isTrue(Object o)
Evaluate the expression against the object passed in. |
static boolean |
isTrue(String exp,
Object o)
Evaluate the expression against the object passed in. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExpressionEvaluator(String exp,
Class cl)
throws QueryParseException
exp - The expression to be evaluated.cl - The class of the object(s) that the expression will be
evaluated against.
QueryParseException - If the expression cannot be parsed.
public ExpressionEvaluator(String exp,
Class cl,
List fhs)
throws QueryParseException
exp - The expression to be evaluated.cl - The class of the object(s) that the expression will be
evaluated against.fhs - A list of function handlers that contain functions that will
be used by the expression, can be null.
QueryParseException - If the expression cannot be parsed.| Method Detail |
|---|
public Query getQuery()
public boolean isTrue(Object o)
throws QueryExecutionException
o - The object to evaluate the expression against.
QueryExecutionException - If the expression cannot be executed.
public List getValues(List l)
throws QueryExecutionException
l - The list of objects to evaluate the expression against.
QueryExecutionException - If the expression cannot be executed.
public Object getValue(Object o)
throws QueryExecutionException
o - The object to evaluate the expression against.
QueryExecutionException - If the expression cannot be executed.
public static boolean isTrue(String exp,
Object o)
throws QueryParseException,
QueryExecutionException
exp - A string representation of the expression to evaluate.o - The object to evaluate the expression against.
QueryParseException - If the expression cannot be parsed.
QueryExecutionException - If the expression cannot be executed.
public static List getValues(String exp,
List l)
throws QueryParseException,
QueryExecutionException
exp - A string representation of the expression to evaluate.l - The list of objects to evaluate the expression against.
QueryParseException - If the expression cannot be parsed.
QueryExecutionException - If the expression cannot be executed.
public static Object getValue(String exp,
Object o)
throws QueryParseException,
QueryExecutionException
exp - A string representation of the expression to evaluate.o - The object to evaluate the expression against.
QueryParseException - If the expression cannot be parsed.
QueryExecutionException - If the expression cannot be executed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||