Search in sources :

Example 1 with DivOpAxis

use of org.sirix.service.xml.xpath.operators.DivOpAxis 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);
}
Also used : IDivOpAxis(org.sirix.service.xml.xpath.operators.IDivOpAxis) DivOpAxis(org.sirix.service.xml.xpath.operators.DivOpAxis) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) SubOpAxis(org.sirix.service.xml.xpath.operators.SubOpAxis) IDivOpAxis(org.sirix.service.xml.xpath.operators.IDivOpAxis) ModOpAxis(org.sirix.service.xml.xpath.operators.ModOpAxis) ModOpAxis(org.sirix.service.xml.xpath.operators.ModOpAxis) RangeAxis(org.sirix.service.xml.xpath.expr.RangeAxis) AddOpAxis(org.sirix.service.xml.xpath.operators.AddOpAxis) ExceptAxis(org.sirix.service.xml.xpath.expr.ExceptAxis) Axis(org.sirix.api.Axis) MulOpAxis(org.sirix.service.xml.xpath.operators.MulOpAxis) UnionAxis(org.sirix.service.xml.xpath.expr.UnionAxis) IfAxis(org.sirix.service.xml.xpath.expr.IfAxis) IntersectAxis(org.sirix.service.xml.xpath.expr.IntersectAxis) IDivOpAxis(org.sirix.service.xml.xpath.operators.IDivOpAxis) DupFilterAxis(org.sirix.service.xml.xpath.filter.DupFilterAxis) PredicateFilterAxis(org.sirix.axis.filter.PredicateFilterAxis) VariableAxis(org.sirix.service.xml.xpath.expr.VariableAxis) ForAxis(org.sirix.axis.ForAxis) SequenceAxis(org.sirix.service.xml.xpath.expr.SequenceAxis) FilterAxis(org.sirix.axis.filter.FilterAxis) SubOpAxis(org.sirix.service.xml.xpath.operators.SubOpAxis) DivOpAxis(org.sirix.service.xml.xpath.operators.DivOpAxis) AddOpAxis(org.sirix.service.xml.xpath.operators.AddOpAxis) MulOpAxis(org.sirix.service.xml.xpath.operators.MulOpAxis)

Aggregations

Axis (org.sirix.api.Axis)1 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)1 ForAxis (org.sirix.axis.ForAxis)1 FilterAxis (org.sirix.axis.filter.FilterAxis)1 PredicateFilterAxis (org.sirix.axis.filter.PredicateFilterAxis)1 ExceptAxis (org.sirix.service.xml.xpath.expr.ExceptAxis)1 IfAxis (org.sirix.service.xml.xpath.expr.IfAxis)1 IntersectAxis (org.sirix.service.xml.xpath.expr.IntersectAxis)1 RangeAxis (org.sirix.service.xml.xpath.expr.RangeAxis)1 SequenceAxis (org.sirix.service.xml.xpath.expr.SequenceAxis)1 UnionAxis (org.sirix.service.xml.xpath.expr.UnionAxis)1 VariableAxis (org.sirix.service.xml.xpath.expr.VariableAxis)1 DupFilterAxis (org.sirix.service.xml.xpath.filter.DupFilterAxis)1 AddOpAxis (org.sirix.service.xml.xpath.operators.AddOpAxis)1 DivOpAxis (org.sirix.service.xml.xpath.operators.DivOpAxis)1 IDivOpAxis (org.sirix.service.xml.xpath.operators.IDivOpAxis)1 ModOpAxis (org.sirix.service.xml.xpath.operators.ModOpAxis)1 MulOpAxis (org.sirix.service.xml.xpath.operators.MulOpAxis)1 SubOpAxis (org.sirix.service.xml.xpath.operators.SubOpAxis)1