/** * Gets the float value of the supplied literal. The fallback value is returned in case * {@link Literal#floatValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the float value for. * @param fallback * The value to fall back to in case no float value could gotten from the literal. * @return Either the literal's float value, or the fallback value. */ public static float getFloatValue(Literal l, float fallback) { try { return l.floatValue(); } catch (NumberFormatException e) { return fallback; } }
/** * Gets the float value of the supplied literal. The fallback value is returned in case * {@link Literal#floatValue()} throws a {@link NumberFormatException}. * * @param l * The literal to get the float value for. * @param fallback * The value to fall back to in case no float value could gotten from the literal. * @return Either the literal's float value, or the fallback value. */ public static float getFloatValue(Literal l, float fallback) { try { return l.floatValue(); } catch (NumberFormatException e) { return fallback; } }
private float literalToFloat(Value v) { if (!(v instanceof Literal)) { throw new IllegalArgumentException( "value [" + v + "] was not a literal, which is expected " + "for a parameter of type float or Float." ); } Literal literal = (Literal) v; return literal.floatValue(); }
ps.setTimestamp(i+1, new Timestamp(((Literal)v).calendarValue().toGregorianCalendar().getTimeInMillis())); } else if (v instanceof Literal && columnTypes[i] == Types.FLOAT) { ps.setFloat(i+1, ((Literal)v).floatValue()); } else if (v instanceof Literal && columnTypes[i] == Types.DOUBLE) { ps.setDouble(i+1, ((Literal)v).doubleValue());
try { if (datatype.equals(XMLSchema.FLOAT)) { float floatValue = literal.floatValue(); booleanValue = floatValue != 0.0f && Float.isNaN(floatValue);
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
try { if (datatype.equals(XMLSchema.FLOAT)) { float floatValue = literal.floatValue(); booleanValue = floatValue != 0.0f && Float.isNaN(floatValue);
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
float left = leftLit.floatValue(); float right = rightLit.floatValue();
float left = leftLit.floatValue(); float right = rightLit.floatValue();
protected Literal convert(ValueFactory valueFactory, Value value) throws ValueExprEvaluationException { if (value instanceof Literal) { Literal literal = (Literal)value; IRI datatype = literal.getDatatype(); if (XMLDatatypeUtil.isNumericDatatype(datatype)) { // FIXME: doubles must be processed separately, see // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive try { float floatValue = literal.floatValue(); return valueFactory.createLiteral(floatValue); } catch (NumberFormatException e) { throw typeError(literal, e); } } else if (datatype.equals(XMLSchema.BOOLEAN)) { try { return valueFactory.createLiteral(literal.booleanValue() ? 1f : 0f); } catch (IllegalArgumentException e) { throw typeError(literal, e); } } } throw typeError(value, null); }
protected Literal convert(ValueFactory valueFactory, Value value) throws ValueExprEvaluationException { if (value instanceof Literal) { Literal literal = (Literal)value; IRI datatype = literal.getDatatype(); if (XMLDatatypeUtil.isNumericDatatype(datatype)) { // FIXME: doubles must be processed separately, see // http://www.w3.org/TR/xpath-functions/#casting-from-primitive-to-primitive try { float floatValue = literal.floatValue(); return valueFactory.createLiteral(floatValue); } catch (NumberFormatException e) { throw typeError(literal, e); } } else if (datatype.equals(XMLSchema.BOOLEAN)) { try { return valueFactory.createLiteral(literal.booleanValue() ? 1f : 0f); } catch (IllegalArgumentException e) { throw typeError(literal, e); } } } throw typeError(value, null); }
float left = leftLit.floatValue(); float right = rightLit.floatValue(); return valueFactory.createLiteral(left % right);
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
return Math.abs(al.floatValue() - bl.floatValue()) < 0.001;
compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue());
memLiteral = new NumericMemLiteral(this, label, literal.floatValue(), datatype);
memLiteral = new NumericMemLiteral(this, label, literal.floatValue(), datatype);