src/org/ohmage/domain/campaign/Campaign.java
private static NumberPrompt processNumber(
			final String id,
			final String condition, 
			final String unit, 
			final String text,
			final String explanationText, 
			final boolean skippable, 
			final String skipLabel,
			final String displayLabel,
			final String defaultValue,
			final Map<String, LabelValuePair> properties, 
			final int index) 
			throws DomainException {
		
		// Create the decimal parser.
		DecimalFormat format = new DecimalFormat();
		format.setParseBigDecimal(true);
		
		BigDecimal min;
		try {
			LabelValuePair minVlp = 
				properties.get(NumberPrompt.XML_KEY_MIN);  // required
			
			if(minVlp == null) {
				throw new DomainException(
						"Missing the '" +
							NumberPrompt.XML_KEY_MIN +
							"' property: " +
							id);
			}
			
			min = (BigDecimal) format.parse(minVlp.getLabel());
		}
		catch(ParseException e) {
			throw new DomainException(
					"The '" +
						NumberPrompt.XML_KEY_MIN +
						"' property is not a valid number: " +
						id, 
					e);
		}
		
		BigDecimal max;
		try {
			LabelValuePair maxVlp = 
				properties.get(NumberPrompt.XML_KEY_MAX);  // required
			
			if(maxVlp == null) {
				throw new DomainException(
						"Missing the '" +
							NumberPrompt.XML_KEY_MAX +
							"' property: " +
							id);
			}
			
			max = (BigDecimal) format.parse(maxVlp.getLabel());
		}
		catch(ParseException e) {
			throw new DomainException(
					"The '" +
						NumberPrompt.XML_KEY_MAX +
						"' property is not valid number: " +
						id, 
					e);
		}
		
		BigDecimal parsedDefaultValue = null;
		try {
			if(defaultValue != null) {
				parsedDefaultValue = (BigDecimal) format.parse(defaultValue);
			}
		}
		catch(ParseException e) {
			throw new DomainException(
					"The default value is not a valid number: " +
						id);
		}
		
		Boolean wholeNumber = null;
		LabelValuePair wholeNumberVlp = 
			properties.get(NumberPrompt.XML_KEY_WHOLE_NUMBER);  // optional
		
		if(wholeNumberVlp != null) {
			wholeNumber =
				StringUtils.decodeBoolean(wholeNumberVlp.getLabel());
			if(wholeNumber == null) {
				throw
					new DomainException(
						"The '" +
						NumberPrompt.XML_KEY_WHOLE_NUMBER +
						"' property is not a valid boolean: " +
						id);
			}
		}

		return new NumberPrompt(
			id,
			condition,
			unit,
			text,
			explanationText,
			skippable,
			skipLabel,
			displayLabel,
			min,
			max,
			parsedDefaultValue,
			index,
			wholeNumber);
	}
/**
	 * Processes a number prompt and returns a NumberPrompt object.
	 * 
	 * @param id The prompt's unique identifier.
	 * 
	 * @param condition The condition value.
	 * 
	 * @param unit The prompt's visualization unit.
	 * 
	 * @param text The prompt's text value.
	 * 
	 * @param explanationText The prompt's explanation text value.
	 * 
	 * @param skippable Whether or not this prompt is skippable.
	 * 
	 * @param skipLabel The label to show to skip this prompt.
	 * 
	 * @param displayLabel The label for this display type.
	 * 
	 * @param defaultValue The default value given in the XML.
	 * 
	 * @param properties The properties defined in the XML for this prompt.
	 * 
	 * @param index The index of this prompt in its collection of survey items.
	 * 
	 * @return A NumberPrompt object.
	 * 
	 * @throws DomainException Thrown if the required properties are missing or
	 * 						   if any of the parameters are invalid.
	 */
Processes a number prompt and returns a NumberPrompt object.

@param id The prompt's unique identifier.

@param condition The condition value.

@param unit The prompt's visualization unit.

@param text The prompt's text value.

@param explanationText The prompt's explanation text value.

@param skippable Whether or not this prompt is skippable.

@param skipLabel The label to show to skip this prompt.

@param displayLabel The label for this display type.

@param defaultValue The default value given in the XML.

@param properties The properties defined in the XML for this prompt.

@param index The index of this prompt in its collection of survey items.

@return A NumberPrompt object.

@throws DomainException Thrown if the required properties are missing or
if any of the parameters are invalid.
Processes a number prompt and returns a NumberPrompt object . @param id The prompt ' s unique identifier . @param condition The condition value . @param unit The prompt ' s visualization unit . @param text The prompt ' s text value . @param explanationText The prompt ' s explanation text value . @param skippable Whether or not this prompt is skippable . @param skipLabel The label to show to skip this prompt . @param displayLabel The label for this display type . @param defaultValue The default value given in the XML . @param properties The properties defined in the XML for this prompt . @param index The index of this prompt in its collection of survey items . @return A NumberPrompt object . @throws DomainException Thrown if the required properties are missing or if any of the parameters are invalid .
private static NumberPrompt processNumber(
			final String id,
			final String condition, 
			final String unit, 
			final String text,
			final String explanationText, 
			final boolean skippable, 
			final String skipLabel,
			final String displayLabel,
			final String defaultValue,
			final Map<String, LabelValuePair> properties, 
			final int index) 
			throws DomainException {
		DecimalFormat format = new DecimalFormat();
		format.setParseBigDecimal(true);
		BigDecimal min;
		try {
			LabelValuePair minVlp = 
				properties.get(NumberPrompt.XML_KEY_MIN);  
			if(minVlp == null) {
				throw new DomainException(
						"Missing the '" +
							NumberPrompt.XML_KEY_MIN +
							"' property: " +
							id);
			}
			min = (BigDecimal) format.parse(minVlp.getLabel());
		}
		catch(ParseException e) {
			throw new DomainException(
					"The '" +
						NumberPrompt.XML_KEY_MIN +
						"' property is not a valid number: " +
						id, 
					e);
		}
		BigDecimal max;
		try {
			LabelValuePair maxVlp = 
				properties.get(NumberPrompt.XML_KEY_MAX);  
			if(maxVlp == null) {
				throw new DomainException(
						"Missing the '" +
							NumberPrompt.XML_KEY_MAX +
							"' property: " +
							id);
			}
			max = (BigDecimal) format.parse(maxVlp.getLabel());
		}
		catch(ParseException e) {
			throw new DomainException(
					"The '" +
						NumberPrompt.XML_KEY_MAX +
						"' property is not valid number: " +
						id, 
					e);
		}
		BigDecimal parsedDefaultValue = null;
		try {
			if(defaultValue != null) {
				parsedDefaultValue = (BigDecimal) format.parse(defaultValue);
			}
		}
		catch(ParseException e) {
			throw new DomainException(
					"The default value is not a valid number: " +
						id);
		}
		Boolean wholeNumber = null;
		LabelValuePair wholeNumberVlp = 
			properties.get(NumberPrompt.XML_KEY_WHOLE_NUMBER);  
		if(wholeNumberVlp != null) {
			wholeNumber =
				StringUtils.decodeBoolean(wholeNumberVlp.getLabel());
			if(wholeNumber == null) {
				throw
					new DomainException(
						"The '" +
						NumberPrompt.XML_KEY_WHOLE_NUMBER +
						"' property is not a valid boolean: " +
						id);
			}
		}
		return new NumberPrompt(
			id,
			condition,
			unit,
			text,
			explanationText,
			skippable,
			skipLabel,
			displayLabel,
			min,
			max,
			parsedDefaultValue,
			index,
			wholeNumber);
	}
private static NumberPrompt processNumber ( final String id , final String condition , final String unit , final String text , final String explanationText , final boolean skippable , final String skipLabel , final String displayLabel , final String defaultValue , final Map < String , LabelValuePair > properties , final int index ) throws DomainException { DecimalFormat format = new DecimalFormat ( ) ; format . setParseBigDecimal ( true ) ; BigDecimal min ; try { LabelValuePair minVlp = properties . get ( NumberPrompt . XML_KEY_MIN ) ; if ( minVlp == null ) { throw new DomainException ( "Missing the '" + NumberPrompt . XML_KEY_MIN + "' property: " + id ) ; } min = ( BigDecimal ) format . parse ( minVlp . getLabel ( ) ) ; } catch ( ParseException e ) { throw new DomainException ( "The '" + NumberPrompt . XML_KEY_MIN + "' property is not a valid number: " + id , e ) ; } BigDecimal max ; try { LabelValuePair maxVlp = properties . get ( NumberPrompt . XML_KEY_MAX ) ; if ( maxVlp == null ) { throw new DomainException ( "Missing the '" + NumberPrompt . XML_KEY_MAX + "' property: " + id ) ; } max = ( BigDecimal ) format . parse ( maxVlp . getLabel ( ) ) ; } catch ( ParseException e ) { throw new DomainException ( "The '" + NumberPrompt . XML_KEY_MAX + "' property is not valid number: " + id , e ) ; } BigDecimal parsedDefaultValue = null ; try { if ( defaultValue != null ) { parsedDefaultValue = ( BigDecimal ) format . parse ( defaultValue ) ; } } catch ( ParseException e ) { throw new DomainException ( "The default value is not a valid number: " + id ) ; } Boolean wholeNumber = null ; LabelValuePair wholeNumberVlp = properties . get ( NumberPrompt . XML_KEY_WHOLE_NUMBER ) ; if ( wholeNumberVlp != null ) { wholeNumber = StringUtils . decodeBoolean ( wholeNumberVlp . getLabel ( ) ) ; if ( wholeNumber == null ) { throw new DomainException ( "The '" + NumberPrompt . XML_KEY_WHOLE_NUMBER + "' property is not a valid boolean: " + id ) ; } } return new NumberPrompt ( id , condition , unit , text , explanationText , skippable , skipLabel , displayLabel , min , max , parsedDefaultValue , index , wholeNumber ) ; }
Processes a number prompt and returns a NumberPrompt object.
Processes a number prompt and returns a NumberPrompt object .
// Create the decimal parser. // required // required // optional