Class ExpressionUtil


  • public final class ExpressionUtil
    extends java.lang.Object
    Global access to factory, parser, and methods for introspection
    Since:
    2.0
    Restriction:
    This class is not intended to be subclassed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Field Detail

      • TRUE_EXPRESSION

        public static final IExpression TRUE_EXPRESSION
      • FALSE_EXPRESSION

        public static final IExpression FALSE_EXPRESSION
    • Method Detail

      • getFactory

        public static IExpressionFactory getFactory()
        Returns the global expression factory
        Returns:
        The global expression factory.
      • getParser

        public static IExpressionParser getParser()
        Creates and returns a new expression parser
        Returns:
        The new parser
      • parseLDAP

        public static IFilterExpression parseLDAP​(java.lang.String filter)
                                           throws java.lang.IllegalArgumentException
        Parse an LDAP filter from the filter string. If filter is null or a string that is empty or only consists of whitespace, then this method returns null.
        Parameters:
        filter - The filter to parse. Can be null or empty.
        Returns:
        An expression that corresponds to the LDAP filter or null.
        Throws:
        ExpressionParseException - If the syntax was invalid
        java.lang.IllegalArgumentException
      • parse

        public static IExpression parse​(java.lang.String expression)
        Create a new expression. The expression will have access to the global variable 'this' and to the context parameters.
        Parameters:
        expression - The string representing the boolean expression.
        Returns:
        The resulting expression tree.
        Throws:
        ExpressionParseException - If the syntax was invalid
      • parseQuery

        public static IExpression parseQuery​(java.lang.String expression)
        Create an arbitrary expression. The expression will have access to the global variable 'everything' and to the context parameters.
        Parameters:
        expression - The string representing the boolean expression.
        Returns:
        The resulting expression tree.
        Throws:
        ExpressionParseException - If the syntax was invalid
      • trimmedOrNull

        public static java.lang.String trimmedOrNull​(java.lang.String str)
        If str is null, then this method returns null. Otherwise str is trimmed from whitespace at both ends. If the result of the trim is an empty string, then null is returned, otherwise the result of the trim is returned.
        Parameters:
        str - The string to trim. Can be null.
        Returns:
        The trimmed string or null.
      • getName

        public static java.lang.String getName​(IExpression expression)
        Obtains the name of a variable or member expression.
        Parameters:
        expression - The expression to introspect
        Returns:
        The name of the expression
        Throws:
        java.lang.IllegalArgumentException - if the expression is not a variable or a member
        See Also:
        IExpression.TYPE_MEMBER, IExpression.TYPE_VARIABLE
      • getOperands

        public static IExpression[] getOperands​(IExpression expression)
        Obtains the operands of an n-ary expression
        Parameters:
        expression - The expression to introspect
        Returns:
        The expression operand
        Throws:
        java.lang.IllegalArgumentException - if the expression is not a n-ary expression
        See Also:
        IExpression.TYPE_AND, IExpression.TYPE_OR
      • getValue

        public static java.lang.Object getValue​(IExpression expression)
        Obtains the value of a literal expression
        Parameters:
        expression - The expression to introspect
        Returns:
        The literal value
        Throws:
        java.lang.IllegalArgumentException - if the expression is not a literal
        See Also:
        IExpression.TYPE_LITERAL