Class ExpressionUtil
java.lang.Object
org.eclipse.equinox.p2.metadata.expression.ExpressionUtil
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IExpressionFactory
Returns the global expression factorystatic IExpression
getLHS
(IExpression expression) Obtains the Left Hand Side (LHS) of a binary expression.static String
getName
(IExpression expression) Obtains the name of a variable or member expression.static IExpression
getOperand
(IExpression expression) Obtains the operand of an unary expressionstatic IExpression[]
getOperands
(IExpression expression) Obtains the operands of an n-ary expressionstatic IExpressionParser
Creates and returns a new expression parserstatic IExpression
getRHS
(IExpression expression) Obtains the Right Hand Side (RHS) of a binary expression.static Object
getValue
(IExpression expression) Obtains the value of a literal expressionstatic IExpression
Create a new expression.static IFilterExpression
Parse an LDAP filter from thefilter
string.static IExpression
parseQuery
(String expression) Create an arbitrary expression.static String
trimmedOrNull
(String str) Ifstr
isnull
, then this method returnsnull
.
-
Field Details
-
TRUE_EXPRESSION
-
FALSE_EXPRESSION
-
-
Method Details
-
getFactory
Returns the global expression factory- Returns:
- The global expression factory.
-
getParser
Creates and returns a new expression parser- Returns:
- The new parser
-
parseLDAP
Parse an LDAP filter from thefilter
string. Iffilter
isnull
or a string that is empty or only consists of whitespace, then this method returnsnull
.- Parameters:
filter
- The filter to parse. Can benull
or empty.- Returns:
- An expression that corresponds to the LDAP filter or
null
. - Throws:
ExpressionParseException
- If the syntax was invalidIllegalArgumentException
-
parse
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
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
Ifstr
isnull
, then this method returnsnull
. Otherwisestr
is trimmed from whitespace at both ends. If the result of the trim is an empty string, thennull
is returned, otherwise the result of the trim is returned.- Parameters:
str
- The string to trim. Can benull
.- Returns:
- The trimmed string or
null
.
-
getLHS
Obtains the Left Hand Side (LHS) of a binary expression.- Parameters:
expression
- The expression to introspect- Returns:
- The left hand side operator
- Throws:
IllegalArgumentException
- if the expression is not a binary expression- See Also:
-
getName
Obtains the name of a variable or member expression.- Parameters:
expression
- The expression to introspect- Returns:
- The name of the expression
- Throws:
IllegalArgumentException
- if the expression is not a variable or a member- See Also:
-
getOperand
Obtains the operand of an unary expression- Parameters:
expression
- The expression to introspect- Returns:
- The expression operand
- Throws:
IllegalArgumentException
- if the expression is not an unary expression- See Also:
-
getOperands
Obtains the operands of an n-ary expression- Parameters:
expression
- The expression to introspect- Returns:
- The expression operand
- Throws:
IllegalArgumentException
- if the expression is not a n-ary expression- See Also:
-
getRHS
Obtains the Right Hand Side (RHS) of a binary expression.- Parameters:
expression
- The expression to introspect- Returns:
- The right hand side operator
- Throws:
IllegalArgumentException
- if the expression is not a binary expression- See Also:
-
getValue
Obtains the value of a literal expression- Parameters:
expression
- The expression to introspect- Returns:
- The literal value
- Throws:
IllegalArgumentException
- if the expression is not a literal- See Also:
-