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.ID)) {
			result.put(MobilityColumnKey.ID.toString(abbreviated), id);
		}
		
		if(columns.contains(MobilityColumnKey.MODE)) {
			result.put(
					MobilityColumnKey.MODE.toString(abbreviated), 
					mode.toString().toLowerCase());
		}
	
		if(columns.contains(MobilityColumnKey.TIME)) {
			result.put(MobilityColumnKey.TIME.toString(abbreviated), time);
		}
	
		if(columns.contains(MobilityColumnKey.TIMESTAMP)) {
			DateTime dateTime = new DateTime(time, timezone);
			DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
			builder.appendPattern(DATE_TIME_FORMAT);

			result.put(
					MobilityColumnKey.TIMESTAMP.toString(abbreviated),
					builder.toFormatter().print(dateTime));
		}

		if(columns.contains(MobilityColumnKey.TIMEZONE)) {
			result.put(
					MobilityColumnKey.TIMEZONE.toString(abbreviated), 
					timezone.getID());
		}

		if(columns.contains(MobilityColumnKey.SUB_TYPE)) {
			result.put(
					MobilityColumnKey.SUB_TYPE.toString(abbreviated), 
					subType.toString().toLowerCase());
		}
		
		if(columns.contains(LocationColumnKey.STATUS)) {
			result.put(
					LocationColumnKey.STATUS.toString(abbreviated), 
					locationStatus.toString().toLowerCase());
		}

		if(columns.contains(MobilityColumnKey.LOCATION) ||
				LocationColumnKey.containsLocationColumnKey(columns)) {
			if(location != null) {
				result.put(
						MobilityColumnKey.LOCATION.toString(abbreviated), 
						location.toJson(abbreviated, columns));
			}
		}

		if(SubType.SENSOR_DATA.equals(subType)) {
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				SensorDataColumnKey.containsSensorDataColumnKey(columns)) {
			
				result.put(
						MobilityColumnKey.SENSOR_DATA.toString(abbreviated), 
						sensorData.toJson(abbreviated, columns));
			}
		
			if((columns.contains(MobilityColumnKey.CLASSIFIER_DATA) ||
				ClassifierDataColumnKey.containsClassifierDataColumnKey(columns)) &&
				(classifierData != null)){
				
				result.put(
					MobilityColumnKey.CLASSIFIER_DATA.toString(abbreviated), 
					classifierData.toJson(abbreviated, columns));
			}
		}
		
		return result;
	}
/**
	 * Outputs this Mobility point as a JSONObject.
	 * 
	 * @param abbreviated Whether or not to use the abbreviated versions of the
	 * 					  JSON keys.
	 * 
	 * @param withData Whether or not to include only the mode or to include
	 * 				   whatever the subtype defines.
	 * 
	 * @return A JSONObject that represents this Mobility point.
	 * 
	 * @throws JSONException There was an error creating this JSONObject.
	 */
Outputs this Mobility point as a JSONObject.

@param abbreviated Whether or not to use the abbreviated versions of the
JSON keys.

@param withData Whether or not to include only the mode or to include
whatever the subtype defines.

@return A JSONObject that represents this Mobility point.

@throws JSONException There was an error creating this JSONObject.
Outputs this Mobility point as a JSONObject . @param abbreviated Whether or not to use the abbreviated versions of the JSON keys . @param withData Whether or not to include only the mode or to include whatever the subtype defines . @return A JSONObject that represents this Mobility point . @throws JSONException There was an error creating this JSONObject .
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.ID)) {
			result.put(MobilityColumnKey.ID.toString(abbreviated), id);
		}
		if(columns.contains(MobilityColumnKey.MODE)) {
			result.put(
					MobilityColumnKey.MODE.toString(abbreviated), 
					mode.toString().toLowerCase());
		}
		if(columns.contains(MobilityColumnKey.TIME)) {
			result.put(MobilityColumnKey.TIME.toString(abbreviated), time);
		}
		if(columns.contains(MobilityColumnKey.TIMESTAMP)) {
			DateTime dateTime = new DateTime(time, timezone);
			DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
			builder.appendPattern(DATE_TIME_FORMAT);
			result.put(
					MobilityColumnKey.TIMESTAMP.toString(abbreviated),
					builder.toFormatter().print(dateTime));
		}
		if(columns.contains(MobilityColumnKey.TIMEZONE)) {
			result.put(
					MobilityColumnKey.TIMEZONE.toString(abbreviated), 
					timezone.getID());
		}
		if(columns.contains(MobilityColumnKey.SUB_TYPE)) {
			result.put(
					MobilityColumnKey.SUB_TYPE.toString(abbreviated), 
					subType.toString().toLowerCase());
		}
		if(columns.contains(LocationColumnKey.STATUS)) {
			result.put(
					LocationColumnKey.STATUS.toString(abbreviated), 
					locationStatus.toString().toLowerCase());
		}
		if(columns.contains(MobilityColumnKey.LOCATION) ||
				LocationColumnKey.containsLocationColumnKey(columns)) {
			if(location != null) {
				result.put(
						MobilityColumnKey.LOCATION.toString(abbreviated), 
						location.toJson(abbreviated, columns));
			}
		}
		if(SubType.SENSOR_DATA.equals(subType)) {
			if(columns.contains(MobilityColumnKey.SENSOR_DATA) ||
				SensorDataColumnKey.containsSensorDataColumnKey(columns)) {
				result.put(
						MobilityColumnKey.SENSOR_DATA.toString(abbreviated), 
						sensorData.toJson(abbreviated, columns));
			}
			if((columns.contains(MobilityColumnKey.CLASSIFIER_DATA) ||
				ClassifierDataColumnKey.containsClassifierDataColumnKey(columns)) &&
				(classifierData != null)){
				result.put(
					MobilityColumnKey.CLASSIFIER_DATA.toString(abbreviated), 
					classifierData.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 . ID ) ) { result . put ( MobilityColumnKey . ID . toString ( abbreviated ) , id ) ; } if ( columns . contains ( MobilityColumnKey . MODE ) ) { result . put ( MobilityColumnKey . MODE . toString ( abbreviated ) , mode . toString ( ) . toLowerCase ( ) ) ; } if ( columns . contains ( MobilityColumnKey . TIME ) ) { result . put ( MobilityColumnKey . TIME . toString ( abbreviated ) , time ) ; } if ( columns . contains ( MobilityColumnKey . TIMESTAMP ) ) { DateTime dateTime = new DateTime ( time , timezone ) ; DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder ( ) ; builder . appendPattern ( DATE_TIME_FORMAT ) ; result . put ( MobilityColumnKey . TIMESTAMP . toString ( abbreviated ) , builder . toFormatter ( ) . print ( dateTime ) ) ; } if ( columns . contains ( MobilityColumnKey . TIMEZONE ) ) { result . put ( MobilityColumnKey . TIMEZONE . toString ( abbreviated ) , timezone . getID ( ) ) ; } if ( columns . contains ( MobilityColumnKey . SUB_TYPE ) ) { result . put ( MobilityColumnKey . SUB_TYPE . toString ( abbreviated ) , subType . toString ( ) . toLowerCase ( ) ) ; } if ( columns . contains ( LocationColumnKey . STATUS ) ) { result . put ( LocationColumnKey . STATUS . toString ( abbreviated ) , locationStatus . toString ( ) . toLowerCase ( ) ) ; } if ( columns . contains ( MobilityColumnKey . LOCATION ) || LocationColumnKey . containsLocationColumnKey ( columns ) ) { if ( location != null ) { result . put ( MobilityColumnKey . LOCATION . toString ( abbreviated ) , location . toJson ( abbreviated , columns ) ) ; } } if ( SubType . SENSOR_DATA . equals ( subType ) ) { if ( columns . contains ( MobilityColumnKey . SENSOR_DATA ) || SensorDataColumnKey . containsSensorDataColumnKey ( columns ) ) { result . put ( MobilityColumnKey . SENSOR_DATA . toString ( abbreviated ) , sensorData . toJson ( abbreviated , columns ) ) ; } if ( ( columns . contains ( MobilityColumnKey . CLASSIFIER_DATA ) || ClassifierDataColumnKey . containsClassifierDataColumnKey ( columns ) ) && ( classifierData != null ) ) { result . put ( MobilityColumnKey . CLASSIFIER_DATA . toString ( abbreviated ) , classifierData . toJson ( abbreviated , columns ) ) ; } } return result ; }
Outputs this Mobility point as a JSONObject.
Outputs this Mobility point as a JSONObject .