src/org/ohmage/domain/campaign/prompt/SingleChoicePrompt.java
@Override
	public Object validateValue(final Object value) throws DomainException {
		Integer keyValue;
		
		// If it's already a NoResponse value, then return make sure that if it
		// was skipped that it as skippable.
		if(value instanceof NoResponse) {
			if(NoResponse.SKIPPED.equals(value) && (! skippable())) {
				throw new DomainException(
						"The prompt, '" +
							getId() +
							"', was skipped, but it is not skippable.");
			}
			
			return value;
		}
		else if(value instanceof Integer) {
			keyValue = (Integer) value;
		}
		else if(value instanceof String) {
			try {
				return NoResponse.valueOf((String) value);
			}
			catch(IllegalArgumentException notNoResponse) {
				try {
					keyValue = Integer.decode((String) value);
				}
				catch(NumberFormatException notChoiceKey) {
					throw new DomainException(
							"The value was not a valid response value for this prompt, '" +
								getId() +
								"'.", 
							notChoiceKey);
				}
			}
		}
		else {
			throw new DomainException(
					"The value is not decodable as a reponse value for prompt '" +
						getId() +
						"'.");
		}

		if(! getChoices().keySet().contains(keyValue)) {
			throw new DomainException(
					"The value is not a value choice for prompt '" +
						getId() +
						"'.");
		}
		
		return keyValue;
	}
/**
	 * Validates that a given value is valid and, if so, converts it into an
	 * appropriate object.
	 * 
	 * @param value The value to be validated. This must be one of the
	 * 				following:<br />
	 * 				<ul>
	 * 				<li>{@link NoResponse}</li>
	 * 				<li>{@link Integer} that represents the key of the item the
	 * 				  user chose.</li>
	 * 				<li>{@link String} that represents:</li>
	 * 				  <ul>
	 * 				    <li>{@link NoResponse}</li>
	 * 				    <li>The key of the item the user chose.</li>
	 * 				  <ul>
	 * 				</ul>
	 * 
	 * @return An Integer representing a key or a {@link NoResponse} object.
	 * 
	 * @throws DomainException The value is invalid.
	 */
Validates that a given value is valid and, if so, converts it into an
appropriate object.

@param value The value to be validated. This must be one of the
following:

 NoResponse
 Integer that represents the key of the item the
user chose.
 String that represents:

 NoResponse
The key of the item the user chose.



@return An Integer representing a key or a  NoResponse object.

@throws DomainException The value is invalid.
Validates that a given value is valid and if so converts it into an appropriate object . @param value The value to be validated . This must be one of the following : NoResponse Integer that represents the key of the item the user chose . String that represents : NoResponse The key of the item the user chose . @return An Integer representing a key or a NoResponse object . @throws DomainException The value is invalid .
@Override
	public Object validateValue(final Object value) throws DomainException {
		Integer keyValue;
		if(value instanceof NoResponse) {
			if(NoResponse.SKIPPED.equals(value) && (! skippable())) {
				throw new DomainException(
						"The prompt, '" +
							getId() +
							"', was skipped, but it is not skippable.");
			}
			return value;
		}
		else if(value instanceof Integer) {
			keyValue = (Integer) value;
		}
		else if(value instanceof String) {
			try {
				return NoResponse.valueOf((String) value);
			}
			catch(IllegalArgumentException notNoResponse) {
				try {
					keyValue = Integer.decode((String) value);
				}
				catch(NumberFormatException notChoiceKey) {
					throw new DomainException(
							"The value was not a valid response value for this prompt, '" +
								getId() +
								"'.", 
							notChoiceKey);
				}
			}
		}
		else {
			throw new DomainException(
					"The value is not decodable as a reponse value for prompt '" +
						getId() +
						"'.");
		}
		if(! getChoices().keySet().contains(keyValue)) {
			throw new DomainException(
					"The value is not a value choice for prompt '" +
						getId() +
						"'.");
		}
		return keyValue;
	}
@ Override public Object validateValue ( final Object value ) throws DomainException { Integer keyValue ; if ( value instanceof NoResponse ) { if ( NoResponse . SKIPPED . equals ( value ) && ( ! skippable ( ) ) ) { throw new DomainException ( "The prompt, '" + getId ( ) + "', was skipped, but it is not skippable." ) ; } return value ; } else if ( value instanceof Integer ) { keyValue = ( Integer ) value ; } else if ( value instanceof String ) { try { return NoResponse . valueOf ( ( String ) value ) ; } catch ( IllegalArgumentException notNoResponse ) { try { keyValue = Integer . decode ( ( String ) value ) ; } catch ( NumberFormatException notChoiceKey ) { throw new DomainException ( "The value was not a valid response value for this prompt, '" + getId ( ) + "'." , notChoiceKey ) ; } } } else { throw new DomainException ( "The value is not decodable as a reponse value for prompt '" + getId ( ) + "'." ) ; } if ( ! getChoices ( ) . keySet ( ) . contains ( keyValue ) ) { throw new DomainException ( "The value is not a value choice for prompt '" + getId ( ) + "'." ) ; } return keyValue ; }
Validates that a given value is valid and, if so, converts it into an
 appropriate object.
Validates that a given value is valid and if so converts it into an appropriate object .
// If it's already a NoResponse value, then return make sure that if it // was skipped that it as skippable.