BigDecimal left = leftLit.decimalValue();
BigDecimal right = rightLit.decimalValue();
switch (op) {
case PLUS:
return new DecimalLiteralImpl(left.add(right));
case MINUS:
return new DecimalLiteralImpl(left.subtract(right));
case MULTIPLY:
return new DecimalLiteralImpl(left.multiply(right));
case DIVIDE:
// Divide by zero handled through NumberFormatException
return new DecimalLiteralImpl(left.divide(right, RoundingMode.HALF_UP));
default:
throw new IllegalArgumentException("Unknown operator: " + op);
}
}
else { // XMLSchema.INTEGER