本文整理汇总了Java中org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind类的典型用法代码示例。如果您正苦于以下问题:Java UnaryOperatorKind类的具体用法?Java UnaryOperatorKind怎么用?Java UnaryOperatorKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnaryOperatorKind类属于org.apache.olingo.server.api.uri.queryoption.expression包,在下文中一共展示了UnaryOperatorKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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;
}
示例2: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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();
}
}
示例3: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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);
}
示例4: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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);
}
示例5: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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");
}
}
示例6: supportedOperators
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Test
public void supportedOperators() {
assertEquals(UnaryOperatorKind.MINUS, UnaryOperatorKind.get("-"));
assertEquals(null, UnaryOperatorKind.get("XXX"));
assertEquals(BinaryOperatorKind.MOD, BinaryOperatorKind.get("mod"));
assertEquals(null, BinaryOperatorKind.get("XXX"));
assertEquals(MethodKind.CONCAT, MethodKind.get("concat"));
assertEquals(null, MethodKind.get("XXX"));
}
示例7: unaryExpression
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Test
public void unaryExpression() throws Exception {
Expression operand = new LiteralImpl("1.2", odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal));
UnaryImpl expression = new UnaryImpl(UnaryOperatorKind.MINUS, operand,
odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal));
assertEquals(UnaryOperatorKind.MINUS, expression.getOperator());
assertEquals(operand, expression.getOperand());
assertEquals(odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Decimal), expression.getType());
assertEquals("<- <1.2>>", expression.accept(new FilterTreeToText()));
}
示例8: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Override
public JsonNode visitUnaryOperator(final UnaryOperatorKind operator, final JsonNode operand)
throws ExpressionVisitException, ODataApplicationException {
return nodeFactory.objectNode()
.put(NODE_TYPE_NAME, UNARY_NAME)
.put(OPERATOR_NAME, operator.toString())
.put(TYPE_NAME, getType(operator))
.set(OPERAND_NAME, operand);
}
示例9: getType
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
private String getType(final UnaryOperatorKind operator) {
switch (operator) {
case MINUS:
return NUMBER_NAME;
case NOT:
return BOOLEAN_NAME;
}
return UNKNOWN_NAME;
}
示例10: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的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();
}
}
示例11: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Override
public SQLExpression visitUnaryOperator(UnaryOperatorKind operator, SQLExpression operand)
throws ExpressionVisitException, ODataApplicationException {
switch (operator) {
case MINUS: return new InverseExpression().setExpression(operand);
case NOT: return new Parenthesis().setExpression(operand).setNot();
default:
break;
}
throw new ODataApplicationException(operator + " operator is not implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
示例12: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Override
public ExpressionMember visitUnaryOperator(UnaryOperatorKind operator, ExpressionMember operand)
throws ExpressionVisitException, ODataApplicationException {
return operator == UnaryOperatorKind.NOT ? operand.not()
: throwNotImplemented("Unsupported unary operator");
}
示例13: visitUnaryOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Override
public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand)
throws ExpressionVisitException {
return "<" + operator + " " + operand + ">";
}
示例14: UnaryImpl
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
public UnaryImpl(final UnaryOperatorKind operator, final Expression expression, final EdmType type) {
this.operator = operator;
this.expression = expression;
this.type = type;
}
示例15: getOperator
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind; //导入依赖的package包/类
@Override
public UnaryOperatorKind getOperator() {
return operator;
}