/** * Gets the integer value of the supplied literal. The fallback value is returned in case * {@link Literal#integerValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the integer value for. * @param fallback * The value to fall back to in case no integer value could gotten from the literal. * @return Either the literal's integer value, or the fallback value. */ public static BigInteger getIntegerValue(Literal l, BigInteger fallback) { try { return l.integerValue(); } catch (NumberFormatException e) { return fallback; } }
/** * Gets the integer value of the supplied literal. The fallback value is returned in case * {@link Literal#integerValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the integer value for. * @param fallback * The value to fall back to in case no integer value could gotten from the literal. * @return Either the literal's integer value, or the fallback value. */ public static BigInteger getIntegerValue(Literal l, BigInteger fallback) { try { return l.integerValue(); } catch (NumberFormatException e) { return fallback; } }
@Override public void update(final AggregationElement aggregation, final AggregationState state, final VisibilityBindingSet childBindingSet) { checkArgument(aggregation.getAggregationType() == AggregationType.COUNT, "The CountFunction only accepts COUNT AggregationElements."); requireNonNull(state); requireNonNull(childBindingSet); // Only add one to the count if the child contains the binding that we are counting. final String aggregatedName = aggregation.getAggregatedBindingName(); if(childBindingSet.hasBinding(aggregatedName)) { final MapBindingSet result = state.getBindingSet(); final String resultName = aggregation.getResultBindingName(); final boolean newBinding = !result.hasBinding(resultName); if(newBinding) { // Initialize the binding. result.addBinding(resultName, VF.createLiteral(BigInteger.ONE)); } else { // Update the existing binding. final Literal count = (Literal) result.getValue(resultName); final BigInteger updatedCount = count.integerValue().add( BigInteger.ONE ); result.addBinding(resultName, VF.createLiteral(updatedCount)); } } } }
BigInteger integerValue = literal.integerValue(); booleanValue = !integerValue.equals(BigInteger.ZERO);
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
BigInteger integerValue = literal.integerValue(); booleanValue = !integerValue.equals(BigInteger.ZERO);
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
@Override protected Value evaluate(ValueFactory valueFactory, Value arg1, Value arg2) throws ValueExprEvaluationException { if (!(arg1 instanceof Literal) || !(arg2 instanceof Literal)) { throw new ValueExprEvaluationException("Both arguments must be literals"); } Literal number = (Literal)arg1; Literal format = (Literal)arg2; java.text.DecimalFormat formatter = new java.text.DecimalFormat(format.getLabel()); String value; if (XMLSchema.INT.equals(number.getDatatype()) || XMLSchema.LONG.equals(number.getDatatype()) || XMLSchema.SHORT.equals(number.getDatatype()) || XMLSchema.BYTE.equals(number.getDatatype())) { value = formatter.format(number.longValue()); } else if (XMLSchema.DECIMAL.equals(number.getDatatype())) { value = formatter.format(number.decimalValue()); } else if (XMLSchema.INTEGER.equals(number.getDatatype())) { value = formatter.format(number.integerValue()); } else { value = formatter.format(number.doubleValue()); } return valueFactory.createLiteral(value); } }
BigInteger left = leftLit.integerValue(); BigInteger right = rightLit.integerValue();
BigInteger left = leftLit.integerValue(); BigInteger right = rightLit.integerValue();
integerValue = literal.integerValue();
integerValue = literal.integerValue();
BigInteger left = leftLit.integerValue(); BigInteger right = rightLit.integerValue(); return valueFactory.createLiteral(left.remainder(right));
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
compareResult = leftLit.integerValue().compareTo(rightLit.integerValue());
try { if (XMLDatatypeUtil.isIntegerDatatype(datatype)) { memLiteral = new IntegerMemLiteral(this, label, literal.integerValue(), datatype);
try { if (XMLDatatypeUtil.isIntegerDatatype(datatype)) { memLiteral = new IntegerMemLiteral(this, label, literal.integerValue(), datatype);