src/org/ohmage/validator/SurveyResponseValidators.java
public static Set<SurveyResponse.ColumnKey> validateColumnList(
			final String columnList) throws ValidationException {
		
		if(StringUtils.isEmptyOrWhitespaceOnly(columnList)) {
			return null;
		}
		
		Set<SurveyResponse.ColumnKey> result = new HashSet<SurveyResponse.ColumnKey>();
		
		// Split the list into the individual items and cycle through them.
		String[] columnListArray = columnList.split(InputKeys.LIST_ITEM_SEPARATOR);
		for(int i = 0; i < columnListArray.length; i++) {
			// Sometimes the split function parses out empty strings, so we 
			// will ignore those.
			if(! StringUtils.isEmptyOrWhitespaceOnly(columnListArray[i])) {
				// Get the current non-null, non-empty string value.
				String currValue = columnListArray[i].trim();
				
				// Attempt to parse it into a known column key and add it.
				try {
					result.add(SurveyResponse.ColumnKey.getValue(currValue));
				}
				catch(IllegalArgumentException e) {
					// If the column key is unknown, check if it is the special
					// key that represents all columns.
					if(SurveyResponseRequest.URN_SPECIAL_ALL.equals(currValue)) {
						// It is the special key, so add all of the known 
						// column keys and return the result.
						ColumnKey[] allKeys = SurveyResponse.ColumnKey.values();
						for(int j = 0; j < allKeys.length; j++) {
							result.add(allKeys[j]);
						}
						
						return result;
					}
					// It is not the special key and wasn't a known key, so 
					// throw an exception.
					else {
						throw new ValidationException(
								ErrorCode.SURVEY_MALFORMED_COLUMN_LIST, 
								"The column list contains an unknown value: " +
									currValue, 
								e);
					}
				}
			}
		}
		
		return result;
	}
/**
	 * Validates that the column list string contains only valid column keys or
	 * none at all. 
	 * 
	 * @param columnList The column list as a string.
	 * 
	 * @return Null if the column list string is null or whitespace only;
	 * 		   otherwise, a, possibly empty, list of column keys is returned.
	 * 		   If the special all keys key is given, the resulting collection
	 * 		   will contain all of the known keys.
	 *  
	 * @throws ValidationException Thrown if an unknown key is found.
	 */
Validates that the column list string contains only valid column keys or
none at all.

@param columnList The column list as a string.

@return Null if the column list string is null or whitespace only;
otherwise, a, possibly empty, list of column keys is returned.
If the special all keys key is given, the resulting collection
will contain all of the known keys.

@throws ValidationException Thrown if an unknown key is found.
Validates that the column list string contains only valid column keys or none at all . @param columnList The column list as a string . @return Null if the column list string is null or whitespace only ; otherwise a possibly empty list of column keys is returned . If the special all keys key is given the resulting collection will contain all of the known keys . @throws ValidationException Thrown if an unknown key is found .
public static Set<SurveyResponse.ColumnKey> validateColumnList(
			final String columnList) throws ValidationException {
		if(StringUtils.isEmptyOrWhitespaceOnly(columnList)) {
			return null;
		}
		Set<SurveyResponse.ColumnKey> result = new HashSet<SurveyResponse.ColumnKey>();
		String[] columnListArray = columnList.split(InputKeys.LIST_ITEM_SEPARATOR);
		for(int i = 0; i < columnListArray.length; i++) {
			if(! StringUtils.isEmptyOrWhitespaceOnly(columnListArray[i])) {
				String currValue = columnListArray[i].trim();
				try {
					result.add(SurveyResponse.ColumnKey.getValue(currValue));
				}
				catch(IllegalArgumentException e) {
					if(SurveyResponseRequest.URN_SPECIAL_ALL.equals(currValue)) {
						ColumnKey[] allKeys = SurveyResponse.ColumnKey.values();
						for(int j = 0; j < allKeys.length; j++) {
							result.add(allKeys[j]);
						}
						return result;
					}
					else {
						throw new ValidationException(
								ErrorCode.SURVEY_MALFORMED_COLUMN_LIST, 
								"The column list contains an unknown value: " +
									currValue, 
								e);
					}
				}
			}
		}
		return result;
	}
public static Set < SurveyResponse . ColumnKey > validateColumnList ( final String columnList ) throws ValidationException { if ( StringUtils . isEmptyOrWhitespaceOnly ( columnList ) ) { return null ; } Set < SurveyResponse . ColumnKey > result = new HashSet < SurveyResponse . ColumnKey > ( ) ; String [ ] columnListArray = columnList . split ( InputKeys . LIST_ITEM_SEPARATOR ) ; for ( int i = 0 ; i < columnListArray . length ; i ++ ) { if ( ! StringUtils . isEmptyOrWhitespaceOnly ( columnListArray [ i ] ) ) { String currValue = columnListArray [ i ] . trim ( ) ; try { result . add ( SurveyResponse . ColumnKey . getValue ( currValue ) ) ; } catch ( IllegalArgumentException e ) { if ( SurveyResponseRequest . URN_SPECIAL_ALL . equals ( currValue ) ) { ColumnKey [ ] allKeys = SurveyResponse . ColumnKey . values ( ) ; for ( int j = 0 ; j < allKeys . length ; j ++ ) { result . add ( allKeys [ j ] ) ; } return result ; } else { throw new ValidationException ( ErrorCode . SURVEY_MALFORMED_COLUMN_LIST , "The column list contains an unknown value: " + currValue , e ) ; } } } } return result ; }
Validates that the column list string contains only valid column keys or
 none at all.
Validates that the column list string contains only valid column keys or none at all .
// Split the list into the individual items and cycle through them. // Sometimes the split function parses out empty strings, so we  // will ignore those. // Get the current non-null, non-empty string value. // Attempt to parse it into a known column key and add it. // If the column key is unknown, check if it is the special // key that represents all columns. // It is the special key, so add all of the known  // column keys and return the result. // It is not the special key and wasn't a known key, so  // throw an exception.