src/org/ohmage/validator/SurveyResponseValidators.java
public static List<SortParameter> validateSortOrder(
			final String sortOrder)
			throws ValidationException {
		
		if(StringUtils.isEmptyOrWhitespaceOnly(sortOrder)) {
			return null;
		}
		
		List<SortParameter> result = new ArrayList<SortParameter>(3);
		
		String[] sortOrderArray = sortOrder.split(InputKeys.LIST_ITEM_SEPARATOR);
		for(int i = 0 ; i < sortOrderArray.length; i++) {
			SortParameter currSortParameter;
			try {
				currSortParameter = SortParameter.getValue(sortOrderArray[i].trim());
			}
			catch(IllegalArgumentException e) {
				throw new ValidationException(
						ErrorCode.SURVEY_INVALID_SORT_ORDER, 
						"An unknown sort order value was given: " + 
							sortOrderArray[i]);
			}
			
			if(result.contains(currSortParameter)) {
				throw new ValidationException(
						ErrorCode.SURVEY_INVALID_SORT_ORDER, 
						"The same sort order value was given multiple times: " + 
							currSortParameter.toString());
			}
			else {
				result.add(currSortParameter);
			}
		}
		
		if(result.size() != SortParameter.values().length) {
			throw new ValidationException(
					ErrorCode.SURVEY_INVALID_SORT_ORDER, 
					"There are " + 
						SortParameter.values().length + 
						" sort order values and " + 
						result.size() + 
						" were given.");
		}
		
		return result;
	}
/**
	 * Validates that a list of sort order values contains all of the required
	 * values with no duplicates or is empty.
	 * 
	 * @param sortOrder The sort order values as a string.
	 * 
	 * @return An ordered list of SortParameter representing the sort 
	 * 		   parameters in their required order.
	 * 
	 * @throws ValidationException Thrown if an unknown sort order value is 
	 * 							   given, if the same sort order value is given
	 * 							   multiple times, or if all of the known sort
	 * 							   order values weren't given.
	 */
Validates that a list of sort order values contains all of the required
values with no duplicates or is empty.

@param sortOrder The sort order values as a string.

@return An ordered list of SortParameter representing the sort
parameters in their required order.

@throws ValidationException Thrown if an unknown sort order value is
given, if the same sort order value is given
multiple times, or if all of the known sort
order values weren't given.
Validates that a list of sort order values contains all of the required values with no duplicates or is empty . @param sortOrder The sort order values as a string . @return An ordered list of SortParameter representing the sort parameters in their required order . @throws ValidationException Thrown if an unknown sort order value is given if the same sort order value is given multiple times or if all of the known sort order values weren ' t given .
public static List<SortParameter> validateSortOrder(
			final String sortOrder)
			throws ValidationException {
		if(StringUtils.isEmptyOrWhitespaceOnly(sortOrder)) {
			return null;
		}
		List<SortParameter> result = new ArrayList<SortParameter>(3);
		String[] sortOrderArray = sortOrder.split(InputKeys.LIST_ITEM_SEPARATOR);
		for(int i = 0 ; i < sortOrderArray.length; i++) {
			SortParameter currSortParameter;
			try {
				currSortParameter = SortParameter.getValue(sortOrderArray[i].trim());
			}
			catch(IllegalArgumentException e) {
				throw new ValidationException(
						ErrorCode.SURVEY_INVALID_SORT_ORDER, 
						"An unknown sort order value was given: " + 
							sortOrderArray[i]);
			}
			if(result.contains(currSortParameter)) {
				throw new ValidationException(
						ErrorCode.SURVEY_INVALID_SORT_ORDER, 
						"The same sort order value was given multiple times: " + 
							currSortParameter.toString());
			}
			else {
				result.add(currSortParameter);
			}
		}
		if(result.size() != SortParameter.values().length) {
			throw new ValidationException(
					ErrorCode.SURVEY_INVALID_SORT_ORDER, 
					"There are " + 
						SortParameter.values().length + 
						" sort order values and " + 
						result.size() + 
						" were given.");
		}
		return result;
	}
public static List < SortParameter > validateSortOrder ( final String sortOrder ) throws ValidationException { if ( StringUtils . isEmptyOrWhitespaceOnly ( sortOrder ) ) { return null ; } List < SortParameter > result = new ArrayList < SortParameter > ( 3 ) ; String [ ] sortOrderArray = sortOrder . split ( InputKeys . LIST_ITEM_SEPARATOR ) ; for ( int i = 0 ; i < sortOrderArray . length ; i ++ ) { SortParameter currSortParameter ; try { currSortParameter = SortParameter . getValue ( sortOrderArray [ i ] . trim ( ) ) ; } catch ( IllegalArgumentException e ) { throw new ValidationException ( ErrorCode . SURVEY_INVALID_SORT_ORDER , "An unknown sort order value was given: " + sortOrderArray [ i ] ) ; } if ( result . contains ( currSortParameter ) ) { throw new ValidationException ( ErrorCode . SURVEY_INVALID_SORT_ORDER , "The same sort order value was given multiple times: " + currSortParameter . toString ( ) ) ; } else { result . add ( currSortParameter ) ; } } if ( result . size ( ) != SortParameter . values ( ) . length ) { throw new ValidationException ( ErrorCode . SURVEY_INVALID_SORT_ORDER , "There are " + SortParameter . values ( ) . length + " sort order values and " + result . size ( ) + " were given." ) ; } return result ; }
Validates that a list of sort order values contains all of the required
 values with no duplicates or is empty.
Validates that a list of sort order values contains all of the required values with no duplicates or is empty .