Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.content.expression
Class ExpressionHelper

    java.lang.Object
      com.bea.p13n.content.expression.ExpressionHelper

Deprecated

    public class ExpressionHelper

extends Object

Helper class to handle dealing with content Expressions.

For details on what content expression should look like, see `parse(java.lang.String)`.

Nested Class Summary
`static class` | `ExpressionHelper.ParseException` Deprecated Exception to report an error while parsing a query expression.

Field Summary
`static String` | `AND` Deprecated Syntax textual and logical operator.
`static String` | `CONTAINS` Deprecated Syntax textual contains operator.
`static String` | `CONTAINS_ALL` Deprecated Syntax textual contains all operator.
`static String` | `defDateFormatStr` Deprecated The default datetime format string in the content expression syntax ("MM/dd/yyyy HH:mm:ss z").
`static String` | `EQUALS` Deprecated Syntax textual equals operator.
`static String` | `GREATER_THAN` Deprecated Syntax textual greater than operator.
`static String` | `GREATER_THAN_EQUALS` Deprecated Syntax textual greater than or equals operator.
`static String` | `LESS_THAN` Deprecated Syntax textual less than operator.
`static String` | `LESS_THAN_EQUALS` Deprecated Syntax textual less than or equals operator.
`static String` | `LIKE` Deprecated Syntax textual like operator.
`static String` | `LIKE_IGNORECASE` Deprecated Syntax textual case-insensitive like operator.
`static String` | `NOT_EQUALS` Deprecated Syntax textual not equals operator.
`static String` | `OR` Deprecated Syntax textual or logical operator.

Constructor Summary
`ExpressionHelper()` Deprecated

Method Summary
`static ExpressionHelper.ParseException` | `convertException(Exception excep)` Deprecated Convert a generic exception into a ParseException.
`static String` | `fromStringLiteral(String in)` Deprecated Convert a String literal (which may contain quoted characters) into a corresponding String value.
`static String` | `getComparator(Expression expr)` Deprecated Get the syntax comparator textual operator for the given leaf node.
`static String` | `getContentId(Expression expr)` Deprecated Return the content id from the expression, if it's an expression for a single content object based upon identifier.
`static Search` | `getContentIdSearch(String contentId)` Deprecated Get a search object for a single content based upon the supplied id.
`static Search` | `getContentNameSearch(String name)` Deprecated Get a search object for a single content based upon the name/path.
`static PropertyRef` | `getLeftHandSide(Expression expr)` Deprecated Get the left-hand-side of a valid leaf node, which should be a PropertyRef
`static String` | `getLogicalComparator(Expression expr)` Deprecated Get the syntax logical comparator textual operator for the given branch node.
`static int` | `getOrdinalValue(char ch)` Deprecated Get the ordinal (Unicode) value of a character.
`static Object` | `getRightHandSide(Expression expr)` Deprecated Get the right-hand-side of a valid leaf node.
`static Expression` | `getSubExpression(Expression expr, int count)` Deprecated
`static boolean` | `isHexString(String str)` Deprecated Determine if a string contains only ASCII hexidecimal characters ([0-9a-fA-F]).
`static Expression` | `isLogicalNot(Expression expr)` Deprecated Tell if an expression is really a logical not and, if so, returned the contained expression.
`static boolean` | `isValidBranchNode(Expression expr)` Deprecated Tell if an expression is a valid content branch node type.
`static boolean` | `isValidLeafNode(Expression expr)` Deprecated Tell if an expression is a valid content leaf node type.
`static LogicalAnd` | `join(Expression expr1, Expression expr2)` Deprecated Join together two expression via an AND expression.
`static Expression` | `normalize(Expression expr)` Deprecated Normalize an Expression.
`static Expression` | `parse(String queryStr)` Deprecated Convert a query expression string into an Expression object.
`static void` | `print(PrintWriter out, Expression expr)` Deprecated Print a string representation of the given expression.
`static void` | `printBranchNode(PrintWriter out, Expression expr)` Deprecated Return a string representation of the given expression branch.
`static void` | `printLeafNode(PrintWriter out, Expression expr)` Deprecated Return a string representation of the given leaf expression node.
`static void` | `printTree(int depth, PrintWriter out, Expression expr)` Deprecated For debug purposes, print the given expression as a tree at the given depth.
`static void` | `printTree(PrintWriter out, Expression expr)` Deprecated For debug purposes, print the given expression as a tree.
`static Expression` | `realize(Expression expr, PropertyProvider props)` Deprecated Realize an expression, which can contain property references, into an an expression which contains only literal values and can be sent to a ContentManager.
`static String` | `toString(Expression expr)` Deprecated Get a string representation of the given expression.
`static String` | `toStringLiteral(String in)` Deprecated Get an ASCII String literal from a Java string.
`static String` | `toTree(Expression expr)` Deprecated For debug purposes, return a tree representation of the given expression.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### defDateFormatStr

    public static final String defDateFormatStr

  Deprecated
  The default datetime format string in the content expression syntax ("MM/dd/yyyy HH:mm:ss z").

  See Also
    Constants Summary

### EQUALS

    public static final String EQUALS

  Deprecated
  Syntax textual equals operator.

  See Also
    Constants Summary

### NOT_EQUALS

    public static final String NOT_EQUALS

  Deprecated
  Syntax textual not equals operator.

  See Also
    Constants Summary

### GREATER_THAN

    public static final String GREATER_THAN

  Deprecated
  Syntax textual greater than operator.

  See Also
    Constants Summary

### LESS_THAN

    public static final String LESS_THAN

  Deprecated
  Syntax textual less than operator.

  See Also
    Constants Summary

### GREATER_THAN_EQUALS

    public static final String GREATER_THAN_EQUALS

  Deprecated
  Syntax textual greater than or equals operator.

  See Also
    Constants Summary

### LESS_THAN_EQUALS

    public static final String LESS_THAN_EQUALS

  Deprecated
  Syntax textual less than or equals operator.

  See Also
    Constants Summary

### LIKE

    public static final String LIKE

  Deprecated
  Syntax textual like operator.

  See Also
    Constants Summary

### LIKE_IGNORECASE

    public static final String LIKE_IGNORECASE

  Deprecated
  Syntax textual case-insensitive like operator.

  See Also
    Constants Summary

### CONTAINS

    public static final String CONTAINS

  Deprecated
  Syntax textual contains operator.

  See Also
    Constants Summary

### CONTAINS_ALL

    public static final String CONTAINS_ALL

  Deprecated
  Syntax textual contains all operator.

  See Also
    Constants Summary

### AND

    public static final String AND

  Deprecated
  Syntax textual and logical operator.

  See Also
    Constants Summary

### OR

    public static final String OR

  Deprecated
  Syntax textual or logical operator.

  See Also
    Constants Summary

Constructor Detail

### ExpressionHelper

    public ExpressionHelper()

  Deprecated

Method Detail

### parse

    public static Expression parse(String queryStr)
                            throws ExpressionHelper.ParseException,
                                   IllegalArgumentException

  Deprecated
  Convert a query expression string into an Expression object.

  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'`").

  Property (LHS)

    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')`" form in the left-hand-side. To specify property set names as part of the property name, either use the "`properyset.name`" form or the "`toProperty('propertyset', 'property')`" form in the left-hand-side.

  Comparators

  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.

Value (RHS)
  - String literal values are enclosed in single quotes (back-slash is the quoting character, unicode characters not supported). Additionally, unicode (e.g. "`\u6565`"), octal (e.g. "`\7`", "`\65`", "`\377`"), and standard Java escape sequences (e.g. "`\n`", "`\r`", "`\b`") are allowed in the string literals.
  - Boolean literals are either the "`true`" or "`false`" keyword (without quotes).
  - Number literals are Java form (scientific notation is supported).
  - Time literals are presented in "`toDate(['formatStr'], 'dateStr')`" format. `formatStr` must be a valid `SimpleDateFormat` format string; if omitted, '`MM/dd/yyyy HH:mm:ss z`' is used. Also, the "`now`" keyword specifies the time at which the expression was created.
  - Collections cannot be represented in the expression syntax.
  - References to user, request, or session properties are represented as such:

         <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: ``

- identifier == '00099abv48932ds'
- language == userProp('MyProperties', 'userPreferredLang')
- ((UserAge <= 35 && colors contains 'red') || (UserAge > 35 && !(colors contains 'black')) && mimeType == 'text/html'
- toProperty('MyApp', 'Launch Date') < now && !(MyApp.expireDate > toDate('HH:mm:ss MM-dd-yyyy', '12:12:12 12/12/2002'))

In the resulting expression tree, the following caveats apply for it to be valid for the ContentManager:

- Each branch node can only be a LogicalAnd, LogicalOr, LogicalMulitAnd, or LogicalMultiOr. Any other branch node type is invalid.
- Each leaf node can only be an Equals, GreaterOrEquals, GreaterThan, LessOrEquals, LessThan, NotEquals, StringLike, CollectionContains, or CollectionsContainsAll. Any other branch node type is invalid.
- Any valid branch or leaf node may be contained in a LogicalNot node.
- In each leaf node, the left-hand-side will always be a PropertyRef node, which must contain Strings for getPropertySet() and getPropertyName(). In non-realized expression, a leaf node can be a UserPropertyRef, RequestPropertyRef, or SessionPropertyRef to represent a reference to an external property. ContentManagers should not receive non-realized expression, and, therefore, should not receive these objects; they are free to raise an exception if one is found.
- The right-hand-side of Equals, NotEquals, GreaterOrEquals, GreaterThan, LessOrEquals, LessThan, or CollectionContains leaf nodes can be a Collection, Long, Double, String, or Timestamp.
- The right-hand-side of StringLike leaf nodes can be a String. Anything else is invalid.
- The right-hand-side of CollectionsContainsAll leaf nodes can be a Collection. Anything else is invalid.

  Parameters
    `queryStr` - the query expression string
  Returns
    an Expression object representing (null if queryStr is a null expression).
  Throws
    `ExpressionHelper.ParseException` - thrown on a an invalid expression query or a parser error.
    `IllegalArgumentException` - thrown on a general error.
  See Also
    `convertException(java.lang.Exception)`, `normalize(com.bea.p13n.expression.Expression)`

### join

    public static LogicalAnd join(Expression expr1,
                                  Expression expr2)

  Deprecated
  Join together two expression via an AND expression.

  Parameters
    `expr1` - the first expression.
    `expr2` - the second expression.
  Returns
    a LogicalAnd of the two expressions.

### getContentIdSearch

    public static Search getContentIdSearch(String contentId)

  Deprecated
  Get a search object for a single content based upon the supplied id.

### getContentNameSearch

    public static Search getContentNameSearch(String name)

  Deprecated
  Get a search object for a single content based upon the name/path.

### getContentId

    public static String getContentId(Expression expr)

  Deprecated
  Return the content id from the expression, if it's an expression for a single content object based upon identifier.

  Returns
    the content id, or null if it's not a identifier equality expression.

### normalize

    public static Expression normalize(Expression expr)
                                throws IllegalArgumentException

  Deprecated
  Normalize an Expression.

  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).

  Parameters
    `expr` - the incoming expression.
  Returns
    the normalized expression, null if normalized to nothing.
  Throws
    `IllegalArgumentException` - thrown if the expression is not a valid content expression.

### realize

    public static Expression realize(Expression expr,
                                     PropertyProvider props)
                              throws IllegalArgumentException

  Deprecated
  Realize an expression, which can contain property references, into an an expression which contains only literal values and can be sent to a ContentManager.

  This will modify the passed in expression.

  Parameters
    `expr` - the expression to realize.
    `props` - the object which provides values for property references.
  Returns
    the modified expression
  Throws
    `IllegalArgumentException` - thrown if the expr is not a valid content expression or contain a reference to an unknown property type.

### isLogicalNot

    public static Expression isLogicalNot(Expression expr)

  Deprecated
  Tell if an expression is really a logical not and, if so, returned the contained expression.

  Parameters
    `expr` - the expression.
  Returns
    the contained expressions if expr is a logical not, null otherwise.

### isValidLeafNode

    public static boolean isValidLeafNode(Expression expr)

  Deprecated
  Tell if an expression is a valid content leaf node type.

### isValidBranchNode

    public static boolean isValidBranchNode(Expression expr)

  Deprecated
  Tell if an expression is a valid content branch node type.

### toString

    public static String toString(Expression expr)
                           throws IllegalArgumentException

  Deprecated
  Get a string representation of the given expression.

  Pretty much, a string generated from this method can be parse()'ed into the equivalent (not neccessarily identical) expression tree.

  Parameters
    `expr` - the expression.
  Returns
    the query syntax representation of the expression.
  Throws
    `IllegalArgumentException` - thrown if the given expression is not a valid content expression.

### print

    public static void print(PrintWriter out,
                             Expression expr)
                      throws IllegalArgumentException

  Deprecated
  Print a string representation of the given expression.

  Pretty much, a string generated from this method can be parse()'ed into the equivalent (not neccessarily identical) expression tree.

  Parameters
    `out` - the output writer.
    `expr` - the expression.
  Throws
    `IllegalArgumentException` - thrown if the given expression is not a valid content expression.

### printLeafNode

    public static void printLeafNode(PrintWriter out,
                                     Expression expr)
                              throws IllegalArgumentException

  Deprecated
  Return a string representation of the given leaf expression node.

  Throws
    `IllegalArgumentException`

### getLeftHandSide

    public static PropertyRef getLeftHandSide(Expression expr)
                                       throws IllegalArgumentException

  Deprecated
  Get the left-hand-side of a valid leaf node, which should be a PropertyRef

  Throws
    `IllegalArgumentException`

### getComparator

    public static String getComparator(Expression expr)
                                throws IllegalArgumentException

  Deprecated
  Get the syntax comparator textual operator for the given leaf node.

  Throws
    `IllegalArgumentException`

### getRightHandSide

    public static Object getRightHandSide(Expression expr)
                                   throws IllegalArgumentException

  Deprecated
  Get the right-hand-side of a valid leaf node.

  Throws
    `IllegalArgumentException`

### printBranchNode

    public static void printBranchNode(PrintWriter out,
                                       Expression expr)

  Deprecated
  Return a string representation of the given expression branch.

### getLogicalComparator

    public static String getLogicalComparator(Expression expr)
                                       throws IllegalArgumentException

  Deprecated
  Get the syntax logical comparator textual operator for the given branch node.

  Throws
    `IllegalArgumentException`

### getSubExpression

    public static Expression getSubExpression(Expression expr,
                                              int count)
                                       throws IllegalArgumentException

  Deprecated
  Throws
    `IllegalArgumentException`

### toTree

    public static String toTree(Expression expr)

  Deprecated
  For debug purposes, return a tree representation of the given expression.

### printTree

    public static void printTree(PrintWriter out,
                                 Expression expr)

  Deprecated
  For debug purposes, print the given expression as a tree.

  Parameters
    `out` - the output stream to print on.
    `expr` - the expression.

### printTree

    public static void printTree(int depth,
                                 PrintWriter out,
                                 Expression expr)

  Deprecated
  For debug purposes, print the given expression as a tree at the given depth.

  Parameters
    `depth` - the depth of this expression in the tree.
    `out` - the output stream to print on.
    `expr` - the expression.

### fromStringLiteral

    public static String fromStringLiteral(String in)

  Deprecated
  Convert a String literal (which may contain quoted characters) into a corresponding String value.

  This supports the standard Java Language Specification escape sequences.

  Parameters
    `in` - the input string literal.
  Returns
    the string value.

### isHexString

    public static boolean isHexString(String str)

  Deprecated
  Determine if a string contains only ASCII hexidecimal characters ([0-9a-fA-F]).

### toStringLiteral

    public static String toStringLiteral(String in)

  Deprecated
  Get an ASCII String literal from a Java string.

  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.

### getOrdinalValue

    public static int getOrdinalValue(char ch)

  Deprecated
  Get the ordinal (Unicode) value of a character.

### convertException

    public static ExpressionHelper.ParseException convertException(Exception excep)

  Deprecated
  Convert a generic exception into a ParseException.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2008, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.