/** * Constructs <code>FloatValue</code> from given <code>String</code> representation. * * @param value <code>String</code> representation of <code>FloatValue</code> * @throws QtiParseException if <code>String</code> representation of <code>FloatValue</code> is not valid */ public FloatValue(final String value) { this.doubleValue = DataTypeBinder.parseFloat(value); }
@Override public Double parseDomAttributeValue(final String domAttributeValue) { return Double.valueOf(DataTypeBinder.parseFloat(domAttributeValue)); }
@Override public Double parseDomAttributeValue(final String domAttributeValue) { return Double.valueOf(DataTypeBinder.parseFloat(domAttributeValue)); }
/** * Constructs <code>DurationValue</code> from given <code>String</code> representation. * * @param value <code>String</code> representation of <code>DurationValue</code> * @throws QtiParseException if <code>String</code> representation of <code>DurationValue</code> is not valid */ public DurationValue(final String value) { try { this.doubleValue = DataTypeBinder.parseFloat(value); if (doubleValue < 0) { throw new QtiParseException("Invalid duration '" + value + "'. Duration cannot be negative."); } } catch (final QtiParseException ex) { throw new QtiParseException("Invalid duration '" + value + "'.", ex); } }
/** * Parses a new floatOrVariableRef from the given String, as defined in the QTI spec. * * @throws QtiParseException */ public static FloatOrVariableRef parseString(final String string) { Assert.notNull(string); if (string.isEmpty()) { throw new QtiParseException("floatOrVariableRef must not be empty"); } try { /* Try to parse as a float */ final double floatValue = DataTypeBinder.parseFloat(string); return new FloatOrVariableRef(floatValue); } catch (final QtiParseException e) { /* Try to parse as a variable reference */ final Identifier variableReferenceIdentifier = Identifier.parseString(string); return new FloatOrVariableRef(variableReferenceIdentifier); } }