src/org/ohmage/domain/Location.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(LocationColumnKey.TIME)) {
			result.put(
					LocationColumnKey.TIME.toString(abbreviated), 
					getTime());
		}
			
		if(columns.contains(LocationColumnKey.TIMEZONE)) {
			result.put(
					LocationColumnKey.TIMEZONE.toString(abbreviated), 
					getTimeZone().getID());
		}
			
		if(columns.contains(LocationColumnKey.LATITUDE)) {
			result.put(
					LocationColumnKey.LATITUDE.toString(abbreviated),  
					latitude);
		}
			
		if(columns.contains(LocationColumnKey.LONGITUDE)) {
			result.put(
					LocationColumnKey.LONGITUDE.toString(abbreviated), 
					longitude);
		}
			
		if(columns.contains(LocationColumnKey.ACCURACY)) {
			result.put(
					LocationColumnKey.ACCURACY.toString(abbreviated), 
					accuracy);
		}
			
		if(columns.contains(LocationColumnKey.PROVIDER)) {
			result.put(
					LocationColumnKey.PROVIDER.toString(abbreviated), 
					provider);
		}
		
		return result;
	}
/**
	 * Creates a JSONObject that represents the information in this object with
	 * only the information whose column value is present.
	 * 
	 * @param abbreviated Whether or not the keys should use their 
	 * 					  abbreviated version.
	 * 
	 * @param columns A collection of columns dictating which variables should
	 * 				  be included in the resulting object. If this is empty, an
	 * 				  empty JSONObject will be returned. This cannot be null 
	 * 				  and if all columns are desired, a quick fix is to use
	 * 				  {@link LocationColumnKey#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 or a column key
	 * 						   was a LocationColumnKey but was not known to 
	 * 						   this function.
	 */
Creates a JSONObject that represents the information in this object with
only the information whose column value is present.

@param abbreviated Whether or not the keys should use their
abbreviated version.

@param columns A collection of columns dictating which variables should
be included in the resulting object. If this is empty, an
empty JSONObject will be returned. This cannot be null
and if all columns are desired, a quick fix is to use
LocationColumnKey#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 or a column key
was a LocationColumnKey but was not known to
this function.
Creates a JSONObject that represents the information in this object with only the information whose column value is present . @param abbreviated Whether or not the keys should use their abbreviated version . @param columns A collection of columns dictating which variables should be included in the resulting object . If this is empty an empty JSONObject will be returned . This cannot be null and if all columns are desired a quick fix is to use LocationColumnKey#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 or a column key was a LocationColumnKey but was not known to this function .
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(LocationColumnKey.TIME)) {
			result.put(
					LocationColumnKey.TIME.toString(abbreviated), 
					getTime());
		}
		if(columns.contains(LocationColumnKey.TIMEZONE)) {
			result.put(
					LocationColumnKey.TIMEZONE.toString(abbreviated), 
					getTimeZone().getID());
		}
		if(columns.contains(LocationColumnKey.LATITUDE)) {
			result.put(
					LocationColumnKey.LATITUDE.toString(abbreviated),  
					latitude);
		}
		if(columns.contains(LocationColumnKey.LONGITUDE)) {
			result.put(
					LocationColumnKey.LONGITUDE.toString(abbreviated), 
					longitude);
		}
		if(columns.contains(LocationColumnKey.ACCURACY)) {
			result.put(
					LocationColumnKey.ACCURACY.toString(abbreviated), 
					accuracy);
		}
		if(columns.contains(LocationColumnKey.PROVIDER)) {
			result.put(
					LocationColumnKey.PROVIDER.toString(abbreviated), 
					provider);
		}
		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 ( LocationColumnKey . TIME ) ) { result . put ( LocationColumnKey . TIME . toString ( abbreviated ) , getTime ( ) ) ; } if ( columns . contains ( LocationColumnKey . TIMEZONE ) ) { result . put ( LocationColumnKey . TIMEZONE . toString ( abbreviated ) , getTimeZone ( ) . getID ( ) ) ; } if ( columns . contains ( LocationColumnKey . LATITUDE ) ) { result . put ( LocationColumnKey . LATITUDE . toString ( abbreviated ) , latitude ) ; } if ( columns . contains ( LocationColumnKey . LONGITUDE ) ) { result . put ( LocationColumnKey . LONGITUDE . toString ( abbreviated ) , longitude ) ; } if ( columns . contains ( LocationColumnKey . ACCURACY ) ) { result . put ( LocationColumnKey . ACCURACY . toString ( abbreviated ) , accuracy ) ; } if ( columns . contains ( LocationColumnKey . PROVIDER ) ) { result . put ( LocationColumnKey . PROVIDER . toString ( abbreviated ) , provider ) ; } return result ; }
Creates a JSONObject that represents the information in this object with
 only the information whose column value is present.
Creates a JSONObject that represents the information in this object with only the information whose column value is present .