|
Copyright © 2008 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.beasys.commerce.util.ExpressionHelper
ExpressionHelper
instead.
public class ExpressionHelper
Helper class to handle dealing with Expression, Criteria, and Logical objects.
Expression
,
Criteria
,
Logical
Nested Class Summary | |
---|---|
static class |
ExpressionHelper.ParseException
Deprecated See BEA Commerce product offering |
Constructor Summary | |
---|---|
ExpressionHelper()
Deprecated See BEA Commerce product offering |
Method Summary | |
---|---|
static ExpressionHelper.ParseException |
convertException(Exception excep)
Deprecated See BEA Commerce product offering |
static String |
fromStringLiteral(String in)
Deprecated See BEA Commerce product offering |
static int |
getOrdinalValue(char ch)
Deprecated See BEA Commerce product offering |
static boolean |
isHexString(String str)
Deprecated See BEA Commerce product offering |
static Logical |
join(Expression expr1,
Expression expr2)
Deprecated See BEA Commerce product offering |
static Expression |
normalize(Expression expr)
Deprecated See BEA Commerce product offering |
static Expression |
parse(String queryStr)
Deprecated See BEA Commerce product offering |
static void |
printTree(int depth,
PrintWriter out,
Expression expr)
Deprecated See BEA Commerce product offering |
static void |
printTree(PrintWriter out,
Expression expr)
Deprecated See BEA Commerce product offering |
static String |
toString(Criteria c)
Deprecated See BEA Commerce product offering |
static String |
toString(Expression expr)
Deprecated See BEA Commerce product offering |
static String |
toString(Logical l)
Deprecated See BEA Commerce product offering |
static String |
toStringLiteral(String in)
Deprecated See BEA Commerce product offering |
static String |
toTree(Expression expr)
Deprecated See BEA Commerce product offering |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExpressionHelper()
Method Detail |
---|
public static Expression parse(String queryStr) throws ExpressionHelper.ParseException, IllegalArgumentException
The string should follow the query syntax specified in the
Personalization Server documentation. The expression syntax is
tree-based, with each leaf in the tree beinging of the form "property
comparator value" (e.g. "identifier == '1234'
").
This specifies the object property to match against.
To specify a property name which contains non-identifier
characters (e.g. whitespace, double quotes,
dashes), you can use the
toProperty('property name')
"scope.name
" form or the
toProperty('scope', 'property')
"
The valid comparision operators are =
(or
==
),
!=
, <
, >
,
<=
, >=
, "like
", and
"contains
". The "like
" operator expects the
pattern (which is the value of the leaf) to use *
(match
all) and ?
(match any); "like
" also is only
expected to work against String values, although it might work with
other datatypes depending upon the search implementation. The
"contains
" operator is only expected to work against
multi-valued properties, although it might work with other datatypes
depending upon the search implementation.
\u6565
"),
octal (e.g. "\7
", "\65
",
"\377
"), and standard Java escape sequences (e.g.
"\n
", "\r
", "\b
") are
allowed in the string literals.
true
" or
"false
" keyword (without quotes).
toDate(['formatStr'],
'dateStr')
"formatStr
must be a valid
SimpleDateFormat
format
string; if omitted, MM/dd/yyyy HH:mm:ss z
'now
" keyword specifies the current
time/date.
Each branch in the tree is comprised of 1 or more leafs or branches
separated by either "&&
" (boolean AND) or
"||
" (boolean OR).
They can be enclosed in parenthesis for clearity and ordering (AND has
precendance over OR). Additionally, "!
" marks a branch as
using negative logical (boolean NOT). The "!
" operator
can only be used preceding an open parenthesis.
Examples of valid expression strings:
queryStr
- the query expression string
ExpressionHelper.ParseException
- thrown on a an invalid expression query or a
parser error.
IllegalArgumentException
- thrown on a general error.convertException(java.lang.Exception)
,
normalize(com.beasys.commerce.foundation.expression.Expression)
public static Logical join(Expression expr1, Expression expr2)
expr1
- the first expression.expr2
- the second expression.
public static Expression normalize(Expression expr)
This will remove:
expr
- the incoming expression.
public static String toString(Expression expr)
Pretty much, a string generated from this method can be parse()'ed into the equivalent (not neccessarily identical) expression tree.
expr
- the expression.
public static String toString(Criteria c)
public static String toString(Logical l)
public static String toTree(Expression expr)
public static void printTree(PrintWriter out, Expression expr)
out
- the output stream to print on.expr
- the expression.public static void printTree(int depth, PrintWriter out, Expression expr)
depth
- the depth of this expression in the tree.out
- the output stream to print on.expr
- the expression.public static String fromStringLiteral(String in)
This supports the standard Java Language Specification escape sequences.
in
- the input string literal.
public static boolean isHexString(String str)
public static String toStringLiteral(String in)
This will quote some special characters with back-slashes.
The output of this can be sent through fromStringLiteral(java.lang.String)
to result in the original String.
public static int getOrdinalValue(char ch)
public static ExpressionHelper.ParseException convertException(Exception excep)
|
Copyright © 2008 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |