/** * Parses a new integerOrVariableRef from the given String, as defined in the QTI spec. * * @throws QtiParseException */ public static IntegerOrVariableRef parseString(final String string) { Assert.notNull(string); if (string.isEmpty()) { throw new QtiParseException("integerOrVariableRef must not be empty"); } try { /* Try to parse as in integer */ final int integer = DataTypeBinder.parseInteger(string); return new IntegerOrVariableRef(integer); } catch (final QtiParseException e) { /* Parse as a variable reference */ final Identifier variableReferenceIdentifier = Identifier.parseString(string); return new IntegerOrVariableRef(variableReferenceIdentifier); } }
protected RandomInteger(final ExpressionParent parent, final String qtiClassName) { super(parent, qtiClassName); getAttributes().add(new IntegerOrVariableRefAttribute(this, ATTR_MIN_NAME, true)); getAttributes().add(new IntegerOrVariableRefAttribute(this, ATTR_MAX_NAME, true)); getAttributes().add(new IntegerOrVariableRefAttribute(this, ATTR_STEP_NAME, new IntegerOrVariableRef(ATTR_STEP_DEFAULT_VALUE), false)); }
public PrintedVariable(final QtiNode parent) { super(parent, QTI_CLASS_NAME); getAttributes().add(new IdentifierAttribute(this, ATTR_IDENTIFIER_NAME, true)); getAttributes().add(new StringAttribute(this, ATTR_FORMAT_NAME, false)); getAttributes().add(new BooleanAttribute(this, ATTR_POWER_FORM_NAME, false)); getAttributes().add(new IntegerOrVariableRefAttribute(this, ATTR_BASE_NAME, new IntegerOrVariableRef(ATTR_BASE_DEFAULT_VALUE), false)); getAttributes().add(new IntegerOrVariableRefAttribute(this, ATTR_INDEX_NAME, false)); getAttributes().add(new StringAttribute(this, ATTR_DELIMTER_NAME, ATTR_DELMITER_DEFAULT_VALUE, false)); getAttributes().add(new StringAttribute(this, ATTR_FIELD_NAME, false)); getAttributes().add(new StringAttribute(this, ATTR_MAPPING_INDICATOR_NAME, ATTR_MAPPING_INDICATOR_DEFAULT_VALUE, false)); }