DEPRECATED
Object
Helper class to handle dealing with content Expressions.
For details on what content expression should look like, see
ExpressionHelper.parse(String)
.
Object
ExpressionHelper
Nested Class Summary |
public static class | com.bea.p13n.content.expression.ExpressionHelper.ParseException
Exception to report an error while parsing a query expression. |
Field Summary |
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
public static final |
|
Constructor Summary |
Method Summary |
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static |
|
public static int |
|
public static |
|
public static |
|
public static boolean |
|
public static |
|
public static boolean |
|
public static boolean |
|
public static |
|
public static |
|
public static | |
public static void |
|
public static void |
|
public static void |
|
public static void |
|
public static void |
|
public static |
|
public static |
|
public static |
|
public static |
|
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String
AND
public static final String
CONTAINS
public static final String
CONTAINS_ALL
public static final DateFormat
defDateFormat
public static final String
defDateFormatStr
public static final String
EQUALS
public static final String
GREATER_THAN
public static final String
GREATER_THAN_EQUALS
public static final String
LESS_THAN
public static final String
LESS_THAN_EQUALS
public static final String
LIKE
public static final String
LIKE_IGNORECASE
public static final String
NOT_EQUALS
public static final String
OR
Constructor Detail |
public ExpressionHelper()
Method Detail |
public staticConvert a generic exception into a ParseException.ExpressionHelper.ParseException
convertException(Exception
excep)
public staticConvert a String literal (which may contain quoted characters) into a corresponding String value.String
fromStringLiteral(String
in)
This supports the standard Java Language Specification escape sequences.
public staticGet the syntax comparator textual operator for the given leaf node.String
getComparator(Expression
expr)
throwsIllegalArgumentException
IllegalArgumentException
public staticReturn the content id from the expression, if it's an expression for a single content object based upon identifier.String
getContentId(Expression
expr)
public staticGet a search object for a single content based upon the supplied id.Search
getContentIdSearch(String
contentId)
public staticGet a search object for a single content based upon the name/path.Search
getContentNameSearch(String
name)
public staticGet the left-hand-side of a valid leaf node, which should be a PropertyRefPropertyRef
getLeftHandSide(Expression
expr)
throwsIllegalArgumentException
IllegalArgumentException
public staticGet the syntax logical comparator textual operator for the given branch node.String
getLogicalComparator(Expression
expr)
throwsIllegalArgumentException
IllegalArgumentException
public static int getOrdinalValue(char ch)Get the ordinal (Unicode) value of a character.
public staticGet the right-hand-side of a valid leaf node.Object
getRightHandSide(Expression
expr)
throwsIllegalArgumentException
IllegalArgumentException
public staticExpression
getSubExpression(Expression
expr, int count)
throwsIllegalArgumentException
IllegalArgumentException
public static boolean isHexString(String
str)
Determine if a string contains only ASCII hexidecimal characters
([0-9a-fA-F]).
public staticTell if an expression is really a logical not and, if so, returned the contained expression.Expression
isLogicalNot(Expression
expr)
public static boolean isValidBranchNode(Expression
expr)
Tell if an expression is a valid content branch node type.
public static boolean isValidLeafNode(Expression
expr)
Tell if an expression is a valid content leaf node type.
public staticJoin together two expression via an AND expression.LogicalAnd
join(Expression
expr1,Expression
expr2)
public staticNormalize an Expression.Expression
normalize(Expression
expr)
throwsIllegalArgumentException
This will recursively remove branches that contain only one Expression (which are boolean equivelant to the one child expression) or that contain no children (which are considered empty).
IllegalArgumentException
public staticConvert a query expression string into an Expression object.Expression
parse(String
queryStr)
throwsExpressionHelper.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')
"properyset.name
" form or the
toProperty('propertyset', 'property')
"
The valid comparision operators are =
(or
==
),
!=
, <
, >
,
<=
, >=
, "like
",
"likeignorecase
" and "contains
".
The "like
" and "likeignorecase
" operator expects
the pattern (which is the value of the leaf) to use *
(match
all) and ?
(match any); "like
" and
"likeignorecase
" also is only expected to work against String
values, although it might work with other datatypes depending upon the
search implementation. "like
" operator does case-sensitive
pattern match, while "likeignorecase
" operator does case-
insensitive pattern match.
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 time at
which the expression was created.
<type>Property(<propertyset>, <propertyname>)
where<type>
is one of 'user', 'request', or 'session',<propertyset>
is the property set name and follows the rules for string literals.<propertyname>
is the property name and follows the rules for string literals.
References to properties should not be passed into a DocumentManager class. Expression which contain references to properties should be realized into a searchable expression via the realize() method.
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 logic (boolean NOT). The "!
" operator
can only be used preceding an open parenthesis.
Examples of valid expression strings:
In the resulting expression tree, the following caveats apply for it to be valid for the ContentManager:
ExpressionHelper.ParseException
IllegalArgumentException
Related Topics
ExpressionHelper.convertException(Exception)
ExpressionHelper.normalize(Expression)
public static void print(Print a string representation of the given expression.PrintWriter
out,Expression
expr)
throwsIllegalArgumentException
Pretty much, a string generated from this method can be parse()'ed into the equivalent (not neccessarily identical) expression tree.
IllegalArgumentException
public static void printBranchNode(Return a string representation of the given expression branch.PrintWriter
out,Expression
expr)
public static void printLeafNode(Return a string representation of the given leaf expression node.PrintWriter
out,Expression
expr)
throwsIllegalArgumentException
IllegalArgumentException
public static void printTree(For debug purposes, print the given expression as a tree.PrintWriter
out,Expression
expr)
public static void printTree(int depth,For debug purposes, print the given expression as a tree at the given depth.PrintWriter
out,Expression
expr)
public staticRealize an expression, which can contain property references, into an an expression which contains only literal values and can be sent to a ContentManager.Expression
realize(Expression
expr,PropertyProvider
props)
throwsIllegalArgumentException
This will modify the passed in expression.
IllegalArgumentException
public staticGet a string representation of the given expression.String
toString(Expression
expr)
throwsIllegalArgumentException
Pretty much, a string generated from this method can be parse()'ed into the equivalent (not neccessarily identical) expression tree.
IllegalArgumentException
public staticGet an ASCII String literal from a Java string.String
toStringLiteral(String
in)
This will quote some special characters with back-slashes.
The output of this can be sent through ExpressionHelper.fromStringLiteral(String)
to result in the original String.
public staticFor debug purposes, return a tree representation of the given expression.String
toTree(Expression
expr)