src/org/ohmage/validator/MobilityValidators.java
public static List<MobilityPoint> validateDataAsJsonArray(
			final String data, 
			Collection<JSONObject> invalidPoint) 
			throws ValidationException {
		
		LOGGER.info("Validating a JSONArray of data points.");
		
		if(StringUtils.isEmptyOrWhitespaceOnly(data)) {
			return null;
		}
		
		try {
			JSONArray jsonArray = new JSONArray(data.trim());
			
			List<MobilityPoint> result = new LinkedList<MobilityPoint>();
			for(int i = 0; i < jsonArray.length(); i++) {
				JSONObject mobilityPointJson = jsonArray.getJSONObject(i);
				
				try {
					result.add(
							new MobilityPoint(
									mobilityPointJson, 
									MobilityPoint.PrivacyState.PRIVATE));
				}
				catch(DomainException invalidPointException) {
					LOGGER.warn("Invalid point.", invalidPointException);
					invalidPoint.add(mobilityPointJson);
				}
			}
			
			return result;
		}
		catch(JSONException e) {
			throw new ValidationException(
					ErrorCode.SERVER_INVALID_JSON, 
					"The JSONArray containing the data is malformed.", 
					e);
		}
	}
/**
	 * Validates Mobility data in the format of a JSONArray of JSONObjects 
	 * where each JSONObject is a Mobility data point. It returns the decoded
	 * Mobility points and adds the invalid Mobility points and their 
	 * respective ID (if retrievable) to the parameterized lists.
	 * 
	 * @param data The data to be validated. The expected value is a JSONArray
	 * 			   of JSONObjects where each JSONObject is a Mobility data
	 * 			   point.
	 * 
	 * @param invalidPointIds The IDs from their respective JSON objects where
	 * 						  the entire point contained some error(s).
	 * 
	 * @param invalidPoint The JSONObject for each point that contained 
	 * 					   some error. There may or may not be a 
	 * 					   corresponding ID in the 'invalidPointIds' list
	 * 					   depending on whether the ID was retrievable or
	 * 					   not.
	 * 
	 * @return Returns null if the data is null or whitespace only; otherwise,
	 * 		   a list of MobilityPoint objects is returned.
	 * 
	 * @throws ValidationException Thrown if the data is not null, not
	 * 							   whitespace only, and the data String cannot
	 * 							   be decoded into JSON.
	 */
Validates Mobility data in the format of a JSONArray of JSONObjects
where each JSONObject is a Mobility data point. It returns the decoded
Mobility points and adds the invalid Mobility points and their
respective ID (if retrievable) to the parameterized lists.

@param data The data to be validated. The expected value is a JSONArray
of JSONObjects where each JSONObject is a Mobility data
point.

@param invalidPointIds The IDs from their respective JSON objects where
the entire point contained some error(s).

@param invalidPoint The JSONObject for each point that contained
some error. There may or may not be a
corresponding ID in the 'invalidPointIds' list
depending on whether the ID was retrievable or
not.

@return Returns null if the data is null or whitespace only; otherwise,
a list of MobilityPoint objects is returned.

@throws ValidationException Thrown if the data is not null, not
whitespace only, and the data String cannot
be decoded into JSON.
Validates Mobility data in the format of a JSONArray of JSONObjects where each JSONObject is a Mobility data point . It returns the decoded Mobility points and adds the invalid Mobility points and their respective ID ( if retrievable ) to the parameterized lists . @param data The data to be validated . The expected value is a JSONArray of JSONObjects where each JSONObject is a Mobility data point . @param invalidPointIds The IDs from their respective JSON objects where the entire point contained some error ( s ) . @param invalidPoint The JSONObject for each point that contained some error . There may or may not be a corresponding ID in the ' invalidPointIds ' list depending on whether the ID was retrievable or not . @return Returns null if the data is null or whitespace only ; otherwise a list of MobilityPoint objects is returned . @throws ValidationException Thrown if the data is not null not whitespace only and the data String cannot be decoded into JSON .
public static List<MobilityPoint> validateDataAsJsonArray(
			final String data, 
			Collection<JSONObject> invalidPoint) 
			throws ValidationException {
		LOGGER.info("Validating a JSONArray of data points.");
		if(StringUtils.isEmptyOrWhitespaceOnly(data)) {
			return null;
		}
		try {
			JSONArray jsonArray = new JSONArray(data.trim());
			List<MobilityPoint> result = new LinkedList<MobilityPoint>();
			for(int i = 0; i < jsonArray.length(); i++) {
				JSONObject mobilityPointJson = jsonArray.getJSONObject(i);
				try {
					result.add(
							new MobilityPoint(
									mobilityPointJson, 
									MobilityPoint.PrivacyState.PRIVATE));
				}
				catch(DomainException invalidPointException) {
					LOGGER.warn("Invalid point.", invalidPointException);
					invalidPoint.add(mobilityPointJson);
				}
			}
			return result;
		}
		catch(JSONException e) {
			throw new ValidationException(
					ErrorCode.SERVER_INVALID_JSON, 
					"The JSONArray containing the data is malformed.", 
					e);
		}
	}
public static List < MobilityPoint > validateDataAsJsonArray ( final String data , Collection < JSONObject > invalidPoint ) throws ValidationException { LOGGER . info ( "Validating a JSONArray of data points." ) ; if ( StringUtils . isEmptyOrWhitespaceOnly ( data ) ) { return null ; } try { JSONArray jsonArray = new JSONArray ( data . trim ( ) ) ; List < MobilityPoint > result = new LinkedList < MobilityPoint > ( ) ; for ( int i = 0 ; i < jsonArray . length ( ) ; i ++ ) { JSONObject mobilityPointJson = jsonArray . getJSONObject ( i ) ; try { result . add ( new MobilityPoint ( mobilityPointJson , MobilityPoint . PrivacyState . PRIVATE ) ) ; } catch ( DomainException invalidPointException ) { LOGGER . warn ( "Invalid point." , invalidPointException ) ; invalidPoint . add ( mobilityPointJson ) ; } } return result ; } catch ( JSONException e ) { throw new ValidationException ( ErrorCode . SERVER_INVALID_JSON , "The JSONArray containing the data is malformed." , e ) ; } }
Validates Mobility data in the format of a JSONArray of JSONObjects
 where each JSONObject is a Mobility data point.
Validates Mobility data in the format of a JSONArray of JSONObjects where each JSONObject is a Mobility data point .