[OLINGO-63] Uri Parser: cleanup, tests

This commit is contained in:
Sven Kobler 2014-02-12 16:40:00 +01:00
parent 7a3ee483ba
commit fad52801d3
41 changed files with 401 additions and 382 deletions

View File

@ -59,6 +59,6 @@ public interface UriInfoResource {
TopOption getTopOption();
List<UriResourcePart> getUriResourceParts();
List<UriResource> getUriResourceParts();
}

View File

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

View File

@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmActionImport;
public interface UriResourceAction extends UriResourcePartTyped {
public interface UriResourceAction extends UriResourcePartTyped {
EdmAction getAction();

View File

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

View File

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

View File

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

View File

@ -22,6 +22,6 @@ package org.apache.olingo.odata4.producer.api.uri;
* Class indicating the $root reference. $root may be used within filter to
* refer to the current OData service
*/
public interface UriResourceRoot extends UriResourcePart {
public interface UriResourceRoot extends UriResource {
}

View File

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

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;

View File

@ -18,11 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri;
import org.antlr.v4.runtime.ANTLRErrorListener;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.BailErrorStrategy;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.DefaultErrorStrategy;
import org.antlr.v4.runtime.atn.PredictionMode;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.apache.olingo.odata4.producer.api.uri.UriInfo;

View File

@ -32,7 +32,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriInfoMetadata;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
import org.apache.olingo.odata4.producer.api.uri.UriInfoService;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
import org.apache.olingo.odata4.producer.api.uri.UriResource;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
@ -84,8 +84,8 @@ public class UriInfoImpl implements UriInfo {
private String fragment;
private UriResourcePart lastResourcePart;
private List<UriResourcePart> pathParts = new ArrayList<UriResourcePart>();
private UriResource lastResourcePart;
private List<UriResource> pathParts = new ArrayList<UriResource>();
@Override
public UriInfoAll asUriInfoAll() {
@ -127,15 +127,15 @@ public class UriInfoImpl implements UriInfo {
}
@Override
public List<UriResourcePart> getUriResourceParts() {
List<UriResourcePart> returnList = new ArrayList<UriResourcePart>();
for (UriResourcePart item : pathParts) {
public List<UriResource> getUriResourceParts() {
List<UriResource> returnList = new ArrayList<UriResource>();
for (UriResource item : pathParts) {
returnList.add(item);
}
return Collections.unmodifiableList(returnList);
}
public UriInfoImpl addResourcePart(final UriResourcePartImpl uriPathInfo) {
public UriInfoImpl addResourcePart(final UriResourceImpl uriPathInfo) {
pathParts.add(uriPathInfo);
lastResourcePart = uriPathInfo;
return this;
@ -195,7 +195,7 @@ public class UriInfoImpl implements UriInfo {
return this;
}
public UriResourcePart getLastResourcePart() {
public UriResource getLastResourcePart() {
return lastResourcePart;
}

View File

@ -79,4 +79,5 @@ public class UriParameterImpl implements UriParameter {
this.referencedProperty = referencedProperty;
return this;
}
}

View File

@ -24,7 +24,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceAction;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceActionImpl extends UriResourceImplTyped implements UriResourceAction {
public class UriResourceActionImpl extends UriResourceTypedImpl implements UriResourceAction {
protected EdmAction action;
protected EdmActionImport actionImport;

View File

@ -24,7 +24,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceComplexProperty;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceComplexPropertyImpl extends UriResourceImplTyped implements UriResourceComplexProperty {
public class UriResourceComplexPropertyImpl extends UriResourceTypedImpl implements UriResourceComplexProperty {
protected EdmProperty property;

View File

@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriResourceCount;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceCountImpl extends UriResourcePartImpl implements UriResourceCount {
public class UriResourceCountImpl extends UriResourceImpl implements UriResourceCount {
public UriResourceCountImpl() {
super(UriResourceKind.count);

View File

@ -25,7 +25,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceEntitySet;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements UriResourceEntitySet {
public class UriResourceEntitySetImpl extends UriResourceWithKeysImpl implements UriResourceEntitySet {
protected EdmEntitySet edmEntitySet = null;
public UriResourceEntitySetImpl() {

View File

@ -31,7 +31,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
/**
* Covers Function imports and BoundFunction in URI
*/
public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements UriResourceFunction {
public class UriResourceFunctionImpl extends UriResourceWithKeysImpl implements UriResourceFunction {
protected List<UriParameterImpl> parameters;
protected EdmFunction function;

View File

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

View File

@ -25,7 +25,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
/**
* Covers Functionimports and BoundFunction in URI
*/
public class UriResourceItImpl extends UriResourceImplKeyPred implements UriResourceIt {
public class UriResourceItImpl extends UriResourceWithKeysImpl implements UriResourceIt {
private EdmType type;
private boolean isCollection;

View File

@ -26,7 +26,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAll;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class UriResourceLambdaAllImpl extends UriResourceImplTyped implements UriResourceLambdaAll {
public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements UriResourceLambdaAll {
protected EdmProperty property;
private String lamdaVariable;
private ExpressionImpl expression;

View File

@ -26,7 +26,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAny;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class UriResourceLambdaAnyImpl extends UriResourceImplTyped implements UriResourceLambdaAny {
public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements UriResourceLambdaAny {
protected EdmProperty property;
private String lamdaVariable;
private ExpressionImpl expression;

View File

@ -22,7 +22,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaRef;
public class UriResourceLambdaVarImpl extends UriResourceImplTyped implements UriResourceLambdaRef {
public class UriResourceLambdaVarImpl extends UriResourceTypedImpl implements UriResourceLambdaRef {
private EdmType type;
private boolean isCollection;

View File

@ -23,7 +23,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceNavigation;
public class UriResourceNavigationPropertyImpl extends UriResourceImplKeyPred implements UriResourceNavigation {
public class UriResourceNavigationPropertyImpl extends UriResourceWithKeysImpl implements UriResourceNavigation {
protected EdmNavigationProperty navigationProperty;

View File

@ -23,7 +23,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePrimitiveProperty;
public class UriResourcePrimitivePropertyImpl extends UriResourceImplTyped implements UriResourcePrimitiveProperty {
public class UriResourcePrimitivePropertyImpl extends UriResourceTypedImpl implements UriResourcePrimitiveProperty {
EdmProperty property;

View File

@ -21,7 +21,7 @@ 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 class UriResourceRefImpl extends UriResourceImpl implements UriResourceRef {
public UriResourceRefImpl() {
super(UriResourceKind.ref);

View File

@ -22,7 +22,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceRoot;
public class UriResourceRootImpl extends UriResourceImplKeyPred implements UriResourceRoot {
public class UriResourceRootImpl extends UriResourceWithKeysImpl implements UriResourceRoot {
private EdmType type;
private boolean isCollection;

View File

@ -24,7 +24,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceSingleton;
public class UriResourceSingletonImpl extends UriResourceImplTyped implements UriResourceSingleton {
public class UriResourceSingletonImpl extends UriResourceTypedImpl implements UriResourceSingleton {
private EdmSingleton singleton;

View File

@ -22,7 +22,8 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceStartingTypeFilter;
public class UriResourceStartingTypeFilterImpl extends UriResourceImplKeyPred implements UriResourceStartingTypeFilter {
public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl
implements UriResourceStartingTypeFilter {
private EdmType type;
private boolean isCollection;
@ -58,10 +59,10 @@ public class UriResourceStartingTypeFilterImpl extends UriResourceImplKeyPred im
this.isCollection = isCollection;
return this;
}
@Override
public String toString() {
return type.getNamespace() + "." +type.getName();
return type.getNamespace() + "." + type.getName();
}
}

View File

@ -24,11 +24,11 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
public abstract class UriResourceImplTyped extends UriResourcePartImpl implements UriResourcePartTyped {
public abstract class UriResourceTypedImpl extends UriResourceImpl implements UriResourcePartTyped {
protected EdmType typeFilter = null;
public UriResourceImplTyped(final UriResourceKind kind) {
public UriResourceTypedImpl(final UriResourceKind kind) {
super(kind);
}
@ -36,7 +36,7 @@ public abstract class UriResourceImplTyped extends UriResourcePartImpl implement
return typeFilter;
}
public UriResourceImplTyped setTypeFilter(final EdmStructuralType typeFilter) {
public UriResourceTypedImpl setTypeFilter(final EdmStructuralType typeFilter) {
this.typeFilter = typeFilter;
return this;
}

View File

@ -21,7 +21,7 @@ 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 class UriResourceValueImpl extends UriResourceImpl implements UriResourceValue {
public UriResourceValueImpl() {
super(UriResourceKind.value);

View File

@ -25,25 +25,18 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
public abstract class UriResourceWithKeysImpl extends UriResourceImpl implements UriResourcePartTyped {
protected EdmType collectionTypeFilter = null;
protected List<UriParameterImpl> keyPredicates = null;
protected EdmType entryTypeFilter = null;
public UriResourceImplKeyPred(final UriResourceKind kind) {
public UriResourceWithKeysImpl(final UriResourceKind kind) {
super(kind);
}
@Override
public EdmType getTypeFilter() {
if (entryTypeFilter != null) {
return entryTypeFilter;
}
return collectionTypeFilter;
}
public EdmType getTypeFilterOnCollection() {
return collectionTypeFilter;
}
@ -60,17 +53,17 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
return retList;
}
public UriResourceImplKeyPred setKeyPredicates(final List<UriParameterImpl> list) {
public UriResourceWithKeysImpl setKeyPredicates(final List<UriParameterImpl> list) {
keyPredicates = list;
return this;
}
public UriResourceImplKeyPred setEntryTypeFilter(final EdmType entryTypeFilter) {
public UriResourceWithKeysImpl setEntryTypeFilter(final EdmType entryTypeFilter) {
this.entryTypeFilter = entryTypeFilter;
return this;
}
public UriResourceImplKeyPred setCollectionTypeFilter(final EdmType collectionTypeFilter) {
public UriResourceWithKeysImpl setCollectionTypeFilter(final EdmType collectionTypeFilter) {
this.collectionTypeFilter = collectionTypeFilter;
return this;
}

View File

@ -18,19 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.queryoption;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplTyped;
import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
public class SelectItemImpl implements SelectItem {

View File

@ -26,9 +26,9 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expressi
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Member;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression;
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplTyped;
import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceTypedImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceWithKeysImpl;
public class MemberImpl extends ExpressionImpl implements Member, VisitableExression {
@ -52,18 +52,18 @@ public class MemberImpl extends ExpressionImpl implements Member, VisitableExres
@Override
public EdmType getType() {
UriInfoImpl uriInfo = (UriInfoImpl) path;
UriResourcePartImpl lastResourcePart = (UriResourcePartImpl) uriInfo.getLastResourcePart();
UriResourceImpl lastResourcePart = (UriResourceImpl) uriInfo.getLastResourcePart();
if (lastResourcePart instanceof UriResourceImplKeyPred) {
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastResourcePart;
if (lastResourcePart instanceof UriResourceWithKeysImpl) {
UriResourceWithKeysImpl lastKeyPred = (UriResourceWithKeysImpl) lastResourcePart;
if (lastKeyPred.getTypeFilterOnEntry() != null) {
return lastKeyPred.getTypeFilterOnEntry();
} else if (lastKeyPred.getTypeFilterOnCollection() != null) {
return lastKeyPred.getTypeFilterOnCollection();
}
return lastKeyPred.getType();
} else if (lastResourcePart instanceof UriResourceImplTyped) {
UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastResourcePart;
} else if (lastResourcePart instanceof UriResourceTypedImpl) {
UriResourceTypedImpl lastTyped = (UriResourceTypedImpl) lastResourcePart;
EdmType type = lastTyped.getTypeFilter();
if (type != null) {
return type;
@ -77,9 +77,9 @@ public class MemberImpl extends ExpressionImpl implements Member, VisitableExres
@Override
public boolean isCollection() {
UriInfoImpl uriInfo = (UriInfoImpl) path;
UriResourcePartImpl lastResourcePart = (UriResourcePartImpl) uriInfo.getLastResourcePart();
if (lastResourcePart instanceof UriResourceImplTyped) {
UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastResourcePart;
UriResourceImpl lastResourcePart = (UriResourceImpl) uriInfo.getLastResourcePart();
if (lastResourcePart instanceof UriResourceTypedImpl) {
UriResourceTypedImpl lastTyped = (UriResourceTypedImpl) lastResourcePart;
return lastTyped.isCollection();
}
return false;

View File

@ -24,9 +24,9 @@ import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
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;
import org.apache.olingo.odata4.producer.api.uri.UriResource;
import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAll;
import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAny;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
@ -93,7 +93,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
UriInfoResource path = resource;
for (UriResourcePart item : path.getUriResourceParts()) {
for (UriResource item : path.getUriResourceParts()) {
String tmp = "";
if (item instanceof UriResourceLambdaAll) {
UriResourceLambdaAll all = (UriResourceLambdaAll) item;

View File

@ -29,7 +29,6 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException;
import org.apache.olingo.odata4.producer.api.uri.UriInfo;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Member;
@ -42,7 +41,6 @@ import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor;
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
import org.apache.olingo.odata4.producer.core.uri.UriParserSemanticException;
import org.apache.olingo.odata4.producer.core.uri.UriParserSyntaxException;
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByOptionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl;

View File

@ -33,6 +33,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriInfo;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression;
@ -43,14 +44,13 @@ import org.apache.olingo.odata4.producer.core.uri.UriResourceActionImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceComplexPropertyImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceEntitySetImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplKeyPred;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImplTyped;
import org.apache.olingo.odata4.producer.core.uri.UriResourceImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceLambdaAllImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceLambdaAnyImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceNavigationPropertyImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourcePartImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourcePrimitivePropertyImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceSingletonImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceWithKeysImpl;
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.SelectOptionImpl;
@ -61,7 +61,7 @@ public class UriResourceValidator implements Validator {
private Validator invokedBy;
private UriInfo uriInfo = null;
private UriResourcePartImpl uriPathInfo = null;
private UriResourceImpl uriPathInfo = null;
private int uriResourceIndex;
// --- Setup ---
@ -173,7 +173,7 @@ public class UriResourceValidator implements Validator {
public UriResourceValidator first() {
uriResourceIndex = 0;
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(0);
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
return this;
}
@ -181,7 +181,7 @@ public class UriResourceValidator implements Validator {
uriResourceIndex = 0;
try {
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
} catch (IndexOutOfBoundsException ex) {
fail("not enough segments");
@ -194,7 +194,7 @@ public class UriResourceValidator implements Validator {
uriResourceIndex++;
try {
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
} catch (IndexOutOfBoundsException ex) {
fail("not enough segments");
}
@ -205,7 +205,7 @@ public class UriResourceValidator implements Validator {
public UriResourceValidator at(final int index) {
uriResourceIndex = index;
try {
uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(index);
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
} catch (IndexOutOfBoundsException ex) {
fail("not enough segments");
}
@ -240,10 +240,10 @@ public class UriResourceValidator implements Validator {
}
public UriResourceValidator isType(final FullQualifiedName type) {
if (!(uriPathInfo instanceof UriResourceImplTyped)) {
if (!(uriPathInfo instanceof UriResourcePartTyped)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplTyped uriPathInfoTyped = (UriResourceImplTyped) uriPathInfo;
UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
EdmType actualType = uriPathInfoTyped.getType();
if (actualType == null) {
@ -259,16 +259,16 @@ public class UriResourceValidator implements Validator {
public UriResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
isType(type);
assertEquals(isFinallyACollection, ((UriResourceImplTyped) uriPathInfo).isCollection());
assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection());
return this;
}
public UriResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
// input parameter type may be null in order to assert that the singleTypeFilter is not set
EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnEntry();
@ -282,10 +282,10 @@ public class UriResourceValidator implements Validator {
}
public UriResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplKeyPred uriPathInfoKeyPred = (UriResourceImplKeyPred) uriPathInfo;
UriResourceWithKeysImpl uriPathInfoKeyPred = (UriResourceWithKeysImpl) uriPathInfo;
// input parameter type may be null in order to assert that the collectionTypeFilter is not set
EdmType actualType = uriPathInfoKeyPred.getTypeFilterOnCollection();
@ -318,10 +318,10 @@ public class UriResourceValidator implements Validator {
// TODO remove
public UriResourceValidator isCollection(final boolean isCollection) {
if (!(uriPathInfo instanceof UriResourceImplTyped)) {
if (!(uriPathInfo instanceof UriResourcePartTyped)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplTyped uriPathInfoTyped = (UriResourceImplTyped) uriPathInfo;
UriResourcePartTyped uriPathInfoTyped = (UriResourcePartTyped) uriPathInfo;
EdmType type = uriPathInfoTyped.getType();
if (type == null) {
@ -348,11 +348,11 @@ public class UriResourceValidator implements Validator {
public UriResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplKeyPred info = (UriResourceImplKeyPred) uriPathInfo;
UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
List<UriParameter> keyPredicates = info.getKeyPredicates();
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(refencedProperty, keyPredicates.get(index).getRefencedProperty());
@ -360,11 +360,11 @@ public class UriResourceValidator implements Validator {
}
public UriResourceValidator isKeyPredicate(final int index, final String name, final String text) {
if (!(uriPathInfo instanceof UriResourceImplKeyPred)) {
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
}
UriResourceImplKeyPred info = (UriResourceImplKeyPred) uriPathInfo;
UriResourceWithKeysImpl info = (UriResourceWithKeysImpl) uriPathInfo;
List<UriParameter> keyPredicates = info.getKeyPredicates();
assertEquals(name, keyPredicates.get(index).getName());
assertEquals(text, keyPredicates.get(index).getText());

View File

@ -232,7 +232,7 @@ public class UriParameterImplTest {
@Test
public void testUriResourceImplKeyPred() {
class Mock extends UriResourceImplKeyPred {
class Mock extends UriResourceWithKeysImpl {
EdmType type;
public Mock() {
@ -282,22 +282,22 @@ public class UriParameterImplTest {
impl.toString(true));
// set entry
// TODO remove ???
impl = new Mock();
impl.setType(entityType);
impl.setEntryTypeFilter(entityTypeBaseEntry);
assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry());
assertEquals("mock", impl.toString(false));
assertEquals("mock/com.sap.odata.test1.ETTwoBaseTwoKeyNav", impl.toString(true));
assertEquals(entityTypeBaseEntry, impl.getTypeFilter());
// set collection
// TODO remove ???
impl = new Mock();
impl.setType(entityType);
impl.setCollectionTypeFilter(entityTypeBaseColl);
assertEquals(entityTypeBaseColl, impl.getTypeFilterOnCollection());
assertEquals("mock", impl.toString(false));
assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav", impl.toString(true));
assertEquals(entityTypeBaseColl, impl.getTypeFilter());
impl = new Mock();
UriParameterImpl parameter = new UriParameterImpl().setName("ParameterInt16");
@ -311,7 +311,7 @@ public class UriParameterImplTest {
@Test
public void testUriResourceImplTyped() {
class Mock extends UriResourceImplTyped {
class Mock extends UriResourceTypedImpl {
EdmType type;
public Mock() {

View File

@ -18,7 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.core.uri.antlr;
import java.net.URISyntaxException;
import java.util.Arrays;
import org.apache.olingo.odata4.commons.api.edm.Edm;
@ -36,8 +35,6 @@ import org.apache.olingo.odata4.producer.core.testutil.FilterValidator;
import org.apache.olingo.odata4.producer.core.testutil.UriResourceValidator;
import org.apache.olingo.odata4.producer.core.testutil.UriValidator;
import org.apache.olingo.odata4.producer.core.uri.UriParserException;
import org.apache.olingo.odata4.producer.core.uri.UriParserSemanticException;
import org.apache.olingo.odata4.producer.core.uri.UriParserSyntaxException;
import org.junit.Test;
public class TestFullResourcePath {
@ -2516,7 +2513,7 @@ public class TestFullResourcePath {
.isFormatText("IANA_content_type/must_contain_a_slash");
testUri.run("ESKeyNav(1)?$format=Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27")
.isKind(UriInfoKind.resource).goPath()
.isFormatText("Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27");
.isFormatText("Test_all_valid_signsSpecified_for_format_signs&-._~$@'/Aa123&-._~$@'");
}
@Test

View File

@ -23,7 +23,6 @@ package org.apache.olingo.odata4.producer.core.uri.antlr;
import java.util.Arrays;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;

View File

@ -21,23 +21,17 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.commons.api.edm.EdmAction;
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl;
import org.apache.olingo.odata4.producer.api.uri.UriInfoKind;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
import org.apache.olingo.odata4.producer.core.testutil.EdmTechProvider;
import org.apache.olingo.odata4.producer.core.testutil.EdmTechTestProvider;
import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceActionImpl;
import org.apache.olingo.odata4.producer.core.uri.UriResourceFunctionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.AliasImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.LiteralImpl;