Value

public final class Value extends Object
implements Parcelable

Holder object for the value of a single field in a data point. Values are not constructed directly; a value for each field of the data type is created for each data point.

A field value has a particular format, and should be set and read using the format-specific methods. For instance, a float value should be set via setFloat(float) and read via asFloat(). Formats are defined as constants in Field

Inherited Constant Summary

Public Method Summary

String
asActivity()
Returns the value of this object as an activity.
float
asFloat()
Returns the value of this object as a float.
int
asInt()
Returns the value of this object as an int.
String
asString()
Returns the value of this object as a string.
void
clearKey(String key)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
boolean
equals(Object other)
int
getFormat()
Returns the format of this value, which matches the appropriate field in the data type definition.
Float
getKeyValue(String key)
Returns the value of the given key in the map as a Float.
int
boolean
isSet()
Returns true if this object's value has been set by calling one of the setters.
void
setActivity(String activity)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
void
setFloat(float value)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
void
setInt(int value)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
void
setKeyValue(String key, float value)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
void
setString(String value)
This method is deprecated. Use DataPoint.Builder to construct new DataPoint instances.
String
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Public Methods

public String asActivity ()

Returns the value of this object as an activity. The integer representation of the activity is converted to a String prior to returning.

Returns
Throws
IllegalStateException If this Value does not correspond to a Field.FORMAT_INT32

public float asFloat ()

Returns the value of this object as a float.

Throws
IllegalStateException If this Value does not correspond to a Field.FORMAT_FLOAT

public int asInt ()

Returns the value of this object as an int.

Throws
IllegalStateException If this Value does not correspond to Field.FORMAT_INT32

public String asString ()

Returns the value of this object as a string.

Throws
IllegalStateException If this Value does not correspond to a Field.FORMAT_STRING

public void clearKey (String key)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Clears any value currently associated with the given key in the map. This method can be used only on map values.

Parameters
key The key you're modifying.

public boolean equals (Object other)

public int getFormat ()

Returns the format of this value, which matches the appropriate field in the data type definition.

Returns
  • One of the format constants from Field.

public Float getKeyValue (String key)

Returns the value of the given key in the map as a Float.

Returns
  • null if the key doesn't have a set value in the map.
Throws
IllegalStateException If this Value does not correspond to a Field.FORMAT_MAP

public int hashCode ()

public boolean isSet ()

Returns true if this object's value has been set by calling one of the setters.

public void setActivity (String activity)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Updates this value object to represent an activity value. Activities are internally represented as integers for storage.

Parameters
activity One of the activities from FitnessActivities

public void setFloat (float value)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Updates this value object to represent a float value. Any previous values associated with this object are erased.

Parameters
value The new value that this objects holds.

public void setInt (int value)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Updates this value object to represent an int value. Any previous values are erased.

Parameters
value The new value that this object holds.

public void setKeyValue (String key, float value)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Updates the value for a given key in the map to the given float value. Any previous values associated with the key are erased. This method can be used only on map values.

Key values should be kept small whenever possible. This is specially important for high frequency streams, since large keys may result in down sampling.

Parameters
key The key you're modifying.
value The new value for the given key.

public void setString (String value)

This method is deprecated.
Use DataPoint.Builder to construct new DataPoint instances.

Updates this value object to represent a string value. Any previous values associated with this object are erased.

String values should be kept small whenever possible. This is specially important for high frequency streams, since large values may result in down sampling.

Parameters
value The new value that this objects holds.

public String toString ()

public void writeToParcel (Parcel dest, int flags)