MulOpAxis extends AbstractObAxis { @Override public Node operate(final AtomicValue mOperand1, final AtomicValue mOperand2) throws SirixXPathException { final Type returnType = getReturnType(mOperand1.getTypeKey(), mOperand2.getTypeKey()); final int typeKey = asXdmNodeReadTrx().keyForName(returnType.getStringRepr()); final byte[] value; switch (returnType) { case DOUBLE: case FLOAT: case DECIMAL: case INTEGER: final double dOp1 = Double.parseDouble(new String(mOperand1.getRawValue())); final double dOp2 = Double.parseDouble(new String(mOperand2.getRawValue())); value = TypedValue.getBytes(dOp1 * dOp2); break; case YEAR_MONTH_DURATION: case DAY_TIME_DURATION: throw new IllegalStateException( "Add operator is not implemented for the type " + returnType.getStringRepr() + " yet."); default: throw new XPathError(ErrorType.XPTY0004); } return new AtomicValue(value, typeKey); } MulOpAxis(final XmlNodeReadOnlyTrx rtx, final Axis mOp1, final Axis mOp2); @Override Node operate(final AtomicValue mOperand1, final AtomicValue mOperand2);  }
@Test public final void testOperate() throws SirixException { AtomicValue item1 = new AtomicValue(3.0, Type.DOUBLE); AtomicValue item2 = new AtomicValue(2.0, Type.DOUBLE); AbstractAxis op1 = new LiteralExpr(holder.getXmlNodeReadTrx(), holder.getXmlNodeReadTrx().getItemList().addItem(item1)); AbstractAxis op2 = new LiteralExpr(holder.getXmlNodeReadTrx(), holder.getXmlNodeReadTrx().getItemList().addItem(item2)); AbstractObAxis axis = new MulOpAxis(holder.getXmlNodeReadTrx(), op1, op2); assertEquals(true, axis.hasNext()); axis.next(); assertThat(6.0, is(Double.parseDouble(holder.getXmlNodeReadTrx().getValue()))); assertEquals(holder.getXmlNodeReadTrx().keyForName("xs:double"), holder.getXmlNodeReadTrx().getTypeKey()); assertEquals(false, axis.hasNext()); }