[OLINGO-63] Uri Parser: Add test cases for key predicates, select,expand and code cleanup

This commit is contained in:
Sven Kobler 2014-01-24 14:05:20 +01:00
parent 757eb54c08
commit 1ef03f92f4
137 changed files with 2504 additions and 1918 deletions

View File

@ -16,28 +16,20 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.antlr;
package org.apache.olingo.odata4.commons.api.exception;
public class ParserException extends Exception {
/**
*
*/
public class ODataApplicationException extends Exception {
private static final long serialVersionUID = 1L;
public ParserException() {
super();
}
public ParserException(final String msg) {
public ODataApplicationException(final String msg) {
super(msg);
}
public ParserException(final String msg, final Throwable e) {
public ODataApplicationException(final String msg, final Throwable e) {
super(msg, e);
}
public ParserException(final Throwable e) {
public ODataApplicationException(final Throwable e) {
super(e);
}

View File

@ -22,7 +22,7 @@ package org.apache.olingo.odata4.producer.api.uri;
public interface UriInfo extends
UriInfoService, UriInfoAll, UriInfoBatch, UriInfoCrossjoin,
UriInfoEntityId, UriInfoMetadata, UriInfoResource {
public UriInfoService asUriInfoService();
public UriInfoAll asUriInfoAll();

View File

@ -19,6 +19,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public interface UriInfoAll {
public interface UriInfoAll {
}

View File

@ -19,6 +19,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public interface UriInfoBatch {
public interface UriInfoBatch {
}

View File

@ -32,7 +32,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
* Indicates a URL access to an single Entity
*/
public interface UriInfoEntityId {
public List<CustomQueryOption> getCustomQueryOptions();
public EdmEntityType getEntityTypeCast();

View File

@ -22,7 +22,9 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption;
public interface UriInfoMetadata {
public String getContext();
public FormatOption getFormatOption();
}

View File

@ -30,7 +30,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
public interface UriInfoResource {
@ -55,7 +55,7 @@ public interface UriInfoResource {
SkipOption getSkipOption();
SkipTokenOption getSkipTokenOption();
SkiptokenOption getSkipTokenOption();
TopOption getTopOption();

View File

@ -22,9 +22,12 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expressi
public interface UriParameter {
public String getAlias();
public String getText();
public Expression getExression();
public String getName();
public String getAlias();
public String getText();
public Expression getExression();
public String getName();
}

View File

@ -26,7 +26,7 @@ public interface UriResourceAction extends UriResourcePartTyped {
EdmAction getAction();
/**
* Convenience method which return the {@link EdmActionImport} which was used in
* Convenience method which returns the {@link EdmActionImport} which was used in
* the resource path to define the {@link EdmAction}.
* @return
*/

View File

@ -21,6 +21,9 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface UriResourceAll extends UriResourcePartTyped {
public String getLamdaVariable();
public Expression getExpression();
}

View File

@ -21,6 +21,9 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface UriResourceAny extends UriResourcePartTyped {
public String getLamdaVariable();
public Expression getExpression();
}

View File

@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
public interface UriResourceComplexProperty extends UriResourceProperty {
EdmComplexType getComplexType();
EdmComplexType getComplexTypeFilter();

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
public interface UriResourceCount extends UriResourcePart {
}

View File

@ -26,7 +26,6 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceEntitySet extends UriResourcePartTyped {
EdmEntitySet getEntitySet();
EdmEntityType getEntityType();

View File

@ -26,11 +26,10 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceFunction extends UriResourcePartTyped {
EdmFunction getFunction();
/**
* Convenience method which return the {@link EdmFunctionImport} which was used in
* Convenience method which returns the {@link EdmFunctionImport} which was used in
* the resource path to define the {@link EdmFunction}.
* @return
*/

View File

@ -22,11 +22,15 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
/**
* Class indicating the $it reference. $it may be used within filter to
* refer to the last EDM object reference in the resource path.
* refer to the last EDM object reference in the resource path. Since $it is
* optional in some cases ( e.g. first member expressions) the {@link #isExplicitIt()}
* method can be used to check if $it was explicitly noted in the URI
*/
public interface UriResourceIt extends UriResourcePartTyped {
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
boolean isExplicitIt();
boolean isExplicitIt();
}

View File

@ -20,7 +20,6 @@
package org.apache.olingo.odata4.producer.api.uri;
public enum UriResourceKind {
action, entitySet, function, it, singleton, navigationProperty,
simpleProperty, complexProperty, value, count, ref, root, lamdaAll, lamdaAny
action, complexProperty, count, entitySet, function, it, lambdaAll, lambdaAny,
lambdaVariable, navigationProperty, ref, root, simpleProperty, singleton, value,
}

View File

@ -1,5 +1,4 @@
/*******************************************************************************
*
* 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
@ -17,20 +16,18 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
package org.apache.olingo.odata4.producer.api.uri;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmElement;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface ExpandVisitor<T> {
/**
* Class indicating the $it reference. $it may be used within filter to
* refer to the last EDM object reference in the resource path. Since $it is
* optional in some cases ( e.g. first member expressions) the {@link #isExplicitIt()}
* method can be used to check if $it was explicitly noted in the URI
*/
public interface UriResourceLambdaRef extends UriResourcePartTyped {
T visitExpandSegment(EdmElement property, EdmType initialType, EdmType finalType);
T visitExpandItem(List<T> expandSegments, boolean isStar, boolean isRef, EdmType finalType);
T visitExpand(List<T> expandItems);
public String getVariableText();
}

View File

@ -24,10 +24,13 @@ import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceNavigation extends UriResourcePartTyped {
List<UriParameter> getKeyPredicates();
EdmNavigationProperty getNavigationProperty();
EdmType getTypeFilterOnCollection();
EdmType getTypeFilterOnEntry();
}

View File

@ -18,7 +18,11 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
public interface UriResourcePart {
UriResourceKind getKind();
@Override
String toString();
}

View File

@ -22,7 +22,9 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourcePartTyped extends UriResourcePart {
EdmType getType();
boolean isCollection();
}

View File

@ -21,5 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
public interface UriResourceProperty extends UriResourcePartTyped {
EdmProperty getProperty();
}

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
public interface UriResourceRef extends UriResourcePart {
}

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
public interface UriResourceSimpleProperty extends UriResourceProperty {
public interface UriResourceSimpleProperty extends UriResourceProperty{
}

View File

@ -18,15 +18,15 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmComplexType;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmSingleton;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceSingleton extends UriResourcePartTyped {
EdmSingleton getSingleton();
EdmEntityType getEntityType();
EdmEntityType getEntityTypeFilter();
}

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
public interface UriResourceValue extends UriResourcePart {
}

View File

@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface AliasQueryOption extends QueryOption {
public Expression getAliasValue();
public Expression getAliasValue();
}

View File

@ -20,9 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
public class ExceptionVisitExpand extends Exception {
/**
*
*/
private static final long serialVersionUID = 822365726050299076L;
private static final long serialVersionUID = 1L;
}

View File

@ -18,14 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
public interface ExpandItem {
boolean isStar();
List<UriResourceProperty> getPropertyChainList();
LevelExpandOption getLevel();
@ -44,4 +39,11 @@ public interface ExpandItem {
SelectOption getSelect();
ExpandOption getExpand();
UriInfoResource getPath();
boolean isStar();
boolean isRef();
}

View File

@ -21,5 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
public interface ExpandOption extends SystemQueryOption {
List<ExpandItem> getExpandItems();
}

View File

@ -21,5 +21,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
public interface FilterOption extends SystemQueryOption {
Expression getExpression();
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface FormatOption extends SystemQueryOption {
// TODO select best representation for format
// TODO Select best representation for format
Object getFormat();
}

View File

@ -19,5 +19,7 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface IdOption extends SystemQueryOption {
String getIdValue();
}

View File

@ -19,5 +19,7 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface InlineCountOption extends SystemQueryOption {
boolean getInlineCountValue();
boolean getvalue();
}

View File

@ -22,6 +22,6 @@ public interface LevelExpandOption {
boolean isMax();
String getLevel();
int getLevel();
}

View File

@ -28,7 +28,7 @@ public interface OrderByItem {
* @return if false (default) the sort order is ascending, if true the sort order is descending
*/
boolean isDescending();
Expression getExpression();
}

View File

@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
public interface OrderByOption extends SystemQueryOption {
List<OrderByItem> getOrders();
}

View File

@ -23,4 +23,5 @@ public interface QueryOption {
public String getName();
public String getText();
}

View File

@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.search.SearchExpression;
public interface SearchOption extends SystemQueryOption {
SearchExpression getSearchExpression();
}

View File

@ -35,9 +35,6 @@ public interface SelectItem {
EdmEntityType getEntityTypeCast();
EdmAction getAction();
EdmFunction getFunction();
List<UriResourceProperty> getPropertyChainList();
}

View File

@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
import java.util.List;
public interface SelectOption extends SystemQueryOption {
List<SelectItem> getSelectItems();
}

View File

@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface SkipOption extends SystemQueryOption {
String getSkipValue();
String getValue();
}

View File

@ -1,26 +0,0 @@
/*******************************************************************************
*
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface SkipTokenOption extends SystemQueryOption{
String getSkipTokenValue();
}

View File

@ -18,3 +18,9 @@
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface SkiptokenOption extends SystemQueryOption {
String getValue();
}

View File

@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public enum SystemQueryOptionEnum {
public enum SupportedQueryOptions {
FILTER("$filter"),
FORMAT("$format"),
EXPAND("$expand"),
@ -34,7 +34,7 @@ public enum SystemQueryOptionEnum {
String syntax;
private SystemQueryOptionEnum(final String syntax) {
private SupportedQueryOptions(final String syntax) {
this.syntax = syntax;
}

View File

@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface SystemQueryOption extends QueryOption {
SystemQueryOptionEnum getKind();
SupportedQueryOptions getKind();
}

View File

@ -18,6 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
public interface TopOption extends SystemQueryOption{
public interface TopOption extends SystemQueryOption {
String getTopValue();
}

View File

@ -1,48 +0,0 @@
/*******************************************************************************
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
/* TODO update documentation*/
public interface VisitableExpand {
/**
* Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on
* each
* expression used as node in an expression tree. The implementations should
* behave as follows:
* <li>Call accept on all sub nodes and store the returned Objects
* <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that
* instance
* <li>Return the object which should be passed to the processing algorithm of the parent expression node
* <br>
* <br>
* @param visitor
* Object ( implementing {@link ExpressionVisitor}) whose methods are called during traversing a expression node of
* the expression tree.
* @return
* Object which should be passed to the processing algorithm of the parent expression node
* @throws ExceptionVisitExpression
* Exception occurred the OData library while traversing the tree
* @throws ODataApplicationException
* Exception thrown by the application who implemented the visitor
*/
<T> T accept(ExpandVisitor<T> visitor) throws ExceptionVisitExpand;
}

View File

@ -18,7 +18,7 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface BinaryExpression {
public interface BinaryExpression extends Expression {
public SupportedBinaryOperators getOperator();

View File

@ -16,13 +16,10 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public class ExceptionVisitExpression extends Exception {
/**
*
*/
private static final long serialVersionUID = 822365726050299076L;
private static final long serialVersionUID = 1L;
}

View File

@ -18,6 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface Expression {
public interface Expression extends VisitableExression {
}

View File

@ -16,25 +16,37 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import java.util.List;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedUnaryOperators;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
public interface ExpressionVisitor<T> {
T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right) throws ExceptionVisitExpression;
T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right)
throws ExceptionVisitExpression, ODataApplicationException;
T visitUnaryOperator(SupportedUnaryOperators operator, T operand) throws ExceptionVisitExpression;
T visitUnaryOperator(SupportedUnaryOperators operator, T operand)
throws ExceptionVisitExpression, ODataApplicationException;
T visitMethodCall(SupportedMethodCalls methodCall, List<T> parameters) throws ExceptionVisitExpression;
T visitMethodCall(SupportedMethodCalls methodCall, List<T> parameters)
throws ExceptionVisitExpression, ODataApplicationException;
T visitLambdaExpression(String variableText, Expression expression)
throws ExceptionVisitExpression, ODataApplicationException;
T visitLiteral(String literal) throws ExceptionVisitExpression;
T visitLiteral(String literal) throws ExceptionVisitExpression, ODataApplicationException;
T visitMember(MemberImpl member) throws ExceptionVisitExpression;
T visitMember(UriInfoResource member) throws ExceptionVisitExpression, ODataApplicationException;
T visitAlias(String referenceName) throws ExceptionVisitExpression;
T visitAlias(String referenceName) throws ExceptionVisitExpression, ODataApplicationException;
T visitTypeLiteral(EdmType type) throws ExceptionVisitExpression, ODataApplicationException;
T visitLambdaReference(String variableText) throws ExceptionVisitExpression, ODataApplicationException;
}

View File

@ -18,8 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface LambdaRef {
public interface LambdaRef extends Expression {
public String getVariableText();
public String getVariableName();
}

View File

@ -18,8 +18,8 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface Literal {
public interface Literal extends Expression {
public String getText();
public String getText();
}

View File

@ -20,10 +20,8 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
public interface Member {
public interface Member extends Expression {
public boolean isIT();
public UriInfoResource getPath();
public UriInfoResource getPath();
}

View File

@ -20,12 +20,10 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import java.util.List;
public interface MethodCall {
public interface MethodCall extends Expression {
public SupportedMethodCalls getMethod();
public List<Expression> getParameters();
}

View File

@ -19,17 +19,17 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public enum SupportedBinaryOperators {
//multiplicative
// multiplicative
MUL("mul"), DIV("div"), MOD("mod"),
//additive
// additive
ADD("add"), SUB("sub"),
//comparism
// comparism
GT("gt"), GE("ge"), LT("lt"), LE("le"),
//isof
// isof
ISOF("isof"),
//equality
// equality
EQ("eq"), NE("ne"),
//and/or
// and/or
AND("and"), OR("or");
private String syntax;
@ -38,7 +38,7 @@ public enum SupportedBinaryOperators {
this.syntax = syntax;
}
public static SupportedBinaryOperators get(String operator) {
public static SupportedBinaryOperators get(final String operator) {
for (SupportedBinaryOperators op : SupportedBinaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;
@ -46,11 +46,10 @@ public enum SupportedBinaryOperators {
}
return null;
}
@Override
public String toString() {
return syntax;
}
}

View File

@ -19,18 +19,18 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public enum SupportedMethodCalls {
CONTAINS("contains"),STARTSWITH("startswith"),ENDSWITH("endswith"),LENGTH("length"),
INDEXOF("indexof"),SUBSTRING("substring"),TOLOWER("tolower"),TOUPPER("toupper"),TRIM("trim"),
CONTAINS("contains"), STARTSWITH("startswith"), ENDSWITH("endswith"), LENGTH("length"),
INDEXOF("indexof"), SUBSTRING("substring"), TOLOWER("tolower"), TOUPPER("toupper"), TRIM("trim"),
CONCAT("concat"),
YEAR("year"),MONTH("month"),DAY("day"),HOUR("hour"),MINUTE("minute"),SECOND("second"),
FRACTIONALSECOND("fractionalsecond"),TOTALSECONDS("totalseconds"),DATE("date"),TIME("time"),
TOTALOFFSETMINUTES("totaloffsetminutes"),MINDATETIME("mindatetime"),MAXDATETIME("maxdatetime"),NOW("now"),
ROUND("round"),FLOOR("floor"),
CEILING("ceiling"),DISTANCE("distance"),GEOLENGTH("geolength"),INTERSECTS("intersects"), CAST("cast"), ISOF("isof");
YEAR("year"), MONTH("month"), DAY("day"), HOUR("hour"), MINUTE("minute"), SECOND("second"),
FRACTIONALSECOND("fractionalsecond"), TOTALSECONDS("totalseconds"), DATE("date"), TIME("time"),
TOTALOFFSETMINUTES("totaloffsetminutes"), MINDATETIME("mindatetime"), MAXDATETIME("maxdatetime"), NOW("now"),
ROUND("round"), FLOOR("floor"),
CEILING("ceiling"), DISTANCE("distance"), GEOLENGTH("geolength"), INTERSECTS("intersects"), CAST("cast"),
ISOF("isof");
private String syntax;
@ -43,9 +43,9 @@ public enum SupportedMethodCalls {
return syntax;
}
public static SupportedMethodCalls get(String operator) {
public static SupportedMethodCalls get(final String operator) {
for (SupportedMethodCalls op : SupportedMethodCalls.values()) {
if (op.toString().equals(operator+'(')) {
if (op.toString().equals(operator + '(')) {
return op;
}
}

View File

@ -32,7 +32,7 @@ public enum SupportedUnaryOperators {
return syntax;
}
public static SupportedUnaryOperators get(String operator) {
public static SupportedUnaryOperators get(final String operator) {
for (SupportedUnaryOperators op : SupportedUnaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;
@ -40,5 +40,5 @@ public enum SupportedUnaryOperators {
}
return null;
}
}

View File

@ -20,10 +20,8 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface TypeLiteral {
public EdmType getType();
public interface TypeLiteral extends Expression {
public EdmType getType();
}

View File

@ -18,10 +18,10 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
public interface UnaryOperator {
public interface UnaryOperator extends Expression {
public abstract Expression getOperand();
public Expression getOperand();
public abstract SupportedUnaryOperators getOperator();
public SupportedUnaryOperators getOperator();
}

View File

@ -16,39 +16,32 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption.expression;
package org.apache.olingo.odata4.producer.api.uri.queryoption.expression;
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
/* TODO update documentation*/
public interface VisitableExression {
/**
* Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on
* each
* expression used as node in an expression tree. The implementations should
* each expression used as node in an expression tree. The implementations should
* behave as follows:
* <li>Call accept on all sub nodes and store the returned Objects
* <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that
* instance
* <li>Call accept on all sub nodes and store the returned Objects which are of the generic type T
* <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored return objects
* to that instance
* <li>Return the object which should be passed to the processing algorithm of the parent expression node
* <br>
* <br>
* @param visitor
* Object ( implementing {@link ExpressionVisitor}) whose methods are called during traversing a expression node of
* the expression tree.
* Object (implementing {@link ExpressionVisitor}) whose methods are called during traversing a
* expression node of the expression tree.
* @return
* Object which should be passed to the processing algorithm of the parent expression node
* Object of type T which should be passed to the processing algorithm of the parent expression node
* @throws ExceptionVisitExpression
* Exception occurred the OData library while traversing the tree
* @throws ODataApplicationException
* Exception thrown by the application who implemented the visitor
*/
<T> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression;
}
<T> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException;
}

View File

@ -25,4 +25,5 @@ public interface SearchBinary extends SearchExpression {
SearchExpression getLeftOperand();
SearchExpression getRightOperand();
}

View File

@ -19,5 +19,7 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption.search;
public interface SearchTerm extends SearchExpression {
String getSearchTerm();
}

View File

@ -19,5 +19,7 @@
package org.apache.olingo.odata4.producer.api.uri.queryoption.search;
public interface SearchUnary {
SearchExpression getOperand();
}

View File

@ -27,8 +27,13 @@ public enum SupportedSearchBinaryOperators {
private SupportedSearchBinaryOperators(final String syntax) {
this.syntax = syntax;
}
@Override
public String toString() {
return syntax;
}
public static SupportedSearchBinaryOperators get(String operator) {
public static SupportedSearchBinaryOperators get(final String operator) {
for (SupportedSearchBinaryOperators op : SupportedSearchBinaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;
@ -37,8 +42,5 @@ public enum SupportedSearchBinaryOperators {
return null;
}
@Override
public String toString() {
return syntax;
}
}

View File

@ -32,7 +32,7 @@ public enum SupportedSearchUnaryOperators {
return syntax;
}
public static SupportedSearchUnaryOperators get(String operator) {
public static SupportedSearchUnaryOperators get(final String operator) {
for (SupportedSearchUnaryOperators op : SupportedSearchUnaryOperators.values()) {
if (op.toString().equals(operator)) {
return op;

View File

@ -110,7 +110,7 @@ valueOnly : vV=commonExpr ;
nameValueList : WSP* vlNVP+=nameValuePair WSP* ( COMMA WSP* vlNVP+=nameValuePair WSP*)* ;
nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vCOM=commonExpr /*TODO | val2=enumX*/);
constSegment : SLASH (vV=value | vC=count | vR=ref );
constSegment : SLASH (vV=value | vC=count | vR=ref | vAll=allExpr | vAny=anyExpr);
count : COUNT;
ref : REF;
@ -159,8 +159,10 @@ expand : EXPAND EQ vlEI+=expandItem ( COMMA vlEI+=expandItem )*;
expandItem : vS=STAR ( SLASH vR=ref | OPEN LEVELS EQ ( vL=INT | vM=MAX) CLOSE )?
| vEP=expandPath vEPE=expandPathExtension?;
expandPath : expandPathSegment ( SLASH expandPathSegment )*;
expandPathSegment : vNS=namespace? vODI=odataIdentifier;
expandPath : vlPS+=pathSegment (SLASH vlPS+=pathSegment)*;
//expandPath : expandPathSegment ( SLASH expandPathSegment )*;
//expandPathSegment : vNS=namespace? vODI=odataIdentifier;
expandPathExtension : OPEN vlEO+=expandOption ( SEMI vlEO+=expandOption )* CLOSE
| SLASH vR=ref ( OPEN vlEOR+=expandRefOption ( SEMI vlEOR+=expandRefOption )* CLOSE )?

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
@ -32,11 +31,10 @@ import org.antlr.v4.runtime.atn.ATNConfigSet;
import org.antlr.v4.runtime.dfa.DFA;
class ErrorCollector implements ANTLRErrorListener {
private List<Exception> exceptions = new ArrayList<Exception>();
//private ParserValidator tokenValidator;
private List<Exception> exceptions = new ArrayList<Exception>();
// private ParserValidator tokenValidator;
@Override
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
@ -49,7 +47,7 @@ class ErrorCollector implements ANTLRErrorListener {
System.out.println("syntaxError");
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
//fail("syntaxError");
// fail("syntaxError");
}
@Override
@ -58,49 +56,53 @@ class ErrorCollector implements ANTLRErrorListener {
final BitSet ambigAlts, final ATNConfigSet configs) {
/*
if (tokenValidator.logLevel > 0) {
System.out.println("reportAmbiguity: ");
System.out.println(" ambigAlts: " + ambigAlts);
System.out.println(" configs: " + configs);
System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
}*/
/*
if (!tokenValidator.allowAmbiguity) {
printStack(recognizer);
fail("reportAmbiguity");
}*/
* if (tokenValidator.logLevel > 0) {
* System.out.println("reportAmbiguity: ");
* System.out.println(" ambigAlts: " + ambigAlts);
* System.out.println(" configs: " + configs);
* System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
* }
*/
/*
* if (!tokenValidator.allowAmbiguity) {
* printStack(recognizer);
* fail("reportAmbiguity");
* }
*/
}
@Override
public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
final int stopIndex,
final BitSet conflictingAlts, final ATNConfigSet configs) {
/*
// The grammar should be written in order to avoid attempting a full context parse because its negative
// impact on the performance, so trace and stop here
if (tokenValidator.logLevel > 0) {
System.out.println("allowed AttemptingFullContext");
}
if (!tokenValidator.allowFullContext) {
printStack(recognizer);
fail("reportAttemptingFullContext");
}*/
/*
* // The grammar should be written in order to avoid attempting a full context parse because its negative
* // impact on the performance, so trace and stop here
* if (tokenValidator.logLevel > 0) {
* System.out.println("allowed AttemptingFullContext");
* }
*
* if (!tokenValidator.allowFullContext) {
* printStack(recognizer);
* fail("reportAttemptingFullContext");
* }
*/
}
@Override
public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
final int stopIndex, final int prediction,
final ATNConfigSet configs) {
/*
if (tokenValidator.logLevel > 0) {
System.out.println("allowed ContextSensitivity");
}
if (!tokenValidator.allowContextSensitifity) {
printStack(recognizer);
fail("reportContextSensitivity");
}*/
/*
* if (tokenValidator.logLevel > 0) {
* System.out.println("allowed ContextSensitivity");
* }
*
* if (!tokenValidator.allowContextSensitifity) {
* printStack(recognizer);
* fail("reportContextSensitivity");
* }
*/
}
/*
@ -130,8 +132,8 @@ class ErrorCollector implements ANTLRErrorListener {
// String lexerTokenName = TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
String lexerTokenName = "";
try {
//TODO check how the Lexer is accessed in the new package structure
//lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
// TODO check how the Lexer is accessed in the new package structure
// lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
} catch (ArrayIndexOutOfBoundsException es) {
lexerTokenName = "token error";
}

View File

@ -1,25 +0,0 @@
/*******************************************************************************
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class ExpandSegmentCount extends ExpandSegment {
}

View File

@ -1,25 +0,0 @@
/*******************************************************************************
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class ExpandSegmentIt extends ExpandSegment {
}

View File

@ -1,25 +0,0 @@
/*******************************************************************************
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment;
public class ExpandSegmentRef extends ExpandSegment {
}

View File

@ -29,7 +29,7 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
public class ParserAdapter {
public static UriInfoImpl parseUri(final String input, UriParseTreeVisitor uriParseTreeVisitor)
public static UriInfoImpl parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor)
throws UriParserException {
try {
@ -61,10 +61,9 @@ public class ParserAdapter {
// create parser
lexer = new UriLexer(new ANTLRInputStream(input));
parser = new UriParserParser(new CommonTokenStream(lexer));
// TODO create better error collector
parser.addErrorListener(new ErrorCollector());
// bail out of parser at first syntax error. --> proceeds in catch block with step 2
parser.setErrorHandler(new BailErrorStrategy());

View File

@ -44,21 +44,21 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption;
import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.FormatOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.IdOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SearchOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipTokenOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SkiptokenOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.TopOptionImpl;
@ -75,21 +75,17 @@ public class UriInfoImpl implements UriInfo {
private FilterOptionImpl filterOption;
private FormatOptionImpl formatOption;
private IdOption idOption;
private InlineCountImpl inlineCountOption;
private InlineCountOptionImpl inlineCountOption;
private OrderByImpl orderByOption;
private SearchOptionImpl searchOption;
private SelectOptionImpl selectOption;
private SkipOptionImpl skipOption;
private SkipTokenOptionImpl skipTokenOption;
private SkiptokenOptionImpl skipTokenOption;
private TopOptionImpl topOption;
private UriResourcePart lastPathPart;
private UriResourcePart lastResourcePart;
private List<UriResourcePart> pathParts = new ArrayList<UriResourcePart>();
public UriInfoImpl(Edm edm) {
// this.edm = edm;
}
@Override
public UriInfoAll asUriInfoAll() {
return this;
@ -125,26 +121,27 @@ public class UriInfoImpl implements UriInfo {
return Collections.unmodifiableList(entitySetNames);
}
public void addEntitySetName(String entitySet) {
public void addEntitySetName(final String entitySet) {
entitySetNames.add(entitySet);
}
@Override
public List<UriResourcePart> getUriResourceParts() {
List<UriResourcePart> returnList = new ArrayList<UriResourcePart>();
for (UriResourcePart part : pathParts) {
returnList.add(part);
for (UriResourcePart item : pathParts) {
returnList.add(item);
}
return Collections.unmodifiableList(returnList);
}
public void addPathInfo(UriResourcePartImpl uriPathInfo) {
public void addPathInfo(final UriResourcePartImpl uriPathInfo) {
pathParts.add(uriPathInfo);
lastPathPart = uriPathInfo;
lastResourcePart = uriPathInfo;
}
@Override
public String getContext() {
// TODO add support for UTI context part
return null;
}
@ -192,13 +189,12 @@ public class UriInfoImpl implements UriInfo {
return kind;
}
public UriResourcePart getLastUriPathInfo() {
return lastPathPart;
public UriResourcePart getLastResourcePart() {
return lastResourcePart;
}
@Override
public OrderByOption getOrderByOption() {
return orderByOption;
}
@ -219,7 +215,7 @@ public class UriInfoImpl implements UriInfo {
}
@Override
public SkipTokenOption getSkipTokenOption() {
public SkiptokenOption getSkipTokenOption() {
return skipTokenOption;
}
@ -228,13 +224,12 @@ public class UriInfoImpl implements UriInfo {
return topOption;
}
public UriInfoImpl setEntityTypeCast(EdmEntityType type) {
public UriInfoImpl setEntityTypeCast(final EdmEntityType type) {
entityTypeCast = type;
return this;
}
public UriInfoImpl setFormat(FormatOptionImpl formatOption) {
public UriInfoImpl setFormat(final FormatOptionImpl formatOption) {
this.formatOption = formatOption;
return this;
}
@ -244,33 +239,33 @@ public class UriInfoImpl implements UriInfo {
return this;
}
public UriInfoImpl setQueryOptions(List<QueryOptionImpl> list) {
public UriInfoImpl setQueryOptions(final List<QueryOptionImpl> list) {
for (QueryOptionImpl item : list) {
if (item instanceof SystemQueryOptionImpl) {
SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item;
if (sysItem.getKind() == SystemQueryOptionEnum.EXPAND) {
if (sysItem.getKind() == SupportedQueryOptions.EXPAND) {
expandOption = (ExpandOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.FILTER) {
} else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
filterOption = (FilterOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.FORMAT) {
} else if (sysItem.getKind() == SupportedQueryOptions.FORMAT) {
formatOption = (FormatOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.ID) {
} else if (sysItem.getKind() == SupportedQueryOptions.ID) {
idOption = (IdOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.INLINECOUNT) {
inlineCountOption = (InlineCountImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.ORDERBY) {
} else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
inlineCountOption = (InlineCountOptionImpl) sysItem;
} else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
orderByOption = (OrderByImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SEARCH) {
} else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) {
searchOption = (SearchOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SELECT) {
} else if (sysItem.getKind() == SupportedQueryOptions.SELECT) {
selectOption = (SelectOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SKIP) {
} else if (sysItem.getKind() == SupportedQueryOptions.SKIP) {
skipOption = (SkipOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.SKIPTOKEN) {
skipTokenOption = (SkipTokenOptionImpl) sysItem;
} else if (sysItem.getKind() == SystemQueryOptionEnum.TOP) {
} else if (sysItem.getKind() == SupportedQueryOptions.SKIPTOKEN) {
skipTokenOption = (SkiptokenOptionImpl) sysItem;
} else if (sysItem.getKind() == SupportedQueryOptions.TOP) {
topOption = (TopOptionImpl) sysItem;
}
} else if (item instanceof CustomQueryOptionImpl) {
@ -287,7 +282,5 @@ public class UriInfoImpl implements UriInfo {
public void clearPathInfo() {
pathParts.clear();
}
}
}

View File

@ -33,7 +33,7 @@ public class UriParameterImpl implements UriParameter {
return name;
}
public UriParameterImpl setName(String name) {
public UriParameterImpl setName(final String name) {
this.name = name;
return this;
}
@ -43,7 +43,7 @@ public class UriParameterImpl implements UriParameter {
return alias;
}
public UriParameterImpl setAlias(String alias) {
public UriParameterImpl setAlias(final String alias) {
this.alias = alias;
return this;
}
@ -53,7 +53,7 @@ public class UriParameterImpl implements UriParameter {
return text;
}
public UriParameterImpl setText(String text) {
public UriParameterImpl setText(final String text) {
this.text = text;
return this;
}
@ -64,7 +64,7 @@ public class UriParameterImpl implements UriParameter {
return expression;
}
public UriParameterImpl setExpression(Expression expression) {
public UriParameterImpl setExpression(final Expression expression) {
this.expression = expression;
return this;
}

View File

@ -23,16 +23,14 @@ public class UriParserException extends Exception {
/**
*
*/
private static final long serialVersionUID = -1813203179082217112L;
private static final long serialVersionUID = 1L;
public UriParserException(String message, Throwable cause) {
public UriParserException(final String message, final Throwable cause) {
super(message, cause);
}
public UriParserException(String message) {
public UriParserException(final String message) {
super(message, null);
}
}

View File

@ -24,16 +24,14 @@ public class UriParserSemanticException extends UriParserException {
/**
*
*/
private static final long serialVersionUID = -1813203179082217112L;
public UriParserSemanticException(String message, Throwable cause) {
private static final long serialVersionUID = 1L;
public UriParserSemanticException(final String message, final Throwable cause) {
super(message, cause);
}
public UriParserSemanticException(String message) {
public UriParserSemanticException(final String message) {
super(message, null);
}
}

View File

@ -23,13 +23,13 @@ public class UriParserSyntaxException extends UriParserException {
/**
*
*/
private static final long serialVersionUID = -975557346686301719L;
private static final long serialVersionUID = 1L;
public UriParserSyntaxException(String message, Throwable cause) {
public UriParserSyntaxException(final String message, final Throwable cause) {
super(message, cause);
}
public UriParserSyntaxException(String message) {
public UriParserSyntaxException(final String message) {
super(message, null);
}

View File

@ -38,7 +38,7 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe
return action;
}
public UriResourceActionImpl setAction(EdmAction action) {
public UriResourceActionImpl setAction(final EdmAction action) {
this.action = action;
return this;
}
@ -48,20 +48,15 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe
return actionImport;
}
public UriResourceActionImpl setActionImport(EdmActionImport actionImport) {
public UriResourceActionImpl setActionImport(final EdmActionImport actionImport) {
this.actionImport = actionImport;
this.setAction(actionImport.getAction());
setAction(actionImport.getAction());
return this;
}
@Override
public String toString() {
return action.getName() + super.toString();
}
@Override
public boolean isCollection() {
if ( action != null) {
if (action != null) {
return action.getReturnType().isCollection();
}
return false;
@ -72,4 +67,13 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe
return action.getReturnType().getType();
}
@Override
public String toString() {
if (actionImport != null) {
return actionImport.getName();
} else if (action != null) {
return action.getName();
}
return "";
}
}

View File

@ -32,7 +32,7 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou
private ExpressionImpl expression;
public UriResourceAllImpl() {
super(UriResourceKind.lamdaAll);
super(UriResourceKind.lambdaAll);
}
@Override
@ -49,8 +49,8 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou
public String getLamdaVariable() {
return lamdaVariable;
}
public UriResourceAllImpl setLamdaVariable(String lamdaVariable) {
public UriResourceAllImpl setLamdaVariable(final String lamdaVariable) {
this.lamdaVariable = lamdaVariable;
return this;
};
@ -59,9 +59,14 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou
public Expression getExpression() {
return expression;
}
public UriResourceAllImpl setExpression(ExpressionImpl expression) {
public UriResourceAllImpl setExpression(final ExpressionImpl expression) {
this.expression = expression;
return this;
};
@Override
public String toString() {
return "all";
}
}

View File

@ -32,7 +32,7 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou
private ExpressionImpl expression;
public UriResourceAnyImpl() {
super(UriResourceKind.lamdaAny);
super(UriResourceKind.lambdaAny);
}
@Override
@ -49,8 +49,8 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou
public String getLamdaVariable() {
return lamdaVariable;
}
public UriResourceAnyImpl setLamdaVariable(String lamdaVariable) {
public UriResourceAnyImpl setLamdaVariable(final String lamdaVariable) {
this.lamdaVariable = lamdaVariable;
return this;
};
@ -59,9 +59,14 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou
public Expression getExpression() {
return expression;
}
public UriResourceAnyImpl setExpression(ExpressionImpl expression) {
public UriResourceAnyImpl setExpression(final ExpressionImpl expression) {
this.expression = expression;
return this;
}
@Override
public String toString() {
return "any";
};
}

View File

@ -37,14 +37,14 @@ public class UriResourceComplexPropertyImpl extends UriResourceImplTyped impleme
return property;
}
public UriResourceComplexPropertyImpl setProperty(EdmProperty property) {
public UriResourceComplexPropertyImpl setProperty(final EdmProperty property) {
this.property = property;
return this;
}
@Override
public EdmComplexType getComplexType() {
return (EdmComplexType) this.getType();
return (EdmComplexType) getType();
}
@Override
@ -62,4 +62,9 @@ public class UriResourceComplexPropertyImpl extends UriResourceImplTyped impleme
return property.isCollection();
}
@Override
public String toString() {
return property.getName();
}
}

View File

@ -27,4 +27,9 @@ public class UriResourceCountImpl extends UriResourcePartImpl implements UriReso
super(UriResourceKind.count);
}
@Override
public String toString() {
return "$count";
}
}

View File

@ -37,16 +37,11 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements
return edmEntitySet;
}
public UriResourceEntitySetImpl setEntitSet(EdmEntitySet edmES) {
this.edmEntitySet = edmES;
public UriResourceEntitySetImpl setEntitSet(final EdmEntitySet edmES) {
edmEntitySet = edmES;
return this;
}
@Override
public String toString() {
return edmEntitySet.getName() + super.toString();
}
@Override
public EdmEntityType getEntityType() {
return edmEntitySet.getEntityType();
@ -54,11 +49,7 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements
@Override
public EdmType getType() {
/*if (singleTypeFilter != null) {
return singleTypeFilter;
} else if (collectionTypeFilter != null) {
return collectionTypeFilter;
}*/
return edmEntitySet.getEntityType();
}
@ -71,4 +62,9 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements
return false;
}
@Override
public String toString() {
return edmEntitySet.getName();
}
}

View File

@ -50,7 +50,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
return retList;
}
public UriResourceFunctionImpl setParameters(List<UriParameterImpl> parameters) {
public UriResourceFunctionImpl setParameters(final List<UriParameterImpl> parameters) {
this.parameters = parameters;
return this;
}
@ -60,7 +60,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
return function;
}
public UriResourceFunctionImpl setFunction(EdmFunction function) {
public UriResourceFunctionImpl setFunction(final EdmFunction function) {
this.function = function;
return this;
}
@ -70,8 +70,9 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
return functionImport;
}
public UriResourceFunctionImpl setFunctionImport(EdmFunctionImport edmFI, List<UriParameterImpl> parameters) {
this.functionImport = edmFI;
public UriResourceFunctionImpl setFunctionImport(final EdmFunctionImport edmFI,
final List<UriParameterImpl> parameters) {
functionImport = edmFI;
this.parameters = parameters;
List<String> names = new ArrayList<String>();
@ -84,27 +85,29 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
return this;
}
@Override
public String toString() {
return function.getName() + super.toString();
}
@Override
public EdmType getType() {
return function.getReturnType().getType();
}
@Override
public boolean isCollection() {
if (keyPredicates != null ) {
if (keyPredicates != null) {
return false;
}
return function.getReturnType().isCollection();
}
@Override
public String toString() {
if (functionImport != null) {
return functionImport.getName();
} else if (function != null) {
return function.getName();
}
return "";
}
}

View File

@ -31,7 +31,7 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
protected List<UriParameterImpl> keyPredicates = null;
protected EdmType singleTypeFilter = null;
public UriResourceImplKeyPred(UriResourceKind kind) {
public UriResourceImplKeyPred(final UriResourceKind kind) {
super(kind);
}
@ -58,18 +58,17 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
return retList;
}
public UriResourceImplKeyPred setKeyPredicates(List<UriParameterImpl> list) {
public UriResourceImplKeyPred setKeyPredicates(final List<UriParameterImpl> list) {
keyPredicates = list;
return this;
}
public void setSingleTypeFilter(EdmType singleTypeFilter) {
public void setSingleTypeFilter(final EdmType singleTypeFilter) {
this.singleTypeFilter = singleTypeFilter;
}
public void setCollectionTypeFilter(EdmType collectionTypeFilter) {
public void setCollectionTypeFilter(final EdmType collectionTypeFilter) {
this.collectionTypeFilter = collectionTypeFilter;
}
}

View File

@ -26,16 +26,16 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
public abstract class UriResourceImplTyped extends UriResourcePartImpl implements UriResourcePartTyped {
protected EdmType typeFilter = null;
public UriResourceImplTyped(UriResourceKind kind) {
public UriResourceImplTyped(final UriResourceKind kind) {
super(kind);
}
public EdmType getTypeFilter() {//TODO rename to TypeFilter
public EdmType getTypeFilter() {
return typeFilter;
}
public UriResourceImplTyped setTypeFilter(EdmStructuralType typeFilter) {
public UriResourceImplTyped setTypeFilter(final EdmStructuralType typeFilter) {
this.typeFilter = typeFilter;
return this;
}

View File

@ -31,21 +31,11 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso
private EdmType type;
private boolean isCollection;
public UriResourceItImpl() {
super(UriResourceKind.it);
}
@Override
public String toString() {
if (explicitIT) {
return "$it" + super.toString();
}
return super.toString();
}
public UriResourceItImpl setIsExplicitIT(boolean explicitIT) {
public UriResourceItImpl setIsExplicitIT(final boolean explicitIT) {
this.explicitIT = explicitIT;
return this;
}
@ -62,22 +52,25 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso
@Override
public boolean isCollection() {
if (keyPredicates != null ) {
if (keyPredicates != null) {
return false;
}
return isCollection;
}
public UriResourceItImpl setType(EdmType type) {
public UriResourceItImpl setType(final EdmType type) {
this.type = type;
return this;
}
public UriResourceItImpl setCollection(boolean isCollection) {
public UriResourceItImpl setCollection(final boolean isCollection) {
this.isCollection = isCollection;
return this;
}
@Override
public String toString() {
return "$it";
}
}

View File

@ -0,0 +1,67 @@
/*******************************************************************************
* 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
*
* 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.
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceIt;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaRef;
public class UriResourceLambdaRefImpl extends UriResourceImplTyped implements UriResourceLambdaRef {
private EdmType type;
private boolean isCollection;
private String variableText;
public UriResourceLambdaRefImpl() {
super(UriResourceKind.lambdaVariable);
}
@Override
public String getVariableText() {
return variableText;
}
public UriResourceLambdaRefImpl setVariableText(String variableText) {
this.variableText = variableText;
return this;
}
@Override
public EdmType getType() {
return type;
}
public UriResourceLambdaRefImpl setType(EdmType type) {
this.type = type;
return this;
}
@Override
public boolean isCollection() {
return isCollection;
}
public UriResourceLambdaRefImpl isCollection(boolean isCollection) {
this.isCollection = isCollection;
return this;
}
}

View File

@ -31,42 +31,33 @@ public class UriResourceNavigationPropertyImpl extends UriResourceImplKeyPred im
super(UriResourceKind.navigationProperty);
}
@Override
public String toString() {
return navigationProperty.getName() + super.toString();
}
@Override
public EdmNavigationProperty getNavigationProperty() {
return navigationProperty;
}
public UriResourceNavigationPropertyImpl addNavigationProperty(EdmNavigationProperty property) {
this.navigationProperty = property;
public UriResourceNavigationPropertyImpl setNavigationProperty(final EdmNavigationProperty property) {
navigationProperty = property;
return this;
}
@Override
public EdmType getType() {
/*if (singleTypeFilter != null) {
return singleTypeFilter;
} else if (collectionTypeFilter != null) {
return collectionTypeFilter;
}*/
return navigationProperty.getType();
}
@Override
public boolean isCollection() {
if (keyPredicates != null ) {
if (keyPredicates != null) {
return false;
}
return navigationProperty.isCollection();
}
@Override
public String toString() {
return navigationProperty.getName();
}
}

View File

@ -24,10 +24,10 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
/**
* Covers Functionimports and BoundFunction in URI
*/
public class UriResourcePartImpl implements UriResourcePart {
public abstract class UriResourcePartImpl implements UriResourcePart {
protected UriResourceKind kind;
public UriResourcePartImpl(UriResourceKind kind) {
public UriResourcePartImpl(final UriResourceKind kind) {
this.kind = kind;
}

View File

@ -26,7 +26,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceSimpleProperty;
public class UriResourcePropertyImpl extends UriResourceImplTyped implements UriResourceSimpleProperty {
protected EdmProperty property;
public UriResourcePropertyImpl(UriResourceKind kind) {
public UriResourcePropertyImpl(final UriResourceKind kind) {
super(kind);
}
@ -35,7 +35,7 @@ public class UriResourcePropertyImpl extends UriResourceImplTyped implements Uri
return property;
}
public UriResourcePropertyImpl setProperty(EdmProperty property) {
public UriResourcePropertyImpl setProperty(final EdmProperty property) {
this.property = property;
return this;
}
@ -48,7 +48,11 @@ public class UriResourcePropertyImpl extends UriResourceImplTyped implements Uri
@Override
public boolean isCollection() {
return property.isCollection();
}
@Override
public String toString() {
return property.getName();
}
}

View File

@ -18,9 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceRef;
public class UriResourceRefImpl extends UriResourcePartImpl implements UriResourceRef {
public UriResourceRefImpl() {
@ -28,7 +28,9 @@ public class UriResourceRefImpl extends UriResourcePartImpl implements UriResour
}
@Override
public String toString() {
return "$ref";
}
}

View File

@ -21,12 +21,15 @@ package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceRoot;
public class UriResourceRootImpl extends UriResourcePartImpl implements UriResourceRoot {
public class UriResourceRootImpl extends UriResourcePartImpl implements UriResourceRoot {
public UriResourceRootImpl() {
super(UriResourceKind.root);
}
@Override
public String toString() {
return "$root";
}
}

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
@ -27,20 +26,18 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceSimpleProperty;
public class UriResourceSimplePropertyImpl extends UriResourceImplTyped implements UriResourceSimpleProperty {
EdmProperty property;
public UriResourceSimplePropertyImpl() {
super(UriResourceKind.simpleProperty);
}
@Override
public EdmProperty getProperty() {
return property;
}
public UriResourceSimplePropertyImpl setProperty( EdmProperty property) {
this.property = property;
public UriResourceSimplePropertyImpl setProperty(final EdmProperty property) {
this.property = property;
return this;
}
@ -53,7 +50,10 @@ public class UriResourceSimplePropertyImpl extends UriResourceImplTyped implemen
public boolean isCollection() {
return property.isCollection();
}
@Override
public String toString() {
return property.getName();
}
}

View File

@ -31,34 +31,28 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped implements Ur
public UriResourceSingletonImpl() {
super(UriResourceKind.singleton);
}
@Override
public EdmSingleton getSingleton() {
return singleton;
}
public UriResourceSingletonImpl setSingleton(EdmSingleton singleton) {
public UriResourceSingletonImpl setSingleton(final EdmSingleton singleton) {
this.singleton = singleton;
return this;
}
@Override
public EdmEntityType getEntityTypeFilter() {
return (EdmEntityType) typeFilter;
}
@Override
public String toString() {
return singleton.getName() + super.toString();
}
@Override
public EdmType getType() {
return singleton.getEntityType();
}
@Override
public EdmEntityType getEntityType() {
return singleton.getEntityType();
@ -69,13 +63,9 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped implements Ur
return false;
}
@Override
public String toString() {
return singleton.toString();
}
}

View File

@ -18,10 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceValue;
public class UriResourceValueImpl extends UriResourcePartImpl implements UriResourceValue {
public UriResourceValueImpl() {
@ -29,7 +28,9 @@ public class UriResourceValueImpl extends UriResourcePartImpl implements UriReso
}
@Override
public String toString() {
return "$value";
}
}

View File

@ -22,7 +22,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.AliasQueryOption;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class AliasQueryOptionImpl extends QueryOptionImpl implements AliasQueryOption {
// TODO change value of alias to a interface which need to be defined
private ExpressionImpl aliasValue;
@Override
@ -30,13 +30,9 @@ public class AliasQueryOptionImpl extends QueryOptionImpl implements AliasQueryO
return aliasValue;
}
public AliasQueryOptionImpl setAliasValue(ExpressionImpl aliasValue) {
public AliasQueryOptionImpl setAliasValue(final ExpressionImpl aliasValue) {
this.aliasValue = aliasValue;
return this;
}
}

View File

@ -21,6 +21,5 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
public class CustomQueryOptionImpl extends QueryOptionImpl implements CustomQueryOption {
}

Some files were not shown because too many files have changed in this diff Show More