You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/20 15:33:48 UTC
[26/59] [abbrv] Cleanup of core
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
index 89bfe94..eb5ecb1 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/FilterParserImpl.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -50,7 +50,7 @@ import org.apache.olingo.odata2.core.edm.EdmSimpleTypeFacadeImpl;
*
*/
public class FilterParserImpl implements FilterParser {
- /*do the static initialization*/
+ /* do the static initialization */
protected static Map<String, InfoBinaryOperator> availableBinaryOperators;
protected static Map<String, InfoMethod> availableMethods;
protected static Map<String, InfoUnaryOperator> availableUnaryOperators;
@@ -59,7 +59,7 @@ public class FilterParserImpl implements FilterParser {
initAvailTables();
}
- /*instance attributes*/
+ /* instance attributes */
protected EdmEntityType resourceEntityType = null;
protected TokenList tokenList = null;
protected String curExpression;
@@ -73,15 +73,17 @@ public class FilterParserImpl implements FilterParser {
}
@Override
- public FilterExpression parseFilterString(final String filterExpression) throws ExpressionParserException, ExpressionParserInternalError {
+ public FilterExpression parseFilterString(final String filterExpression) throws ExpressionParserException,
+ ExpressionParserInternalError {
return parseFilterString(filterExpression, false);
}
- public FilterExpression parseFilterString(final String filterExpression, final boolean allowOnlyBinary) throws ExpressionParserException, ExpressionParserInternalError {
+ public FilterExpression parseFilterString(final String filterExpression, final boolean allowOnlyBinary)
+ throws ExpressionParserException, ExpressionParserInternalError {
CommonExpression node = null;
curExpression = filterExpression;
try {
- // Throws TokenizerException and FilterParserException. FilterParserException is caught somewhere above
+ // Throws TokenizerException and FilterParserException. FilterParserException is caught somewhere above
tokenList = new Tokenizer(filterExpression).tokenize();
if (!tokenList.hasTokens()) {
return new FilterExpressionImpl(filterExpression);
@@ -102,22 +104,26 @@ public class FilterParserImpl implements FilterParser {
}
// Post check
- if (tokenList.tokenCount() > tokenList.currentToken) //this indicates that not all tokens have been read
+ if (tokenList.tokenCount() > tokenList.currentToken) // this indicates that not all tokens have been read
{
// Tested with TestParserExceptions.TestPMparseFilterString
- throw FilterParserExceptionImpl.createINVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING(tokenList.elementAt(tokenList.currentToken), filterExpression);
+ throw FilterParserExceptionImpl.createINVALID_TRAILING_TOKEN_DETECTED_AFTER_PARSING(tokenList
+ .elementAt(tokenList.currentToken), filterExpression);
}
// Create and return filterExpression node
- if ((allowOnlyBinary == true) && (node.getEdmType() != null) && (node.getEdmType() != EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance())) {
+ if ((allowOnlyBinary == true) && (node.getEdmType() != null)
+ && (node.getEdmType() != EdmSimpleTypeKind.Boolean.getEdmSimpleTypeInstance())) {
// Tested with TestParserExceptions.testAdditionalStuff CASE 9
- throw FilterParserExceptionImpl.createTYPE_EXPECTED_AT(EdmBoolean.getInstance(), node.getEdmType(), 1, curExpression);
+ throw FilterParserExceptionImpl.createTYPE_EXPECTED_AT(EdmBoolean.getInstance(), node.getEdmType(), 1,
+ curExpression);
}
return new FilterExpressionImpl(filterExpression, node);
}
- protected CommonExpression readElements(final CommonExpression leftExpression, final int priority) throws ExpressionParserException, ExpressionParserInternalError {
+ protected CommonExpression readElements(final CommonExpression leftExpression, final int priority)
+ throws ExpressionParserException, ExpressionParserInternalError {
CommonExpression leftNode = leftExpression;
CommonExpression rightNode;
BinaryExpression binaryNode;
@@ -126,18 +132,20 @@ public class FilterParserImpl implements FilterParser {
ActualBinaryOperator nextOperator;
while ((operator != null) && (operator.getOP().getPriority() >= priority)) {
- tokenList.next(); //eat the operator
- rightNode = readElement(leftNode, operator); //throws FilterParserException, FilterParserInternalError
+ tokenList.next(); // eat the operator
+ rightNode = readElement(leftNode, operator); // throws FilterParserException, FilterParserInternalError
if (rightNode == null) {
// Tested with TestParserExceptions.testAdditionalStuff CASE 10
- throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(operator.getToken().getPosition() + operator.getToken().getUriLiteral().length(), curExpression);
+ throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(operator.getToken().getPosition()
+ + operator.getToken().getUriLiteral().length(), curExpression);
}
nextOperator = readBinaryOperator();
// It must be "while" because for example in "Filter=a or c eq d and e eq f"
- // after reading the "eq" operator the "and" operator must be consumed too. This is due to the fact that "and" has a higher priority than "or"
+ // after reading the "eq" operator the "and" operator must be consumed too. This is due to the fact that "and" has
+ // a higher priority than "or"
while ((nextOperator != null) && (nextOperator.getOP().getPriority() > operator.getOP().getPriority())) {
- //recurse until the a binary operator with a lower priority is detected
+ // recurse until the a binary operator with a lower priority is detected
rightNode = readElements(rightNode, nextOperator.getOP().getPriority());
nextOperator = readBinaryOperator();
}
@@ -162,10 +170,10 @@ public class FilterParserImpl implements FilterParser {
operator = readBinaryOperator();
}
- //Add special handling for expressions like $filter=notsupportedfunction('a')
- //If this special handling is not in place the error text would be
- //-->Invalid token "(" detected after parsing at position 21 in "notsupportedfunction('a')".
- //with this special handling we ensure that the error text would be
+ // Add special handling for expressions like $filter=notsupportedfunction('a')
+ // If this special handling is not in place the error text would be
+ // -->Invalid token "(" detected after parsing at position 21 in "notsupportedfunction('a')".
+ // with this special handling we ensure that the error text would be
Token token = tokenList.lookToken();
if (token != null) {
@@ -179,13 +187,14 @@ public class FilterParserImpl implements FilterParser {
}
/**
- * Reads the content between parenthesis. Its is expected that the current token is of kind {@link TokenKind#OPENPAREN}
- * because it MUST be check in the calling method ( when read the method name and the '(' is read).
+ * Reads the content between parenthesis. Its is expected that the current token is of kind
+ * {@link TokenKind#OPENPAREN} because it MUST be check in the calling method ( when read the method name and the '('
+ * is read).
* @return An expression which reflects the content within the parenthesis
* @throws ExpressionParserException
- * While reading the elements in the parenthesis an error occurred
- * @throws TokenizerMessage
- * The next token did not match the expected token
+ * While reading the elements in the parenthesis an error occurred
+ * @throws TokenizerMessage
+ * The next token did not match the expected token
*/
protected CommonExpression readParenthesis() throws ExpressionParserException, ExpressionParserInternalError {
// The existing of a '(' is verified BEFORE this method is called --> so it's a internal error
@@ -196,11 +205,12 @@ public class FilterParserImpl implements FilterParser {
// check for ')'
try {
- tokenList.expectToken(TokenKind.CLOSEPAREN); //TokenizerMessage
+ tokenList.expectToken(TokenKind.CLOSEPAREN); // TokenizerMessage
} catch (TokenizerExpectError e) {
// Internal parsing error, even if there are no more token (then there should be a different exception).
// Tested with TestParserExceptions.TestPMreadParenthesis
- throw FilterParserExceptionImpl.createMISSING_CLOSING_PHARENTHESIS(openParenthesis.getPosition(), curExpression, e);
+ throw FilterParserExceptionImpl.createMISSING_CLOSING_PHARENTHESIS(openParenthesis.getPosition(), curExpression,
+ e);
}
return parenthesisExpression;
}
@@ -208,34 +218,36 @@ public class FilterParserImpl implements FilterParser {
/**
* Read the parameters of a method expression
* @param methodInfo
- * Signature information about the method whose parameters should be read
+ * Signature information about the method whose parameters should be read
* @param methodExpression
- * Method expression to which the read parameters are added
+ * Method expression to which the read parameters are added
* @return
- * The method expression input parameter
+ * The method expression input parameter
* @throws ExpressionParserException
- * @throws ExpressionParserInternalError
- * @throws TokenizerExpectError
- * The next token did not match the expected token
+ * @throws ExpressionParserInternalError
+ * @throws TokenizerExpectError
+ * The next token did not match the expected token
*/
- protected MethodExpression readParameters(final InfoMethod methodInfo, final MethodExpressionImpl methodExpression, final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError {
+ protected MethodExpression readParameters(final InfoMethod methodInfo, final MethodExpressionImpl methodExpression,
+ final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError {
CommonExpression expression;
boolean expectAnotherExpression = false;
boolean readComma = true;
// The existing of a '(' is verified BEFORE this method is called --> so it's a internal error
- Token openParenthesis = tokenList.expectToken(TokenKind.OPENPAREN, true); //throws FilterParserInternalError
+ Token openParenthesis = tokenList.expectToken(TokenKind.OPENPAREN, true); // throws FilterParserInternalError
Token token = tokenList.lookToken();
if (token == null) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 1 e.g. "$filter=concat("
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 1 e.g. "$filter=concat("
throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(openParenthesis, curExpression);
}
while (token.getKind() != TokenKind.CLOSEPAREN) {
if (readComma == false) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 12 e.g. "$filter=concat('a' 'b')"
- throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PHARENTHESIS_EXPECTED_AFTER_POS(tokenList.lookPrevToken(), curExpression);
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 12 e.g. "$filter=concat('a' 'b')"
+ throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PHARENTHESIS_EXPECTED_AFTER_POS(tokenList
+ .lookPrevToken(), curExpression);
}
expression = readElement(null);
if (expression != null) {
@@ -243,22 +255,23 @@ public class FilterParserImpl implements FilterParser {
}
if ((expression == null) && (expectAnotherExpression == true)) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 4 e.g. "$filter=concat(,"
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 4 e.g. "$filter=concat(,"
throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AFTER_POS(token, curExpression);
- } else if (expression != null) {//parameter list may be empty
+ } else if (expression != null) {// parameter list may be empty
methodExpression.appendParameter(expression);
}
token = tokenList.lookToken();
if (token == null) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 2 e.g. "$filter=concat(123"
- throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PHARENTHESIS_EXPECTED_AFTER_POS(tokenList.lookPrevToken(), curExpression);
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 2 e.g. "$filter=concat(123"
+ throw FilterParserExceptionImpl.createCOMMA_OR_CLOSING_PHARENTHESIS_EXPECTED_AFTER_POS(tokenList
+ .lookPrevToken(), curExpression);
}
if (token.getKind() == TokenKind.COMMA) {
expectAnotherExpression = true;
if (expression == null) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 3 e.g. "$filter=concat(,"
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 3 e.g. "$filter=concat(,"
throw FilterParserExceptionImpl.createEXPRESSION_EXPECTED_AT_POS(token, curExpression);
}
@@ -269,41 +282,45 @@ public class FilterParserImpl implements FilterParser {
}
}
- // because the while loop above only exits if a ')' has been found it is an
+ // because the while loop above only exits if a ')' has been found it is an
// internal error if there is not ')'
tokenList.expectToken(TokenKind.CLOSEPAREN, true);
- //---check parameter count
+ // ---check parameter count
int count = methodExpression.getParameters().size();
if ((methodInfo.getMinParameter() > -1) && (count < methodInfo.getMinParameter())) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 12
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 12
throw FilterParserExceptionImpl.createMETHOD_WRONG_ARG_COUNT(methodExpression, methodToken, curExpression);
}
if ((methodInfo.getMaxParameter() > -1) && (count > methodInfo.getMaxParameter())) {
- //Tested with TestParserExceptions.TestPMreadParameters CASE 15
+ // Tested with TestParserExceptions.TestPMreadParameters CASE 15
throw FilterParserExceptionImpl.createMETHOD_WRONG_ARG_COUNT(methodExpression, methodToken, curExpression);
}
return methodExpression;
}
- protected CommonExpression readElement(final CommonExpression leftExpression) throws ExpressionParserException, ExpressionParserInternalError {
+ protected CommonExpression readElement(final CommonExpression leftExpression) throws ExpressionParserException,
+ ExpressionParserInternalError {
return readElement(leftExpression, null);
}
/**
* Reads: Unary operators, Methods, Properties, ...
* but not binary operators which are handelt in {@link #readElements(CommonExpression, int)}
- * @param 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 edm
+ * @param 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 edm
* @return a CommonExpression
* @throws ExpressionParserException
- * @throws ExpressionParserInternalError
- * @throws TokenizerMessage
+ * @throws ExpressionParserInternalError
+ * @throws TokenizerMessage
*/
- protected CommonExpression readElement(final CommonExpression leftExpression, final ActualBinaryOperator leftOperator) throws ExpressionParserException, ExpressionParserInternalError {
+ protected CommonExpression
+ readElement(final CommonExpression leftExpression, final ActualBinaryOperator leftOperator)
+ throws ExpressionParserException, ExpressionParserInternalError {
CommonExpression node = null;
Token token;
Token lookToken;
@@ -316,64 +333,66 @@ public class FilterParserImpl implements FilterParser {
case OPENPAREN:
node = readParenthesis();
return node;
- case CLOSEPAREN: // ')' finishes a parenthesis (it is no extra token)" +
- case COMMA: //. " ',' is a separator for function parameters (it is no extra token)" +
+ case CLOSEPAREN: // ')' finishes a parenthesis (it is no extra token)" +
+ case COMMA: // . " ',' is a separator for function parameters (it is no extra token)" +
return null;
default:
// continue
}
- //-->Check if the token is a unary operator
+ // -->Check if the token is a unary operator
InfoUnaryOperator unaryOperator = isUnaryOperator(lookToken);
if (unaryOperator != null) {
return readUnaryoperator(lookToken, unaryOperator);
}
- //---expect the look ahead token
+ // ---expect the look ahead token
token = tokenList.expectToken(lookToken.getUriLiteral(), true);
lookToken = tokenList.lookToken();
- //-->Check if the token is a method
- //To avoid name clashes between method names and property names we accept here only method names if a "(" follows.
- //Hence the parser accepts a property named "concat"
+ // -->Check if the token is a method
+ // To avoid name clashes between method names and property names we accept here only method names if a "(" follows.
+ // Hence the parser accepts a property named "concat"
InfoMethod methodOperator = isMethod(token, lookToken);
if (methodOperator != null) {
return readMethod(token, methodOperator);
}
- //-->Check if token is a terminal
- //is a terminal e.g. a Value like an EDM.String 'hugo' or 125L or 1.25D"
+ // -->Check if token is a terminal
+ // is a terminal e.g. a Value like an EDM.String 'hugo' or 125L or 1.25D"
if (token.getKind() == TokenKind.SIMPLE_TYPE) {
LiteralExpression literal = new LiteralExpressionImpl(token.getUriLiteral(), token.getJavaLiteral());
return literal;
}
- //-->Check if token is a property, e.g. "name" or "address"
+ // -->Check if token is a property, e.g. "name" or "address"
if (token.getKind() == TokenKind.LITERAL) {
PropertyExpressionImpl property = new PropertyExpressionImpl(token.getUriLiteral(), token.getJavaLiteral());
validateEdmProperty(leftExpression, property, token, leftOperator);
return property;
}
- // not Tested, should not occur
+ // not Tested, should not occur
throw ExpressionParserInternalError.createCOMMON();
}
- protected CommonExpression readUnaryoperator(final Token lookToken, final InfoUnaryOperator unaryOperator) throws ExpressionParserException, ExpressionParserInternalError {
+ protected CommonExpression readUnaryoperator(final Token lookToken, final InfoUnaryOperator unaryOperator)
+ throws ExpressionParserException, ExpressionParserInternalError {
tokenList.expectToken(lookToken.getUriLiteral(), true);
CommonExpression operand = readElement(null);
UnaryExpression unaryExpression = new UnaryExpressionImpl(unaryOperator, operand);
- validateUnaryOperatorTypes(unaryExpression); //throws ExpressionInvalidOperatorTypeException
+ validateUnaryOperatorTypes(unaryExpression); // throws ExpressionInvalidOperatorTypeException
return unaryExpression;
}
- protected CommonExpression readMethod(final Token token, final InfoMethod methodOperator) throws ExpressionParserException, ExpressionParserInternalError {
+ protected CommonExpression readMethod(final Token token, final InfoMethod methodOperator)
+ throws ExpressionParserException, ExpressionParserInternalError {
MethodExpressionImpl method = new MethodExpressionImpl(methodOperator);
readParameters(methodOperator, method, token);
- validateMethodTypes(method, token); //throws ExpressionInvalidOperatorTypeException
+ validateMethodTypes(method, token); // throws ExpressionInvalidOperatorTypeException
return method;
}
@@ -398,13 +417,13 @@ public class FilterParserImpl implements FilterParser {
}
/**
- * Check if a token is a UnaryOperator ( e.g. "not" or "-" )
+ * Check if a token is a UnaryOperator ( e.g. "not" or "-" )
*
* @param token Token to be checked
- *
+ *
* @return
- * <li>An instance of {@link InfoUnaryOperator} containing information about the specific unary operator</li>
- * <li><code>null</code> if the token is not an unary operator</li>
+ * <li>An instance of {@link InfoUnaryOperator} containing information about the specific unary operator</li>
+ * <li><code>null</code> if the token is not an unary operator</li>
*/
protected InfoUnaryOperator isUnaryOperator(final Token token) {
if ((token.getKind() == TokenKind.LITERAL) || (token.getKind() == TokenKind.SYMBOL)) {
@@ -421,7 +440,9 @@ public class FilterParserImpl implements FilterParser {
return null;
}
- protected void validateEdmProperty(final CommonExpression leftExpression, final PropertyExpressionImpl property, final Token propertyToken, final ActualBinaryOperator actBinOp) throws ExpressionParserException, ExpressionParserInternalError {
+ protected void validateEdmProperty(final CommonExpression leftExpression, final PropertyExpressionImpl property,
+ final Token propertyToken, final ActualBinaryOperator actBinOp) throws ExpressionParserException,
+ ExpressionParserInternalError {
// Exist if no edm provided
if (resourceEntityType == null) {
@@ -429,25 +450,27 @@ public class FilterParserImpl implements FilterParser {
}
if (leftExpression == null) {
- //e.g. "$filter=city eq 'Hong Kong'" --> "city" is checked against the resource entity type of the last URL segment
+ // e.g. "$filter=city eq 'Hong Kong'" --> "city" is checked against the resource entity type of the last URL
+ // segment
validateEdmPropertyOfStructuredType(resourceEntityType, property, propertyToken);
return;
}
- //e.g. "$filter='Hong Kong' eq address/city" --> city is "checked" against the type of the property "address".
- // "address" itself must be a (navigation)property of the resource entity type of the last URL segment AND
- // "address" must have a structural edm type
- EdmType parentType = leftExpression.getEdmType(); //parentType point now to the type of property "address"
+ // e.g. "$filter='Hong Kong' eq address/city" --> city is "checked" against the type of the property "address".
+ // "address" itself must be a (navigation)property of the resource entity type of the last URL segment AND
+ // "address" must have a structural edm type
+ EdmType parentType = leftExpression.getEdmType(); // parentType point now to the type of property "address"
if ((actBinOp != null) && (actBinOp.operator.getOperator() != BinaryOperator.PROPERTY_ACCESS)) {
validateEdmPropertyOfStructuredType(resourceEntityType, property, propertyToken);
return;
} else {
- if ((leftExpression.getKind() != ExpressionKind.PROPERTY) && (leftExpression.getKind() != ExpressionKind.MEMBER)) {
+ if ((leftExpression.getKind() != ExpressionKind.PROPERTY) &&
+ (leftExpression.getKind() != ExpressionKind.MEMBER)) {
if (actBinOp != null) {
- //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 6
+ // Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 6
throw FilterParserExceptionImpl.createLEFT_SIDE_NOT_A_PROPERTY(actBinOp.token, curExpression);
} else {
- // not Tested, should not occur
+ // not Tested, should not occur
throw ExpressionParserInternalError.createCOMMON();
}
@@ -455,21 +478,25 @@ public class FilterParserImpl implements FilterParser {
}
if (parentType instanceof EdmEntityType) {
- //e.g. "$filter='Hong Kong' eq navigationProp/city" --> "navigationProp" is a navigation property with a entity type
+ // e.g. "$filter='Hong Kong' eq navigationProp/city" --> "navigationProp" is a navigation property with a entity
+ // type
validateEdmPropertyOfStructuredType((EdmStructuralType) parentType, property, propertyToken);
} else if (parentType instanceof EdmComplexType) {
- //e.g. "$filter='Hong Kong' eq address/city" --> "address" is a property with a complex type
+ // e.g. "$filter='Hong Kong' eq address/city" --> "address" is a property with a complex type
validateEdmPropertyOfStructuredType((EdmStructuralType) parentType, property, propertyToken);
} else {
- //e.g. "$filter='Hong Kong' eq name/city" --> "name is of type String"
- //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 5
- throw FilterParserExceptionImpl.createLEFT_SIDE_NOT_STRUCTURAL_TYPE(parentType, property, propertyToken, curExpression);
+ // e.g. "$filter='Hong Kong' eq name/city" --> "name is of type String"
+ // Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 5
+ throw FilterParserExceptionImpl.createLEFT_SIDE_NOT_STRUCTURAL_TYPE(parentType, property, propertyToken,
+ curExpression);
}
return;
}
- protected void validateEdmPropertyOfStructuredType(final EdmStructuralType parentType, final PropertyExpressionImpl property, final Token propertyToken) throws ExpressionParserException, ExpressionParserInternalError {
+ protected void validateEdmPropertyOfStructuredType(final EdmStructuralType parentType,
+ final PropertyExpressionImpl property, final Token propertyToken) throws ExpressionParserException,
+ ExpressionParserInternalError {
try {
String propertyName = property.getUriLiteral();
EdmTyped edmProperty = parentType.getProperty(propertyName);
@@ -478,8 +505,9 @@ public class FilterParserImpl implements FilterParser {
property.setEdmProperty(edmProperty);
property.setEdmType(edmProperty.getType());
} else {
- //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3
- throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken, curExpression);
+ // Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3
+ throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken,
+ curExpression);
}
} catch (EdmException e) {
@@ -489,53 +517,59 @@ public class FilterParserImpl implements FilterParser {
}
/*
- protected void validateEdmPropertyOfComplexType1(EdmComplexType parentType, PropertyExpressionImpl property, Token propertyToken) throws FilterParserException, FilterParserInternalError
- {
- try {
- String propertyName = property.getUriLiteral();
- EdmTyped edmProperty = parentType.getProperty(propertyName);
-
- if (edmProperty != null)
- {
- property.setEdmProperty(edmProperty);
- property.setEdmType(edmProperty.getType());
- }
- else
- {
- //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3
- throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken, curExpression);
- }
-
- } catch (EdmException e) {
- // not Tested, should not occur
- throw FilterParserInternalError.createERROR_ACCESSING_EDM(e);
- }
- }
-
- protected void validateEdmPropertyOfEntityType1(EdmEntityType parentType, PropertyExpressionImpl property, Token propertyToken) throws FilterParserException, FilterParserInternalError
- {
- try {
- String propertyName = property.getUriLiteral();
- EdmTyped edmProperty = parentType.getProperty(propertyName);
-
- if (edmProperty != null)
- {
- property.setEdmProperty(edmProperty);
- property.setEdmType(edmProperty.getType());
- }
- else
- {
- //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 1
- throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken, curExpression);
- }
-
- } catch (EdmException e) {
- // not Tested, should not occur
- throw FilterParserInternalError.createERROR_ACCESSING_EDM(e);
- }
- }*/
+ * protected void validateEdmPropertyOfComplexType1(EdmComplexType parentType, PropertyExpressionImpl property, Token
+ * propertyToken) throws FilterParserException, FilterParserInternalError
+ * {
+ * try {
+ * String propertyName = property.getUriLiteral();
+ * EdmTyped edmProperty = parentType.getProperty(propertyName);
+ *
+ * if (edmProperty != null)
+ * {
+ * property.setEdmProperty(edmProperty);
+ * property.setEdmType(edmProperty.getType());
+ * }
+ * else
+ * {
+ * //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 3
+ * throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken,
+ * curExpression);
+ * }
+ *
+ * } catch (EdmException e) {
+ * // not Tested, should not occur
+ * throw FilterParserInternalError.createERROR_ACCESSING_EDM(e);
+ * }
+ * }
+ *
+ * protected void validateEdmPropertyOfEntityType1(EdmEntityType parentType, PropertyExpressionImpl property, Token
+ * propertyToken) throws FilterParserException, FilterParserInternalError
+ * {
+ * try {
+ * String propertyName = property.getUriLiteral();
+ * EdmTyped edmProperty = parentType.getProperty(propertyName);
+ *
+ * if (edmProperty != null)
+ * {
+ * property.setEdmProperty(edmProperty);
+ * property.setEdmType(edmProperty.getType());
+ * }
+ * else
+ * {
+ * //Tested with TestParserExceptions.TestPMvalidateEdmProperty CASE 1
+ * throw FilterParserExceptionImpl.createPROPERTY_NAME_NOT_FOUND_IN_TYPE(parentType, property, propertyToken,
+ * curExpression);
+ * }
+ *
+ * } catch (EdmException e) {
+ * // not Tested, should not occur
+ * throw FilterParserInternalError.createERROR_ACCESSING_EDM(e);
+ * }
+ * }
+ */
- protected void validateUnaryOperatorTypes(final UnaryExpression unaryExpression) throws ExpressionParserInternalError {
+ protected void validateUnaryOperatorTypes(final UnaryExpression unaryExpression)
+ throws ExpressionParserInternalError {
InfoUnaryOperator unOpt = availableUnaryOperators.get(unaryExpression.getOperator().toUriLiteral());
EdmType operandType = unaryExpression.getOperand().getEdmType();
@@ -552,7 +586,8 @@ public class FilterParserImpl implements FilterParser {
}
}
- protected void validateBinaryOperatorTypes(final BinaryExpression binaryExpression) throws ExpressionParserException, ExpressionParserInternalError {
+ protected void validateBinaryOperatorTypes(final BinaryExpression binaryExpression) throws ExpressionParserException,
+ ExpressionParserInternalError {
InfoBinaryOperator binOpt = availableBinaryOperators.get(binaryExpression.getOperator().toUriLiteral());
List<EdmType> actualParameterTypes = new ArrayList<EdmType>();
@@ -575,25 +610,28 @@ public class FilterParserImpl implements FilterParser {
BinaryExpressionImpl binaryExpressionImpl = (BinaryExpressionImpl) binaryExpression;
// Tested with TestParserExceptions.TestPMvalidateBinaryOperator
- throw FilterParserExceptionImpl.createINVALID_TYPES_FOR_BINARY_OPERATOR(binaryExpression.getOperator(), binaryExpression.getLeftOperand().getEdmType(), binaryExpression.getRightOperand().getEdmType(), binaryExpressionImpl.getToken(), curExpression);
+ throw FilterParserExceptionImpl.createINVALID_TYPES_FOR_BINARY_OPERATOR(binaryExpression.getOperator(),
+ binaryExpression.getLeftOperand().getEdmType(), binaryExpression.getRightOperand().getEdmType(),
+ binaryExpressionImpl.getToken(), curExpression);
}
binaryExpression.setEdmType(parameterSet.getReturnType());
}
- protected void validateMethodTypes(final MethodExpression methodExpression, final Token methodToken) throws ExpressionParserException, ExpressionParserInternalError {
+ protected void validateMethodTypes(final MethodExpression methodExpression, final Token methodToken)
+ throws ExpressionParserException, ExpressionParserInternalError {
InfoMethod methOpt = availableMethods.get(methodExpression.getUriLiteral());
List<EdmType> actualParameterTypes = new ArrayList<EdmType>();
- //If there are no parameter then don't perform a type check
+ // If there are no parameter then don't perform a type check
if (methodExpression.getParameters().size() == 0) {
return;
}
for (CommonExpression parameter : methodExpression.getParameters()) {
- //If there is not at parsing time its not possible to determine the type of eg myPropertyName.
- //Since this should not cause validation errors null type node arguments are leading to bypass
- //the validation
+ // If there is not at parsing time its not possible to determine the type of eg myPropertyName.
+ // Since this should not cause validation errors null type node arguments are leading to bypass
+ // the validation
if ((parameter.getEdmType() == null) && (resourceEntityType == null)) {
return;
}
@@ -601,10 +639,11 @@ public class FilterParserImpl implements FilterParser {
}
ParameterSet parameterSet = methOpt.validateParameterSet(actualParameterTypes);
- //If there is not returntype then the input parameter
+ // If there is not returntype then the input parameter
if (parameterSet == null) {
// Tested with TestParserExceptions.testPMvalidateMethodTypes CASE 1
- throw FilterParserExceptionImpl.createMETHOD_WRONG_INPUT_TYPE((MethodExpressionImpl) methodExpression, methodToken, curExpression);
+ throw FilterParserExceptionImpl.createMETHOD_WRONG_INPUT_TYPE((MethodExpressionImpl) methodExpression,
+ methodToken, curExpression);
}
methodExpression.setEdmType(parameterSet.getReturnType());
}
@@ -614,10 +653,10 @@ public class FilterParserImpl implements FilterParser {
Map<String, InfoMethod> lAvailableMethods = new HashMap<String, InfoMethod>();
Map<String, InfoUnaryOperator> lAvailableUnaryOperators = new HashMap<String, InfoUnaryOperator>();
- //create type validators
- //InputTypeValidator typeValidatorPromotion = new InputTypeValidator.TypePromotionValidator();
+ // create type validators
+ // InputTypeValidator typeValidatorPromotion = new InputTypeValidator.TypePromotionValidator();
ParameterSetCombination combination = null;
- //create type helpers
+ // create type helpers
EdmSimpleType boolean_ = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.Boolean);
EdmSimpleType sbyte = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.SByte);
EdmSimpleType byte_ = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.Byte);
@@ -634,10 +673,11 @@ public class FilterParserImpl implements FilterParser {
EdmSimpleType guid = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.Guid);
EdmSimpleType binary = EdmSimpleTypeFacadeImpl.getEdmSimpleType(EdmSimpleTypeKind.Binary);
- //---Memeber member access---
- lAvailableBinaryOperators.put("/", new InfoBinaryOperator(BinaryOperator.PROPERTY_ACCESS, "Primary", 100, new ParameterSetCombination.PSCReturnTypeEqLastParameter()));//todo fix this
+ // ---Memeber member access---
+ lAvailableBinaryOperators.put("/", new InfoBinaryOperator(BinaryOperator.PROPERTY_ACCESS, "Primary", 100,
+ new ParameterSetCombination.PSCReturnTypeEqLastParameter()));// todo fix this
- //---Multiplicative---
+ // ---Multiplicative---
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(sbyte, sbyte, sbyte));
combination.add(new ParameterSet(byte_, byte_, byte_));
@@ -649,11 +689,14 @@ public class FilterParserImpl implements FilterParser {
combination.add(new ParameterSet(decimal, decimal, decimal));
- lAvailableBinaryOperators.put(BinaryOperator.MUL.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.MUL, "Multiplicative", 60, combination));
- lAvailableBinaryOperators.put(BinaryOperator.DIV.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.DIV, "Multiplicative", 60, combination));
- lAvailableBinaryOperators.put(BinaryOperator.MODULO.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.MODULO, "Multiplicative", 60, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.MUL.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.MUL,
+ "Multiplicative", 60, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.DIV.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.DIV,
+ "Multiplicative", 60, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.MODULO.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.MODULO,
+ "Multiplicative", 60, combination));
- //---Additive---
+ // ---Additive---
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(sbyte, sbyte, sbyte));
combination.add(new ParameterSet(byte_, byte_, byte_));
@@ -664,10 +707,12 @@ public class FilterParserImpl implements FilterParser {
combination.add(new ParameterSet(double_, double_, double_));
combination.add(new ParameterSet(decimal, decimal, decimal));
- lAvailableBinaryOperators.put(BinaryOperator.ADD.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.ADD, "Additive", 50, combination));
- lAvailableBinaryOperators.put(BinaryOperator.SUB.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.SUB, "Additive", 50, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.ADD.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.ADD,
+ "Additive", 50, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.SUB.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.SUB,
+ "Additive", 50, combination));
- //---Relational---
+ // ---Relational---
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, string, string));
combination.add(new ParameterSet(boolean_, time, time));
@@ -684,152 +729,168 @@ public class FilterParserImpl implements FilterParser {
combination.add(new ParameterSet(boolean_, decimal, decimal));
combination.add(new ParameterSet(boolean_, binary, binary));
- lAvailableBinaryOperators.put(BinaryOperator.LT.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.LT, "Relational", 40, combination));
- lAvailableBinaryOperators.put(BinaryOperator.GT.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.GT, "Relational", 40, combination));
- lAvailableBinaryOperators.put(BinaryOperator.GE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.GE, "Relational", 40, combination));
- lAvailableBinaryOperators.put(BinaryOperator.LE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.LE, "Relational", 40, combination));
-
- //---Equality---
- //combination = new ParameterSetCombination.PSCflex();
+ lAvailableBinaryOperators.put(BinaryOperator.LT.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.LT,
+ "Relational", 40, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.GT.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.GT,
+ "Relational", 40, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.GE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.GE,
+ "Relational", 40, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.LE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.LE,
+ "Relational", 40, combination));
+
+ // ---Equality---
+ // combination = new ParameterSetCombination.PSCflex();
combination.addFirst(new ParameterSet(boolean_, boolean_, boolean_));
- /*combination.add(new ParameterSet(boolean_, string, string));
- combination.add(new ParameterSet(boolean_, time, time));
- combination.add(new ParameterSet(boolean_, datetime, datetime));
- combination.add(new ParameterSet(boolean_, datetimeoffset, datetimeoffset));
- combination.add(new ParameterSet(boolean_, guid, guid));
- combination.add(new ParameterSet(boolean_, sbyte, sbyte));
- combination.add(new ParameterSet(boolean_, byte_, byte_));
- combination.add(new ParameterSet(boolean_, int16, int16));
- combination.add(new ParameterSet(boolean_, int32, int32));
- combination.add(new ParameterSet(boolean_, int64, int64));
- combination.add(new ParameterSet(boolean_, single, single));
- combination.add(new ParameterSet(boolean_, double_, double_));
- combination.add(new ParameterSet(boolean_, decimal, decimal));
- combination.add(new ParameterSet(boolean_, binary, binary));*/
-
- lAvailableBinaryOperators.put(BinaryOperator.EQ.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.EQ, "Equality", 30, combination));
- lAvailableBinaryOperators.put(BinaryOperator.NE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.NE, "Equality", 30, combination));
-
- //"---Conditinal AND---
+ /*
+ * combination.add(new ParameterSet(boolean_, string, string));
+ * combination.add(new ParameterSet(boolean_, time, time));
+ * combination.add(new ParameterSet(boolean_, datetime, datetime));
+ * combination.add(new ParameterSet(boolean_, datetimeoffset, datetimeoffset));
+ * combination.add(new ParameterSet(boolean_, guid, guid));
+ * combination.add(new ParameterSet(boolean_, sbyte, sbyte));
+ * combination.add(new ParameterSet(boolean_, byte_, byte_));
+ * combination.add(new ParameterSet(boolean_, int16, int16));
+ * combination.add(new ParameterSet(boolean_, int32, int32));
+ * combination.add(new ParameterSet(boolean_, int64, int64));
+ * combination.add(new ParameterSet(boolean_, single, single));
+ * combination.add(new ParameterSet(boolean_, double_, double_));
+ * combination.add(new ParameterSet(boolean_, decimal, decimal));
+ * combination.add(new ParameterSet(boolean_, binary, binary));
+ */
+
+ lAvailableBinaryOperators.put(BinaryOperator.EQ.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.EQ,
+ "Equality", 30, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.NE.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.NE,
+ "Equality", 30, combination));
+
+ // "---Conditinal AND---
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, boolean_, boolean_));
- lAvailableBinaryOperators.put(BinaryOperator.AND.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.AND, "Conditinal", 20, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.AND.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.AND,
+ "Conditinal", 20, combination));
- //---Conditinal OR---
+ // ---Conditinal OR---
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, boolean_, boolean_));
- lAvailableBinaryOperators.put(BinaryOperator.OR.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.OR, "Conditinal", 10, combination));
+ lAvailableBinaryOperators.put(BinaryOperator.OR.toUriLiteral(), new InfoBinaryOperator(BinaryOperator.OR,
+ "Conditinal", 10, combination));
- //endswith
+ // endswith
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, string, string));
- lAvailableMethods.put(MethodOperator.ENDSWITH.toUriLiteral(), new InfoMethod(MethodOperator.ENDSWITH, 2, 2, combination));
+ lAvailableMethods.put(MethodOperator.ENDSWITH.toUriLiteral(), new InfoMethod(MethodOperator.ENDSWITH, 2, 2,
+ combination));
- //indexof
+ // indexof
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, string, string));
- lAvailableMethods.put(MethodOperator.INDEXOF.toUriLiteral(), new InfoMethod(MethodOperator.INDEXOF, 2, 2, combination));
+ lAvailableMethods.put(MethodOperator.INDEXOF.toUriLiteral(), new InfoMethod(MethodOperator.INDEXOF, 2, 2,
+ combination));
- //startswith
+ // startswith
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, string, string));
- lAvailableMethods.put(MethodOperator.STARTSWITH.toUriLiteral(), new InfoMethod(MethodOperator.STARTSWITH, 2, 2, combination));
+ lAvailableMethods.put(MethodOperator.STARTSWITH.toUriLiteral(), new InfoMethod(MethodOperator.STARTSWITH, 2, 2,
+ combination));
- //tolower
+ // tolower
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(string, string));
lAvailableMethods.put(MethodOperator.TOLOWER.toUriLiteral(), new InfoMethod(MethodOperator.TOLOWER, combination));
- //toupper
+ // toupper
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(string, string));
lAvailableMethods.put(MethodOperator.TOUPPER.toUriLiteral(), new InfoMethod(MethodOperator.TOUPPER, combination));
- //trim
+ // trim
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(string, string));
lAvailableMethods.put(MethodOperator.TRIM.toUriLiteral(), new InfoMethod(MethodOperator.TRIM, combination));
- //substring
+ // substring
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(string, string, int32));
combination.add(new ParameterSet(string, string, int32, int32));
- lAvailableMethods.put(MethodOperator.SUBSTRING.toUriLiteral(), new InfoMethod(MethodOperator.SUBSTRING, 1, -1, combination));
+ lAvailableMethods.put(MethodOperator.SUBSTRING.toUriLiteral(), new InfoMethod(MethodOperator.SUBSTRING, 1, -1,
+ combination));
- //substringof
+ // substringof
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, string, string));
- lAvailableMethods.put(MethodOperator.SUBSTRINGOF.toUriLiteral(), new InfoMethod(MethodOperator.SUBSTRINGOF, 1, -1, combination));
+ lAvailableMethods.put(MethodOperator.SUBSTRINGOF.toUriLiteral(), new InfoMethod(MethodOperator.SUBSTRINGOF, 1, -1,
+ combination));
- //concat
+ // concat
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(string, string, string).setFurtherType(string));
- lAvailableMethods.put(MethodOperator.CONCAT.toUriLiteral(), new InfoMethod(MethodOperator.CONCAT, 2, -1, combination));
+ lAvailableMethods.put(MethodOperator.CONCAT.toUriLiteral(), new InfoMethod(MethodOperator.CONCAT, 2, -1,
+ combination));
- //length
+ // length
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, string));
lAvailableMethods.put(MethodOperator.LENGTH.toUriLiteral(), new InfoMethod(MethodOperator.LENGTH, combination));
- //year
+ // year
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
lAvailableMethods.put(MethodOperator.YEAR.toUriLiteral(), new InfoMethod(MethodOperator.YEAR, combination));
- //month
+ // month
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
lAvailableMethods.put(MethodOperator.MONTH.toUriLiteral(), new InfoMethod(MethodOperator.MONTH, combination));
- //day
+ // day
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
lAvailableMethods.put(MethodOperator.DAY.toUriLiteral(), new InfoMethod(MethodOperator.DAY, combination));
- //hour
+ // hour
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
combination.add(new ParameterSet(int32, time));
combination.add(new ParameterSet(int32, datetimeoffset));
lAvailableMethods.put(MethodOperator.HOUR.toUriLiteral(), new InfoMethod(MethodOperator.HOUR, combination));
- //minute
+ // minute
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
combination.add(new ParameterSet(int32, time));
combination.add(new ParameterSet(int32, datetimeoffset));
lAvailableMethods.put(MethodOperator.MINUTE.toUriLiteral(), new InfoMethod(MethodOperator.MINUTE, combination));
- //second
+ // second
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(int32, datetime));
combination.add(new ParameterSet(int32, time));
combination.add(new ParameterSet(int32, datetimeoffset));
lAvailableMethods.put(MethodOperator.SECOND.toUriLiteral(), new InfoMethod(MethodOperator.SECOND, combination));
- //round
+ // round
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(decimal, decimal));
combination.add(new ParameterSet(double_, double_));
lAvailableMethods.put(MethodOperator.ROUND.toUriLiteral(), new InfoMethod(MethodOperator.ROUND, combination));
- //ceiling
+ // ceiling
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(decimal, decimal));
combination.add(new ParameterSet(double_, double_));
lAvailableMethods.put(MethodOperator.CEILING.toUriLiteral(), new InfoMethod(MethodOperator.CEILING, combination));
- //floor
+ // floor
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(decimal, decimal));
combination.add(new ParameterSet(double_, double_));
lAvailableMethods.put(MethodOperator.FLOOR.toUriLiteral(), new InfoMethod(MethodOperator.FLOOR, combination));
- //---unary---
+ // ---unary---
- //minus
+ // minus
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(sbyte, sbyte));
combination.add(new ParameterSet(byte_, byte_));
@@ -840,13 +901,15 @@ public class FilterParserImpl implements FilterParser {
combination.add(new ParameterSet(double_, double_));
combination.add(new ParameterSet(decimal, decimal));
- //minus
- lAvailableUnaryOperators.put(UnaryOperator.MINUS.toUriLiteral(), new InfoUnaryOperator(UnaryOperator.MINUS, "minus", combination));
+ // minus
+ lAvailableUnaryOperators.put(UnaryOperator.MINUS.toUriLiteral(), new InfoUnaryOperator(UnaryOperator.MINUS,
+ "minus", combination));
- //not
+ // not
combination = new ParameterSetCombination.PSCflex();
combination.add(new ParameterSet(boolean_, boolean_));
- lAvailableUnaryOperators.put(UnaryOperator.NOT.toUriLiteral(), new InfoUnaryOperator(UnaryOperator.NOT, "not", combination));
+ lAvailableUnaryOperators.put(UnaryOperator.NOT.toUriLiteral(), new InfoUnaryOperator(UnaryOperator.NOT, "not",
+ combination));
availableBinaryOperators = Collections.unmodifiableMap(lAvailableBinaryOperators);
availableMethods = Collections.unmodifiableMap(lAvailableMethods);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoBinaryOperator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoBinaryOperator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoBinaryOperator.java
index 4c66a98..47958b3 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoBinaryOperator.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoBinaryOperator.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -25,7 +25,7 @@ import org.apache.olingo.odata2.api.uri.expression.BinaryOperator;
/**
* Describes a binary operator which is allowed in OData expressions
- *
+ *
*/
class InfoBinaryOperator {
private BinaryOperator operator;
@@ -34,7 +34,8 @@ class InfoBinaryOperator {
private int priority;
ParameterSetCombination combination;
- public InfoBinaryOperator(final BinaryOperator operator, final String category, final int priority, final ParameterSetCombination combination) {
+ public InfoBinaryOperator(final BinaryOperator operator, final String category, final int priority,
+ final ParameterSetCombination combination) {
this.operator = operator;
this.category = category;
syntax = operator.toUriLiteral();
@@ -58,7 +59,8 @@ class InfoBinaryOperator {
return priority;
}
- public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
+ public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes)
+ throws ExpressionParserInternalError {
return combination.validate(actualParameterTypes);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoMethod.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoMethod.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoMethod.java
index 95ca87e..400cbd0 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoMethod.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoMethod.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -25,7 +25,7 @@ import org.apache.olingo.odata2.api.uri.expression.MethodOperator;
/**
* Describes a method expression which is allowed in OData expressions
- *
+ *
*/
class InfoMethod {
@@ -43,7 +43,8 @@ class InfoMethod {
this.combination = combination;
}
- public InfoMethod(final MethodOperator method, final int minParameters, final int maxParameters, final ParameterSetCombination combination) {
+ public InfoMethod(final MethodOperator method, final int minParameters, final int maxParameters,
+ final ParameterSetCombination combination) {
this.method = method;
syntax = method.toUriLiteral();
minParameter = minParameters;
@@ -51,7 +52,8 @@ class InfoMethod {
this.combination = combination;
}
- public InfoMethod(final MethodOperator method, final String string, final int minParameters, final int maxParameters, final ParameterSetCombination combination) {
+ public InfoMethod(final MethodOperator method, final String string, final int minParameters, final int maxParameters,
+ final ParameterSetCombination combination) {
this.method = method;
syntax = string;
minParameter = minParameters;
@@ -75,13 +77,14 @@ class InfoMethod {
return maxParameter;
}
- public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
+ public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes)
+ throws ExpressionParserInternalError {
return combination.validate(actualParameterTypes);
}
/**
* Returns the EdmType of the returned value of a Method
- * If a method may have different return types (depending on the input type) null will be returned.
+ * If a method may have different return types (depending on the input type) null will be returned.
*/
public EdmType getReturnType() {
return combination.getReturnType();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoUnaryOperator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoUnaryOperator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoUnaryOperator.java
index ac784d1..de8bf86 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoUnaryOperator.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InfoUnaryOperator.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -25,7 +25,7 @@ import org.apache.olingo.odata2.api.uri.expression.UnaryOperator;
/**
* Describes a unary operator which is allowed in OData expressions
- *
+ *
*/
class InfoUnaryOperator {
UnaryOperator operator;
@@ -33,7 +33,8 @@ class InfoUnaryOperator {
private String syntax;
ParameterSetCombination combination;
- public InfoUnaryOperator(final UnaryOperator operator, final String category, final ParameterSetCombination combination) {
+ public InfoUnaryOperator(final UnaryOperator operator, final String category,
+ final ParameterSetCombination combination) {
this.operator = operator;
this.category = category;
syntax = operator.toUriLiteral();
@@ -52,31 +53,33 @@ class InfoUnaryOperator {
return operator;
}
- public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
+ public ParameterSet validateParameterSet(final List<EdmType> actualParameterTypes)
+ throws ExpressionParserInternalError {
return combination.validate(actualParameterTypes);
}
/**
* Returns the EdmType of the returned value of a Method
- * If a method may have different return types (depending on the input type) null will be returned.
+ * If a method may have different return types (depending on the input type) null will be returned.
*/
/*
- public EdmType getReturnType()
- {
- int parameterCount = allowedParameterTypes.size();
- if (parameterCount == 0)
- return null;
-
- if (parameterCount == 1)
- return allowedParameterTypes.get(0).getReturnType();
-
- //There are more than 1 possible return type, check if they are equal, if not return null.
- EdmType returnType = allowedParameterTypes.get(0).getReturnType();
- for (int i = 1; i < parameterCount; i++)
- if (returnType != allowedParameterTypes.get(i))
- return null;
-
- return returnType;
- }*/
+ * public EdmType getReturnType()
+ * {
+ * int parameterCount = allowedParameterTypes.size();
+ * if (parameterCount == 0)
+ * return null;
+ *
+ * if (parameterCount == 1)
+ * return allowedParameterTypes.get(0).getReturnType();
+ *
+ * //There are more than 1 possible return type, check if they are equal, if not return null.
+ * EdmType returnType = allowedParameterTypes.get(0).getReturnType();
+ * for (int i = 1; i < parameterCount; i++)
+ * if (returnType != allowedParameterTypes.get(i))
+ * return null;
+ *
+ * return returnType;
+ * }
+ */
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InputTypeValidator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InputTypeValidator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InputTypeValidator.java
index 246b769..e3e2d19 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InputTypeValidator.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/InputTypeValidator.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -24,13 +24,15 @@ import org.apache.olingo.odata2.api.edm.EdmType;
public interface InputTypeValidator {
- public EdmType validateParameterSet(List<ParameterSet> allowedParameterTypes, List<EdmType> actualParameterTypes) throws ExpressionParserInternalError;
+ public EdmType validateParameterSet(List<ParameterSet> allowedParameterTypes, List<EdmType> actualParameterTypes)
+ throws ExpressionParserInternalError;
public static class TypePromotionValidator implements InputTypeValidator {
@Override
- public EdmType validateParameterSet(final List<ParameterSet> allowedParameterTypes, final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
- //first check for exact parameter combination
+ public EdmType validateParameterSet(final List<ParameterSet> allowedParameterTypes,
+ final List<EdmType> actualParameterTypes) throws ExpressionParserInternalError {
+ // first check for exact parameter combination
for (ParameterSet parameterSet : allowedParameterTypes) {
boolean s = parameterSet.equals(actualParameterTypes, false);
if (s) {
@@ -38,7 +40,7 @@ public interface InputTypeValidator {
}
}
- //first check for parameter combination with promotion
+ // first check for parameter combination with promotion
for (ParameterSet parameterSet : allowedParameterTypes) {
boolean s = parameterSet.equals(actualParameterTypes, true);
if (s) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/JsonVisitor.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/JsonVisitor.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/JsonVisitor.java
index 4289bc5..d1f4b98 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/JsonVisitor.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/JsonVisitor.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
@@ -50,16 +50,21 @@ import org.apache.olingo.odata2.core.ep.util.JsonStreamWriter;
public class JsonVisitor implements ExpressionVisitor {
@Override
- public Object visitFilterExpression(final FilterExpression filterExpression, final String expressionString, final Object expression) {
+ public Object visitFilterExpression(final FilterExpression filterExpression, final String expressionString,
+ final Object expression) {
return expression;
}
@Override
- public Object visitBinary(final BinaryExpression binaryExpression, final BinaryOperator operator, final Object leftSide, final Object rightSide) {
+ public Object visitBinary(final BinaryExpression binaryExpression, final BinaryOperator operator,
+ final Object leftSide, final Object rightSide) {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", binaryExpression.getKind().toString()).separator().namedStringValue("operator", operator.toUriLiteral()).separator().namedStringValueRaw("type", getType(binaryExpression)).separator().name("left").unquotedValue(leftSide.toString()).separator().name("right").unquotedValue(rightSide.toString()).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", binaryExpression.getKind().toString()).separator()
+ .namedStringValue("operator", operator.toUriLiteral()).separator().namedStringValueRaw("type",
+ getType(binaryExpression)).separator().name("left").unquotedValue(leftSide.toString()).separator().name(
+ "right").unquotedValue(rightSide.toString()).endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
@@ -68,11 +73,13 @@ public class JsonVisitor implements ExpressionVisitor {
}
@Override
- public Object visitOrderByExpression(final OrderByExpression orderByExpression, final String expressionString, final List<Object> orders) {
+ public Object visitOrderByExpression(final OrderByExpression orderByExpression, final String expressionString,
+ final List<Object> orders) {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", "order collection").separator().name("orders").beginArray();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", "order collection").separator().name("orders")
+ .beginArray();
boolean first = true;
for (final Object order : orders) {
if (first) {
@@ -91,11 +98,14 @@ public class JsonVisitor implements ExpressionVisitor {
}
@Override
- public Object visitOrder(final OrderExpression orderExpression, final Object filterResult, final SortOrder sortOrder) {
+ public Object visitOrder(final OrderExpression orderExpression, final Object filterResult,
+ final SortOrder sortOrder) {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", orderExpression.getKind().toString()).separator().namedStringValueRaw("sortorder", sortOrder.toString()).separator().name("expression").unquotedValue(filterResult.toString()).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", orderExpression.getKind().toString()).separator()
+ .namedStringValueRaw("sortorder", sortOrder.toString()).separator().name("expression").unquotedValue(
+ filterResult.toString()).endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
@@ -108,7 +118,9 @@ public class JsonVisitor implements ExpressionVisitor {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", literal.getKind().toString()).separator().namedStringValueRaw("type", getType(literal)).separator().namedStringValue("value", edmLiteral.getLiteral()).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", literal.getKind().toString()).separator()
+ .namedStringValueRaw("type", getType(literal)).separator().namedStringValue("value", edmLiteral.getLiteral())
+ .endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
@@ -117,11 +129,14 @@ public class JsonVisitor implements ExpressionVisitor {
}
@Override
- public Object visitMethod(final MethodExpression methodExpression, final MethodOperator method, final List<Object> parameters) {
+ public Object visitMethod(final MethodExpression methodExpression, final MethodOperator method,
+ final List<Object> parameters) {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", methodExpression.getKind().toString()).separator().namedStringValueRaw("operator", method.toUriLiteral()).separator().namedStringValueRaw("type", getType(methodExpression)).separator().name("parameters").beginArray();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", methodExpression.getKind().toString()).separator()
+ .namedStringValueRaw("operator", method.toUriLiteral()).separator().namedStringValueRaw("type",
+ getType(methodExpression)).separator().name("parameters").beginArray();
boolean first = true;
for (Object parameter : parameters) {
if (first) {
@@ -144,7 +159,9 @@ public class JsonVisitor implements ExpressionVisitor {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", memberExpression.getKind().toString()).separator().namedStringValueRaw("type", getType(memberExpression)).separator().name("source").unquotedValue(path.toString()).separator().name("path").unquotedValue(property.toString()).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", memberExpression.getKind().toString()).separator()
+ .namedStringValueRaw("type", getType(memberExpression)).separator().name("source").unquotedValue(
+ path.toString()).separator().name("path").unquotedValue(property.toString()).endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
@@ -153,11 +170,14 @@ public class JsonVisitor implements ExpressionVisitor {
}
@Override
- public Object visitProperty(final PropertyExpression propertyExpression, final String uriLiteral, final EdmTyped edmProperty) {
+ public Object visitProperty(final PropertyExpression propertyExpression, final String uriLiteral,
+ final EdmTyped edmProperty) {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", propertyExpression.getKind().toString()).separator().namedStringValue("name", uriLiteral).separator().namedStringValueRaw("type", getType(propertyExpression)).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", propertyExpression.getKind().toString())
+ .separator().namedStringValue("name", uriLiteral).separator().namedStringValueRaw("type",
+ getType(propertyExpression)).endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
@@ -170,7 +190,9 @@ public class JsonVisitor implements ExpressionVisitor {
try {
StringWriter writer = new StringWriter();
JsonStreamWriter jsonStreamWriter = new JsonStreamWriter(writer);
- jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", unaryExpression.getKind().toString()).separator().namedStringValueRaw("operator", operator.toUriLiteral()).separator().namedStringValueRaw("type", getType(unaryExpression)).separator().name("operand").unquotedValue(operand.toString()).endObject();
+ jsonStreamWriter.beginObject().namedStringValueRaw("nodeType", unaryExpression.getKind().toString()).separator()
+ .namedStringValueRaw("operator", operator.toUriLiteral()).separator().namedStringValueRaw("type",
+ getType(unaryExpression)).separator().name("operand").unquotedValue(operand.toString()).endObject();
writer.flush();
return writer.toString();
} catch (final IOException e) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/LiteralExpressionImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/LiteralExpressionImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/LiteralExpressionImpl.java
index bc41e28..f08b46b 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/LiteralExpressionImpl.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/LiteralExpressionImpl.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/MemberExpressionImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/MemberExpressionImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/MemberExpressionImpl.java
index 7bbc278..ae9e6cc 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/MemberExpressionImpl.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/uri/expression/MemberExpressionImpl.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
******************************************************************************/
package org.apache.olingo.odata2.core.uri.expression;