src/org/ohmage/validator/ObserverValidators.java
public static final long validateNumToReturn(
			final String value,
			final long limit)
			throws ValidationException {
		
		if(StringUtils.isEmptyOrWhitespaceOnly(value)) {
			return limit;
		}
		
		try {
			long result = Long.decode(value);

			if(result < 0) {
				throw new ValidationException(
					ErrorCode.SERVER_INVALID_NUM_TO_RETURN,
					"The number to return must be positive: " + result);
			}
			else if(result > limit) {
				throw new ValidationException(
					ErrorCode.SERVER_INVALID_NUM_TO_RETURN,
					"The number to return is greater than the allowed maximum (" +
						limit +
						"): " +
						result);
			}
			
			return result;
		}
		catch(NumberFormatException e) {
			throw new ValidationException(
				ErrorCode.SERVER_INVALID_NUM_TO_SKIP,
				"The number to skip is not a valid number.",
				e);
		}
	}
/**
	 * Validates that the number to return is positive or zero and less than or
	 * equal to the maximum allowed.
	 * 
	 * @param value The value to be validated.
	 * 
	 * @return The number to return.
	 * 
	 * @throws ValidationException The number was negative or greater than the
	 * 							   allowed maximum.
	 */
Validates that the number to return is positive or zero and less than or
equal to the maximum allowed.

@param value The value to be validated.

@return The number to return.

@throws ValidationException The number was negative or greater than the
allowed maximum.
Validates that the number to return is positive or zero and less than or equal to the maximum allowed . @param value The value to be validated . @return The number to return . @throws ValidationException The number was negative or greater than the allowed maximum .
public static final long validateNumToReturn(
			final String value,
			final long limit)
			throws ValidationException {
		if(StringUtils.isEmptyOrWhitespaceOnly(value)) {
			return limit;
		}
		try {
			long result = Long.decode(value);
			if(result < 0) {
				throw new ValidationException(
					ErrorCode.SERVER_INVALID_NUM_TO_RETURN,
					"The number to return must be positive: " + result);
			}
			else if(result > limit) {
				throw new ValidationException(
					ErrorCode.SERVER_INVALID_NUM_TO_RETURN,
					"The number to return is greater than the allowed maximum (" +
						limit +
						"): " +
						result);
			}
			return result;
		}
		catch(NumberFormatException e) {
			throw new ValidationException(
				ErrorCode.SERVER_INVALID_NUM_TO_SKIP,
				"The number to skip is not a valid number.",
				e);
		}
	}
public static final long validateNumToReturn ( final String value , final long limit ) throws ValidationException { if ( StringUtils . isEmptyOrWhitespaceOnly ( value ) ) { return limit ; } try { long result = Long . decode ( value ) ; if ( result < 0 ) { throw new ValidationException ( ErrorCode . SERVER_INVALID_NUM_TO_RETURN , "The number to return must be positive: " + result ) ; } else if ( result > limit ) { throw new ValidationException ( ErrorCode . SERVER_INVALID_NUM_TO_RETURN , "The number to return is greater than the allowed maximum (" + limit + "): " + result ) ; } return result ; } catch ( NumberFormatException e ) { throw new ValidationException ( ErrorCode . SERVER_INVALID_NUM_TO_SKIP , "The number to skip is not a valid number." , e ) ; } }
Validates that the number to return is positive or zero and less than or
 equal to the maximum allowed.
Validates that the number to return is positive or zero and less than or equal to the maximum allowed .