@Override public boolean equals(Object other) { if (other instanceof MathExpr && super.equals(other)) { MathExpr o = (MathExpr)other; return operator.equals(o.getOperator()); } return false; }
@Override public boolean equals(Object other) { if (other instanceof MathExpr && super.equals(other)) { MathExpr o = (MathExpr)other; return operator.equals(o.getOperator()); } return false; }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
/** * @inheritDoc */ @Override public void meet(MathExpr theOp) throws Exception { mBuffer.append("("); theOp.getLeftArg().visit(this); mBuffer.append(" ").append(theOp.getOperator().getSymbol()).append(" "); theOp.getRightArg().visit(this); mBuffer.append(")"); }
@Override public Value evaluate(MathExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); if (leftVal instanceof Literal && rightVal instanceof Literal) { return XMLDatatypeMathUtil.compute((Literal)leftVal, (Literal)rightVal, node.getOperator()); } throw new ValueExprEvaluationException("Both arguments must be literals"); }
public Value evaluate(MathExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { // Do the math Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); if (leftVal instanceof Literal && rightVal instanceof Literal) { return MathUtil.compute((Literal)leftVal, (Literal)rightVal, node.getOperator()); } throw new ValueExprEvaluationException("Both arguments must be numeric literals"); }
public Value evaluate(MathExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { // Do the math Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); if (leftVal instanceof Literal && rightVal instanceof Literal) { return MathUtil.compute((Literal)leftVal, (Literal)rightVal, node.getOperator()); } throw new ValueExprEvaluationException("Both arguments must be numeric literals"); }
@Override public Value evaluate(MathExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); if (leftVal instanceof Literal && rightVal instanceof Literal) { return XMLDatatypeMathUtil.compute((Literal)leftVal, (Literal)rightVal, node.getOperator()); } throw new ValueExprEvaluationException("Both arguments must be literals"); }
/** * Evaluate a {@link MathExpr} * @param node the node to evaluate * @param bindings the set of named value bindings * @return the {@link Value} of the math operation on the {@link Value}s return from evaluating the left and right arguments of the node * @throws ValueExprEvaluationException * @throws QueryEvaluationException */ private Value evaluate(MathExpr node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { // Do the math Value leftVal = evaluate(node.getLeftArg(), bindings); Value rightVal = evaluate(node.getRightArg(), bindings); if (leftVal instanceof Literal && rightVal instanceof Literal) { return MathUtil.compute((Literal) leftVal, (Literal) rightVal, node.getOperator()); } throw new ValueExprEvaluationException("Both arguments must be numeric literals"); }
@Override public void meet(MathExpr node) throws RDFHandlerException { Resource currentSubj = subject; flushPendingStatement(); handler.handleStatement( valueFactory.createStatement(subject, RDF.TYPE, toValue(node.getOperator()))); predicate = SP.ARG1_PROPERTY; node.getLeftArg().visit(this); predicate = SP.ARG2_PROPERTY; node.getRightArg().visit(this); subject = currentSubj; predicate = null; }
ExpressionOperation p = NumericalOperations.get(((MathExpr)expr).getOperator()); return termFactory.getFunction(p, term1, term2);