本文整理汇总了Java中org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException类的典型用法代码示例。如果您正苦于以下问题:Java ExpressionVisitException类的具体用法?Java ExpressionVisitException怎么用?Java ExpressionVisitException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpressionVisitException类属于org.apache.olingo.server.api.uri.queryoption.expression包,在下文中一共展示了ExpressionVisitException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitUnaryOperator(UnaryOperatorKind operator, Object operand)
throws ExpressionVisitException, ODataApplicationException {
String sparqlunary = "";
switch (operator) {
case MINUS:
sparqlunary = "-";
break;
case NOT:
sparqlunary = "!";
break;
default:
throw new UnsupportedOperationException("Unsupported unary: " + operator.toString());
}
return sparqlunary;
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlExpressionVisitor.java
示例2: readReferenceCollection
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
static public EntityCollection readReferenceCollection(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
UriType uriType) throws OData2SparqlException, EdmException, ODataApplicationException, ExpressionVisitException {
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
RdfEntityType rdfEntityType = null;
EdmEntitySet edmEntitySet = null;
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
edmEntitySet = uriResourceEntitySet.getEntitySet();
rdfEntityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
SparqlQueryBuilder sparqlBuilder = new SparqlQueryBuilder(rdfEdmProvider.getRdfModel(),
rdfEdmProvider.getEdmMetadata(), uriInfo, uriType);
//prepareQuery
SparqlStatement sparqlStatement = sparqlBuilder.prepareEntityLinksSparql();
SparqlEntityCollection rdfResults = sparqlStatement.executeConstruct(rdfEdmProvider, rdfEntityType, null, null);
if (rdfResults == null) {
throw new ODataApplicationException("No results", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.ENGLISH);
} else {
return rdfResults;
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlBaseCommand.java
示例3: visitMethodCall
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public ExpressionMember visitMethodCall(MethodKind methodCall,
List<ExpressionMember> parameters)
throws ExpressionVisitException, ODataApplicationException {
switch (methodCall) {
case CONTAINS:
return parameters.get(0).contains(parameters.get(1));
case STARTSWITH:
return parameters.get(0).startsWith(parameters.get(1));
case ENDSWITH:
return parameters.get(0).endsWith(parameters.get(1));
case DATE:
return parameters.get(0).date();
default:
return throwNotImplemented(
String.format("Method call %s is not implemented", methodCall));
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:ElasticSearchExpressionVisitor.java
示例4: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public VisitorOperand visitUnaryOperator(final UnaryOperatorKind operator, final VisitorOperand operand)
throws ExpressionVisitException, ODataApplicationException {
final UnaryOperator unaryOperator = new UnaryOperator(operand);
switch (operator) {
case MINUS:
return unaryOperator.minusOperation();
case NOT:
return unaryOperator.notOperation();
default:
// Can't happen.
return throwNotImplemented();
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ExpressionVisitorImpl.java
示例5: visitMember
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public String visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException {
String ret = "";
for (UriResource item : member.getResourcePath().getUriResourceParts()) {
String tmp = "";
if (item instanceof UriResourceLambdaAll) {
UriResourceLambdaAll all = (UriResourceLambdaAll) item;
tmp = visitLambdaExpression("ALL", all.getLambdaVariable(), all.getExpression());
} else if (item instanceof UriResourceLambdaAny) {
UriResourceLambdaAny any = (UriResourceLambdaAny) item;
tmp = visitLambdaExpression("ANY", any.getLambdaVariable(), any.getExpression());
} else if (item instanceof UriResourcePartTyped) {
UriResourcePartTyped typed = (UriResourcePartTyped) item;
tmp = typed.toString(true);
}
if (ret.length() > 0) {
ret += "/";
}
ret += tmp;
}
return "<" + ret + ">";
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:FilterTreeToText.java
示例6: isParameterText
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
throws ExpressionVisitException, ODataApplicationException {
if (curExpression instanceof MethodImpl) {
MethodImpl methodCall = (MethodImpl) curExpression;
Expression parameter = methodCall.getParameters().get(parameterIndex);
String actualParameterText = FilterTreeToText.Serialize(parameter);
assertEquals(parameterText, actualParameterText);
} else if (curExpression instanceof MemberImpl) {
final MemberImpl member = (MemberImpl) curExpression;
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
if (!uriResourceParts.isEmpty() && uriResourceParts.get(0) instanceof UriResourceFunctionImpl) {
assertEquals(parameterText, ((UriResourceFunctionImpl) uriResourceParts.get(0)).getParameters()
.get(parameterIndex).getText());
} else {
fail("Current expression is not a method or function");
}
} else {
fail("Current expression is not a method or function");
}
return this;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:FilterValidator.java
示例7: visitMember
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException {
// To keeps things simple, this tutorial allows only primitive properties.
// We have faith that the java type of Edm.Int32 is Integer
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
// Make sure that the resource path of the property contains only a single segment and a primitive property
// has been addressed. We can be sure, that the property exists because the UriParser checks if the
// property has been defined in service metadata document.
if(uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourcePrimitiveProperty) {
UriResourcePrimitiveProperty uriResourceProperty = (UriResourcePrimitiveProperty) uriResourceParts.get(0);
return currentEntity.getProperty(uriResourceProperty.getProperty().getName()).getValue();
} else {
// The OData specification allows in addition complex properties and navigation properties
// with a target cardinality 0..1 or 1.
// This means any combination can occur e.g. Supplier/Address/City
// -> Navigation properties Supplier
// -> Complex Property Address
// -> Primitive Property City
// For such cases the resource path returns a list of UriResourceParts
throw new ODataApplicationException("Only primitive properties are implemented in filter expressions",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:FilterExpressionVisitor.java
示例8: visitLiteral
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
// To keep this tutorial simple, our filter expression visitor supports only Edm.Int32 and Edm.String
// In real world scenarios it can be difficult to guess the type of an literal.
// We can be sure, that the literal is a valid OData literal because the URI Parser checks
// the lexicographical structure
// String literals start and end with an single quotation mark
String literalAsString = literal.getText();
if(literal.getType() instanceof EdmString) {
String stringLiteral = "";
if(literal.getText().length() > 2) {
stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
}
return stringLiteral;
} else {
// Try to convert the literal into an Java Integer
try {
return Integer.parseInt(literalAsString);
} catch(NumberFormatException e) {
throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:FilterExpressionVisitor.java
示例9: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitUnaryOperator(UnaryOperatorKind operator, Object operand)
throws ExpressionVisitException, ODataApplicationException {
// OData allows two different unary operators. We have to take care, that the type of the operand fits to
// operand
if(operator == UnaryOperatorKind.NOT && operand instanceof Boolean) {
// 1.) boolean negation
return !(Boolean) operand;
} else if(operator == UnaryOperatorKind.MINUS && operand instanceof Integer){
// 2.) arithmetic minus
return -(Integer) operand;
}
// Operation not processed, throw an exception
throw new ODataApplicationException("Invalid type for unary operator",
HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:FilterExpressionVisitor.java
示例10: visitMember
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
public Object visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException {
// To keeps things simple, this tutorial allows only primitive properties.
// We have faith that the java type of Edm.Int32 is Integer
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
// Make sure that the resource path of the property contains only a single segment and a primitive property
// has been addressed. We can be sure, that the property exists because the UriParser checks if the
// property has been defined in service metadata document.
if(uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourcePrimitiveProperty) {
UriResourcePrimitiveProperty uriResourceProperty = (UriResourcePrimitiveProperty) uriResourceParts.get(0);
return currentEntity.getProperty(uriResourceProperty.getProperty().getName()).getValue();
} else {
// The OData specification allows in addition complex properties and navigation properties
// with a target cardinality 0..1 or 1.
// This means any combination can occur e.g. Supplier/Address/City
// -> Navigation properties Supplier
// -> Complex Property Address
// -> Primitive Property City
// For such cases the resource path returns a list of UriResourceParts
throw new ODataApplicationException("Only primitive properties are implemented in filter expressions",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:FilterExpressionVisitor.java
示例11: visitLiteral
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
// To keep this tutorial simple, our filter expression visitor supports only Edm.Int32 and Edm.String
// In real world scenarios it can be difficult to guess the type of an literal.
// We can be sure, that the literal is a valid OData literal because the URI Parser checks
// the lexicographical structure
// String literals start and end with an single quotation mark
String literalAsString = literal.getText();
if(literal.getType() instanceof EdmString) {
String stringLiteral = "";
if(literal.getText().length() > 2) {
stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
}
return stringLiteral;
} else {
// Try to convert the literal into an Java Integer
try {
return Integer.parseInt(literalAsString);
} catch(NumberFormatException e) {
throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:FilterExpressionVisitor.java
示例12: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
public Object visitUnaryOperator(UnaryOperatorKind operator, Object operand)
throws ExpressionVisitException, ODataApplicationException {
// OData allows two different unary operators. We have to take care, that the type of the operand fits to
// operand
if(operator == UnaryOperatorKind.NOT && operand instanceof Boolean) {
// 1.) boolean negation
return !(Boolean) operand;
} else if(operator == UnaryOperatorKind.MINUS && operand instanceof Integer){
// 2.) arithmetic minus
return -(Integer) operand;
}
// Operation not processed, throw an exception
throw new ODataApplicationException("Invalid type for unary operator",
HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ENGLISH);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:FilterExpressionVisitor.java
示例13: applyFilterSystemQuery
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
/**
* This method applies filter query option to the given entity collection.
*
* @param filterOption Filter option
* @param entitySet Entity collection
* @param edmEntitySet Entity set
* @throws ODataApplicationException
*/
public static void applyFilterSystemQuery(final FilterOption filterOption, final EntityCollection entitySet,
final EdmBindingTarget edmEntitySet) throws ODataApplicationException {
try {
final Iterator<Entity> iter = entitySet.getEntities().iterator();
while (iter.hasNext()) {
final VisitorOperand operand =
filterOption.getExpression().accept(new ExpressionVisitorImpl(iter.next(), edmEntitySet));
final TypedOperand typedOperand = operand.asTypedOperand();
if (typedOperand.is(ODataConstants.primitiveBoolean)) {
if (Boolean.FALSE.equals(typedOperand.getTypedValue(Boolean.class))) {
iter.remove();
}
} else {
throw new ODataApplicationException(
"Invalid filter expression. Filter expressions must return a value of " +
"type Edm.Boolean", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
} catch (ExpressionVisitException e) {
throw new ODataApplicationException("Exception in filter evaluation",
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
}
}
开发者ID:wso2,项目名称:carbon-data,代码行数:34,代码来源:QueryHandler.java
示例14: visitMember
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public VisitorOperand visitMember(Member member) throws ExpressionVisitException, ODataApplicationException {
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
int size = uriResourceParts.size();
if (uriResourceParts.get(0) instanceof UriResourceProperty) {
EdmProperty currentEdmProperty = ((UriResourceProperty) uriResourceParts.get(0)).getProperty();
Property currentProperty = entity.getProperty(currentEdmProperty.getName());
return new TypedOperand(currentProperty.getValue(), currentEdmProperty.getType(), currentEdmProperty);
} else if (uriResourceParts.get(size - 1) instanceof UriResourceLambdaAll) {
return throwNotImplemented();
} else if (uriResourceParts.get(size - 1) instanceof UriResourceLambdaAny) {
return throwNotImplemented();
} else {
return throwNotImplemented();
}
}
开发者ID:wso2,项目名称:carbon-data,代码行数:17,代码来源:ExpressionVisitorImpl.java
示例15: visitBinaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public SQLExpression visitBinaryOperator(BinaryOperatorKind operator, SQLExpression left, SQLExpression right)
throws ExpressionVisitException, ODataApplicationException {
switch (operator){
case MUL: return new Multiplication().setLeftExpression(left).setRightExpression(right);
case DIV: return new Division().setLeftExpression(left).setRightExpression(right);
case MOD: return new Function().setName("MOD").setParameters(new ExpressionList(Arrays.asList(left,right)));
case ADD: return new Addition().setLeftExpression(left).setRightExpression(right);
case SUB: return new Subtraction().setLeftExpression(left).setRightExpression(right);
case GT: return new GreaterThan().setLeftExpression(left).setRightExpression(right);
case GE: return new GreaterThanEquals().setLeftExpression(left).setRightExpression(right);
case LT: return new MinorThan().setLeftExpression(left).setRightExpression(right);
case LE: return new MinorThanEquals().setLeftExpression(left).setRightExpression(right);
case EQ: return new EqualsTo().setLeftExpression(left).setRightExpression(right);
case NE: return new NotEqualsTo().setLeftExpression(left).setRightExpression(right);
case AND: return new AndExpression().setLeftExpression(left).setRightExpression(right);
case OR: return new OrExpression().setLeftExpression(left).setRightExpression(right);
default:
break;
}
throw new ODataApplicationException(operator + " operator is not implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:26,代码来源:FilterExpressionVisitor.java
示例16: visitMember
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public SQLExpression visitMember(Member member) throws ExpressionVisitException, ODataApplicationException {
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
if(uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourcePrimitiveProperty) {
UriResourcePrimitiveProperty uriResourceProperty = (UriResourcePrimitiveProperty) uriResourceParts.get(0);
String name = uriResourceProperty.getProperty().getName();
Table table = new Table().setName(alias);
return new Column(alias != null ? table : null , name);
} else {
throw new ODataApplicationException("Only primitive properties are implemented in filter expressions",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
}
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:19,代码来源:FilterExpressionVisitor.java
示例17: appendOrdering
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
public void appendOrdering(String alias,OrderByOption orderByOption) throws ODataApplicationException {
if(orderByOption != null){
getSelect().setOrderByElements(new ArrayList<OrderByElement>());
for( OrderByItem item: orderByOption.getOrders()){
OrderByElement element = new OrderByElement();
element.setAsc(!item.isDescending());
FilterExpressionVisitor expressionVisitor = new FilterExpressionVisitor(alias);
try {
SQLExpression orderByItem = item.getExpression().accept(expressionVisitor);
element.setColumnReference(orderByItem);
getSelect().getOrderByElements().add(element);
} catch (ExpressionVisitException e) {
throw internalError(e);
}
}
}
}
开发者ID:jbaliuka,项目名称:sql-analytic,代码行数:20,代码来源:ReadCommand.java
示例18: visitBinaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitBinaryOperator(
BinaryOperatorKind operator,
Object left,
Object right) throws ExpressionVisitException, ODataApplicationException {
switch (operator) {
case AND:
return and((QueryBuilder) left, (QueryBuilder) right);
case EQ:
return eq((String) left, right);
case GE:
return ge((String) left, right);
case GT:
return gt((String) left, right);
case LE:
return le((String) left, right);
case LT:
return lt((String) left, right);
case NE:
return ne((String) left, right);
case OR:
return or((QueryBuilder) left, (QueryBuilder) right);
default:
throw new NotImplementedException("Binary operator " + operator + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:28,代码来源:ElasticsearchExpressionVisitor.java
示例19: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitUnaryOperator(
UnaryOperatorKind operator,
Object operand) throws ExpressionVisitException, ODataApplicationException {
switch (operator) {
case NOT:
return not((QueryBuilder) operand);
default:
throw new NotImplementedException("Unary operator " + operator + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:13,代码来源:ElasticsearchExpressionVisitor.java
示例20: visitMethodCall
import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException; //导入依赖的package包/类
@Override
public Object visitMethodCall(
MethodKind method,
List<Object> parameters) throws ExpressionVisitException, ODataApplicationException {
switch (method) {
case CONTAINS:
return contains((String) parameters.get(0), (String) parameters.get(1));
case STARTSWITH:
return startsWith((String) parameters.get(0), (String) parameters.get(1));
default:
throw new NotImplementedException("Method " + method + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:15,代码来源:ElasticsearchExpressionVisitor.java
注:本文中的org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论