src/org/ohmage/domain/MobilityPoint.java
public final JSONObject toJson(
				final boolean abbreviated,
				final Collection<ColumnKey> columns) 
				throws JSONException, DomainException {
			
			if(columns == null) {
				throw new DomainException("The list of columns cannot be null.");
			}
			
			JSONObject result = new JSONObject();
			
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.MODE)) {
				result.put(
						MobilityColumnKey.MODE.toString(abbreviated),
						mode.name().toLowerCase());
			}
			
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.SPEED)) {
				
				if(speed == null) {
					// Don't put it in the JSON.
				}
				else if(speed.isInfinite()) {
					if(Double.POSITIVE_INFINITY == speed.doubleValue()) {
						result.put(
								SensorDataColumnKey.SPEED.toString(
										abbreviated),
								"Infinity");
					}
					else {
						result.put(
								SensorDataColumnKey.SPEED.toString(
										abbreviated),
								"-Infinity");
					}
				}
				else if(speed.isNaN()) {
					result.put(
							SensorDataColumnKey.SPEED.toString(abbreviated),
							"NaN");
				}
				else {
					result.put(
							SensorDataColumnKey.SPEED.toString(abbreviated), 
							speed);
				}
			}
			
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.ACCELEROMETER_DATA) ||
				AccelDataColumnKey.containsAccelDataColumnKey(columns)) {

				if(accelData == null) {
					// Don't put it in the JSON.
				}
				else {
					JSONArray accelArray = new JSONArray();
					for(AccelData accelRecord : accelData) {
						accelArray.put(accelRecord.toJson(columns));
					}
					result.put(
							SensorDataColumnKey.ACCELEROMETER_DATA.toString(
									abbreviated),
							accelArray);
				}
			}
			
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.WIFI_DATA) ||
				WifiDataColumnKey.containsWifiDataColumnKey(columns)) {
				
				if(wifiData == null) {
					result.put(
							SensorDataColumnKey.WIFI_DATA.toString(
									abbreviated),
							new JSONObject());
				}
				else {
					result.put(
							SensorDataColumnKey.WIFI_DATA.toString(
									abbreviated),
							wifiData.toJson(abbreviated, columns));
				}
			}
			
			return result;
		}
/**
		 * Creates a JSONObject that represents the sensor data with only the 
		 * information whose column value is present or any of the columns that
		 * belong to objects owned by this sensor data.
		 * 
		 * @param columns A collection of columns dictating which variables
		 * 				  should be included in the resulting object. If 
		 * 				  this is empty, a JSONObject with the mode only will  
		 * 				  be returned. This cannot be null and if all columns 
		 * 				  are desired, a quick fix is to use
		 * 				  {@link SensorDataColumnKey#ALL_COLUMNS}.
		 * 
		 * @return Returns a JSONObject that represents this object with 
		 * 		   only the requested columns.
		 * 
		 * @throws JSONException There was an error building the 
		 * 						 JSONObject.
		 * 
		 * @throws DomainException The columns collection was null.
		 */
Creates a JSONObject that represents the sensor data with only the
information whose column value is present or any of the columns that
belong to objects owned by this sensor data.

@param columns A collection of columns dictating which variables
should be included in the resulting object. If
this is empty, a JSONObject with the mode only will
be returned. This cannot be null and if all columns
are desired, a quick fix is to use
SensorDataColumnKey#ALL_COLUMNS.

@return Returns a JSONObject that represents this object with
only the requested columns.

@throws JSONException There was an error building the
JSONObject.

@throws DomainException The columns collection was null.
Creates a JSONObject that represents the sensor data with only the information whose column value is present or any of the columns that belong to objects owned by this sensor data . @param columns A collection of columns dictating which variables should be included in the resulting object . If this is empty a JSONObject with the mode only will be returned . This cannot be null and if all columns are desired a quick fix is to use SensorDataColumnKey#ALL_COLUMNS . @return Returns a JSONObject that represents this object with only the requested columns . @throws JSONException There was an error building the JSONObject . @throws DomainException The columns collection was null .
public final JSONObject toJson(
				final boolean abbreviated,
				final Collection<ColumnKey> columns) 
				throws JSONException, DomainException {
			if(columns == null) {
				throw new DomainException("The list of columns cannot be null.");
			}
			JSONObject result = new JSONObject();
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.MODE)) {
				result.put(
						MobilityColumnKey.MODE.toString(abbreviated),
						mode.name().toLowerCase());
			}
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.SPEED)) {
				if(speed == null) {
				}
				else if(speed.isInfinite()) {
					if(Double.POSITIVE_INFINITY == speed.doubleValue()) {
						result.put(
								SensorDataColumnKey.SPEED.toString(
										abbreviated),
								"Infinity");
					}
					else {
						result.put(
								SensorDataColumnKey.SPEED.toString(
										abbreviated),
								"-Infinity");
					}
				}
				else if(speed.isNaN()) {
					result.put(
							SensorDataColumnKey.SPEED.toString(abbreviated),
							"NaN");
				}
				else {
					result.put(
							SensorDataColumnKey.SPEED.toString(abbreviated), 
							speed);
				}
			}
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.ACCELEROMETER_DATA) ||
				AccelDataColumnKey.containsAccelDataColumnKey(columns)) {
				if(accelData == null) {
				}
				else {
					JSONArray accelArray = new JSONArray();
					for(AccelData accelRecord : accelData) {
						accelArray.put(accelRecord.toJson(columns));
					}
					result.put(
							SensorDataColumnKey.ACCELEROMETER_DATA.toString(
									abbreviated),
							accelArray);
				}
			}
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				columns.contains(SensorDataColumnKey.WIFI_DATA) ||
				WifiDataColumnKey.containsWifiDataColumnKey(columns)) {
				if(wifiData == null) {
					result.put(
							SensorDataColumnKey.WIFI_DATA.toString(
									abbreviated),
							new JSONObject());
				}
				else {
					result.put(
							SensorDataColumnKey.WIFI_DATA.toString(
									abbreviated),
							wifiData.toJson(abbreviated, columns));
				}
			}
			return result;
		}
public final JSONObject toJson ( final boolean abbreviated , final Collection < ColumnKey > columns ) throws JSONException , DomainException { if ( columns == null ) { throw new DomainException ( "The list of columns cannot be null." ) ; } JSONObject result = new JSONObject ( ) ; if ( columns . contains ( MobilityColumnKey . SENSOR_DATA ) || columns . contains ( SensorDataColumnKey . MODE ) ) { result . put ( MobilityColumnKey . MODE . toString ( abbreviated ) , mode . name ( ) . toLowerCase ( ) ) ; } if ( columns . contains ( MobilityColumnKey . SENSOR_DATA ) || columns . contains ( SensorDataColumnKey . SPEED ) ) { if ( speed == null ) { } else if ( speed . isInfinite ( ) ) { if ( Double . POSITIVE_INFINITY == speed . doubleValue ( ) ) { result . put ( SensorDataColumnKey . SPEED . toString ( abbreviated ) , "Infinity" ) ; } else { result . put ( SensorDataColumnKey . SPEED . toString ( abbreviated ) , "-Infinity" ) ; } } else if ( speed . isNaN ( ) ) { result . put ( SensorDataColumnKey . SPEED . toString ( abbreviated ) , "NaN" ) ; } else { result . put ( SensorDataColumnKey . SPEED . toString ( abbreviated ) , speed ) ; } } if ( columns . contains ( MobilityColumnKey . SENSOR_DATA ) || columns . contains ( SensorDataColumnKey . ACCELEROMETER_DATA ) || AccelDataColumnKey . containsAccelDataColumnKey ( columns ) ) { if ( accelData == null ) { } else { JSONArray accelArray = new JSONArray ( ) ; for ( AccelData accelRecord : accelData ) { accelArray . put ( accelRecord . toJson ( columns ) ) ; } result . put ( SensorDataColumnKey . ACCELEROMETER_DATA . toString ( abbreviated ) , accelArray ) ; } } if ( columns . contains ( MobilityColumnKey . SENSOR_DATA ) || columns . contains ( SensorDataColumnKey . WIFI_DATA ) || WifiDataColumnKey . containsWifiDataColumnKey ( columns ) ) { if ( wifiData == null ) { result . put ( SensorDataColumnKey . WIFI_DATA . toString ( abbreviated ) , new JSONObject ( ) ) ; } else { result . put ( SensorDataColumnKey . WIFI_DATA . toString ( abbreviated ) , wifiData . toJson ( abbreviated , columns ) ) ; } } return result ; }
Creates a JSONObject that represents the sensor data with only the
 information whose column value is present or any of the columns that
 belong to objects owned by this sensor data.
Creates a JSONObject that represents the sensor data with only the information whose column value is present or any of the columns that belong to objects owned by this sensor data .
// Don't put it in the JSON. // Don't put it in the JSON.