use of org.sirix.service.xml.xpath.operators.MulOpAxis in project sirix by sirixdb.
the class PipelineBuilder method addOperatorExpression.
/**
* Adds an operator expression to the pipeline.
*
* @param mTransaction Transaction to operate with.
* @param mOperator Operator type.
*/
public void addOperatorExpression(final XdmNodeReadTrx mTransaction, final String mOperator) {
assert getPipeStack().size() >= 1;
final XdmNodeReadTrx rtx = mTransaction;
final Axis mOperand2 = getPipeStack().pop().getExpr();
// the unary operation only has one operator
final Axis mOperand1 = getPipeStack().pop().getExpr();
if (getPipeStack().empty() || getExpression().getSize() != 0) {
addExpressionSingle();
}
final Axis axis;
// TODO: use typeswitch of JAVA 7
if (mOperator.equals("+")) {
axis = new AddOpAxis(rtx, mOperand1, mOperand2);
} else if (mOperator.equals("-")) {
axis = new SubOpAxis(rtx, mOperand1, mOperand2);
} else if (mOperator.equals("*")) {
axis = new MulOpAxis(rtx, mOperand1, mOperand2);
} else if (mOperator.equals("div")) {
axis = new DivOpAxis(rtx, mOperand1, mOperand2);
} else if (mOperator.equals("idiv")) {
axis = new IDivOpAxis(rtx, mOperand1, mOperand2);
} else if (mOperator.equals("mod")) {
axis = new ModOpAxis(rtx, mOperand1, mOperand2);
} else {
// TODO: unary operator
throw new IllegalStateException(mOperator + " is not a valid operator.");
}
getExpression().add(axis);
}
Aggregations