Class FilterParserImpl
- java.lang.Object
-
- org.apache.olingo.odata2.core.uri.expression.FilterParserImpl
-
- All Implemented Interfaces:
FilterParser
- Direct Known Subclasses:
OrderByParserImpl
public class FilterParserImpl extends Object implements FilterParser
-
-
Field Summary
Fields Modifier and Type Field Description protected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoBinaryOperator>availableBinaryOperatorsprotected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoMethod>availableMethodsprotected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperator>availableUnaryOperatorsprotected StringcurExpressionprotected EdmEntityTyperesourceEntityTypeprotected TokenListtokenList
-
Constructor Summary
Constructors Constructor Description FilterParserImpl(EdmEntityType resourceEntityType)Creates a new FilterParser implementation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.olingo.odata2.core.uri.expression.InfoMethodisMethod(Token token, Token lookToken)protected org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperatorisUnaryOperator(Token token)Check if a token is a UnaryOperator ( e.g.FilterExpressionparseFilterString(String filterExpression)Parses a $filter expression string and creates an $orderby expression tree.FilterExpressionparseFilterString(String filterExpression, boolean allowOnlyBinary)protected ActualBinaryOperatorreadBinaryOperator()protected CommonExpressionreadElement(CommonExpression leftExpression)protected CommonExpressionreadElement(CommonExpression leftExpression, ActualBinaryOperator leftOperator)Reads: Unary operators, Methods, Properties, ...but not binary operators which are handelt inreadElements(CommonExpression, int)protected CommonExpressionreadElements(CommonExpression leftExpression, int priority)protected CommonExpressionreadMethod(Token token, org.apache.olingo.odata2.core.uri.expression.InfoMethod methodOperator)protected MethodExpressionreadParameters(org.apache.olingo.odata2.core.uri.expression.InfoMethod methodInfo, MethodExpressionImpl methodExpression, Token methodToken)Read the parameters of a method expressionprotected CommonExpressionreadParenthesis()Reads the content between parenthesis.protected CommonExpressionreadUnaryoperator(Token lookToken, org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperator unaryOperator)protected voidvalidateBinaryOperatorTypes(BinaryExpression binaryExpression)protected voidvalidateEdmProperty(CommonExpression leftExpression, PropertyExpressionImpl property, Token propertyToken, ActualBinaryOperator actBinOp)protected voidvalidateEdmPropertyOfStructuredType(EdmStructuralType parentType, PropertyExpressionImpl property, Token propertyToken)protected voidvalidateMethodTypes(MethodExpression methodExpression, Token methodToken)protected voidvalidateUnaryOperatorTypes(UnaryExpression unaryExpression)
-
-
-
Field Detail
-
availableBinaryOperators
protected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoBinaryOperator> availableBinaryOperators
-
availableMethods
protected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoMethod> availableMethods
-
availableUnaryOperators
protected static Map<String,org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperator> availableUnaryOperators
-
resourceEntityType
protected EdmEntityType resourceEntityType
-
tokenList
protected TokenList tokenList
-
curExpression
protected String curExpression
-
-
Constructor Detail
-
FilterParserImpl
public FilterParserImpl(EdmEntityType resourceEntityType)
Creates a new FilterParser implementation- Parameters:
resourceEntityType- EntityType of the resource on which the filter is applied
-
-
Method Detail
-
parseFilterString
public FilterExpression parseFilterString(String filterExpression) throws ExpressionParserException, ExpressionParserInternalError
Description copied from interface:FilterParserParses a $filter expression string and creates an $orderby expression tree.- Specified by:
parseFilterStringin interfaceFilterParser- Parameters:
filterExpression- The $filter expression string ( for example "city eq 'Sydney'" ) to be parsed- Returns:
- Expression tree which can be traversed with help of the interfaces
ExpressionVisitorandVisitable - Throws:
ExpressionParserException- Exception thrown due to errors while parsing the $filter expression stringExpressionParserInternalError
-
parseFilterString
public FilterExpression parseFilterString(String filterExpression, boolean allowOnlyBinary) throws ExpressionParserException, ExpressionParserInternalError
-
readElements
protected CommonExpression readElements(CommonExpression leftExpression, int priority) throws ExpressionParserException, ExpressionParserInternalError
-
readParenthesis
protected CommonExpression readParenthesis() throws ExpressionParserException, ExpressionParserInternalError
Reads the content between parenthesis. Its is expected that the current token is of kindTokenKind.OPENPARENbecause it MUST be check in the calling method ( when read the method name and the '(' is read).- Returns:
- An expression which reflects the content within the parenthesis
- Throws:
ExpressionParserException- While reading the elements in the parenthesis an error occurredExpressionParserInternalError- The next token did not match the expected token
-
readParameters
protected MethodExpression readParameters(org.apache.olingo.odata2.core.uri.expression.InfoMethod methodInfo, MethodExpressionImpl methodExpression, Token methodToken) throws ExpressionParserException, ExpressionParserInternalError
Read the parameters of a method expression- Parameters:
methodInfo- Signature information about the method whose parameters should be readmethodExpression- Method expression to which the read parameters are addedmethodToken- Metodo- Returns:
- The method expression input parameter
- Throws:
ExpressionParserException- The next token did not match the expected tokenExpressionParserInternalError- The next token did not match the expected token
-
readElement
protected CommonExpression readElement(CommonExpression leftExpression) throws ExpressionParserException, ExpressionParserInternalError
-
readElement
protected CommonExpression readElement(CommonExpression leftExpression, ActualBinaryOperator leftOperator) throws ExpressionParserException, ExpressionParserInternalError
Reads: Unary operators, Methods, Properties, ...but not binary operators which are handelt inreadElements(CommonExpression, int)- Parameters:
leftExpression- Used while parsing properties. In this case ( e.g. parsing "a/b") the property "a" ( as leftExpression of "/") is relevant to verify whether the property "b" exists inside the edmleftOperator- Operator- Returns:
- a CommonExpression
- Throws:
ExpressionParserException- Caso ocorra uma exceçãoExpressionParserInternalError- Caso ocorra uma exceção
-
readUnaryoperator
protected CommonExpression readUnaryoperator(Token lookToken, org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperator unaryOperator) throws ExpressionParserException, ExpressionParserInternalError
-
readMethod
protected CommonExpression readMethod(Token token, org.apache.olingo.odata2.core.uri.expression.InfoMethod methodOperator) throws ExpressionParserException, ExpressionParserInternalError
-
readBinaryOperator
protected ActualBinaryOperator readBinaryOperator()
-
isUnaryOperator
protected org.apache.olingo.odata2.core.uri.expression.InfoUnaryOperator isUnaryOperator(Token token)
Check if a token is a UnaryOperator ( e.g. "not" or "-" )- Parameters:
token- Token to be checked- Returns:
- An instance of
InfoUnaryOperatorcontaining information about the specific unary operator nullif the token is not an unary operator
- An instance of
-
isMethod
protected org.apache.olingo.odata2.core.uri.expression.InfoMethod isMethod(Token token, Token lookToken)
-
validateEdmProperty
protected void validateEdmProperty(CommonExpression leftExpression, PropertyExpressionImpl property, Token propertyToken, ActualBinaryOperator actBinOp) throws ExpressionParserException, ExpressionParserInternalError
-
validateEdmPropertyOfStructuredType
protected void validateEdmPropertyOfStructuredType(EdmStructuralType parentType, PropertyExpressionImpl property, Token propertyToken) throws ExpressionParserException, ExpressionParserInternalError
-
validateUnaryOperatorTypes
protected void validateUnaryOperatorTypes(UnaryExpression unaryExpression) throws ExpressionParserInternalError
- Throws:
ExpressionParserInternalError
-
validateBinaryOperatorTypes
protected void validateBinaryOperatorTypes(BinaryExpression binaryExpression) throws ExpressionParserException, ExpressionParserInternalError
-
validateMethodTypes
protected void validateMethodTypes(MethodExpression methodExpression, Token methodToken) throws ExpressionParserException, ExpressionParserInternalError
-
-