public final class

DataHolder

extends Object
implements Parcelable
java.lang.Object
   ↳ com.google.android.gms.common.data.DataHolder

Class Overview

Class for accessing collections of data, organized into columns. This provides the backing support for DataBuffer. Much like a cursor, the holder supports the notion of a current position, and has methods for extracting various types of data from named columns.

Summary

Nested Classes
class DataHolder.Builder Helper class to build DataHolder instances containing arbitrary data. 
Constants
String NULL
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final DataHolderCreator CREATOR
Public Constructors
DataHolder(String[] columns, CursorWindow[] windows, int statusCode, Bundle metadata)
Creates a data holder with the specified data.
DataHolder(AbstractWindowedCursor cursor, int statusCode, Bundle metadata)
Creates a data holder wrapping the provided cursor, with provided status code and metadata.
Public Methods
static DataHolder.Builder builder(String[] columns, String uniqueColumn)
Get a DataHolder.Builder to create a new DataHolder manually.
static DataHolder.Builder builder(String[] columns)
Get a DataHolder.Builder to create a new DataHolder manually.
void close()
Closes the data holder, releasing all of its resources and making it completely invalid.
void copyToBuffer(String column, int row, int windowIndex, CharArrayBuffer dataOut)
Copies the String content in the given column at the provided position into a CharArrayBuffer.
int describeContents()
static DataHolder empty(int statusCode, Bundle metadata)
static DataHolder empty(int statusCode)
boolean getBoolean(String column, int row, int windowIndex)
Retrieves the boolean value for a given column at the provided position.
byte[] getByteArray(String column, int row, int windowIndex)
Retrieves the byte array value for a given column at the provided position.
int getCount()
Gets the number of rows in the data holder.
int getInteger(String column, int row, int windowIndex)
Retrieves the integer value for a given column at the provided position.
long getLong(String column, int row, int windowIndex)
Retrieves the long value for a given column at the provided position.
int getStatusCode()
String getString(String column, int row, int windowIndex)
Retrieves the String value for a given column at the provided position.
boolean hasNull(String column, int row, int windowIndex)
Returns whether the given column at the provided position contains null.
boolean isClosed()
Uri parseUri(String column, int row, int windowIndex)
Retrieves the column data at the provided position as a URI if possible, checking for null values.
void validateContents()
void writeToParcel(Parcel dest, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final String NULL

Constant Value: "SAFE_PARCELABLE_NULL_STRING"

Fields

public static final DataHolderCreator CREATOR

Public Constructors

public DataHolder (String[] columns, CursorWindow[] windows, int statusCode, Bundle metadata)

Creates a data holder with the specified data.

Parameters
columns The column names corresponding to the data in the given windows.
windows The CursorWindow instances holding the data.
statusCode The status code of this DataHolder.
metadata The metadata associated with this DataHolder (may be null).

public DataHolder (AbstractWindowedCursor cursor, int statusCode, Bundle metadata)

Creates a data holder wrapping the provided cursor, with provided status code and metadata.

Parameters
cursor The cursor containing the data.
statusCode The status code of this DataHolder.
metadata The metadata associated with this DataHolder (may be null).

Public Methods

public static DataHolder.Builder builder (String[] columns, String uniqueColumn)

Get a DataHolder.Builder to create a new DataHolder manually.

Parameters
columns The array of column names that the object supports.
uniqueColumn The non-null column name that must contain unique values. New rows added to the builder with the same value in this column will replace any older rows.
Returns

public static DataHolder.Builder builder (String[] columns)

Get a DataHolder.Builder to create a new DataHolder manually.

Parameters
columns The array of column names that the object supports.
Returns

public void close ()

Closes the data holder, releasing all of its resources and making it completely invalid.

public void copyToBuffer (String column, int row, int windowIndex, CharArrayBuffer dataOut)

Copies the String content in the given column at the provided position into a CharArrayBuffer. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
dataOut The CharArrayBuffer to copy into.

public int describeContents ()

public static DataHolder empty (int statusCode, Bundle metadata)

Parameters
statusCode The status code of this DataHolder.
metadata The metadata associated with this DataHolder (may be null).
Returns
  • An empty DataHolder object with the given status and null metadata.

public static DataHolder empty (int statusCode)

Parameters
statusCode The status code of this DataHolder.
Returns
  • An empty DataHolder object with the given status and null metadata.

public boolean getBoolean (String column, int row, int windowIndex)

Retrieves the boolean value for a given column at the provided position. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The boolean value in that column.

public byte[] getByteArray (String column, int row, int windowIndex)

Retrieves the byte array value for a given column at the provided position. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The byte array value in that column.

public int getCount ()

Gets the number of rows in the data holder.

Returns
  • the number of rows in the data holder.

public int getInteger (String column, int row, int windowIndex)

Retrieves the integer value for a given column at the provided position. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The integer value in that column.

public long getLong (String column, int row, int windowIndex)

Retrieves the long value for a given column at the provided position. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The long value in that column.

public int getStatusCode ()

Returns
  • Service-specific status code indicating whether data was successfully loaded.

public String getString (String column, int row, int windowIndex)

Retrieves the String value for a given column at the provided position. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The String value in that column.

public boolean hasNull (String column, int row, int windowIndex)

Returns whether the given column at the provided position contains null. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to check.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • Whether the column value is null at this position.

public boolean isClosed ()

public Uri parseUri (String column, int row, int windowIndex)

Retrieves the column data at the provided position as a URI if possible, checking for null values. This will throw an IllegalArgumentException if the column does not exist, the position is invalid, or the data holder has been closed.

Parameters
column The column to retrieve.
row The row to retrieve the data from.
windowIndex Index of the cursor window to extract the data from.
Returns
  • The column data as a URI, or null if not present.

public void validateContents ()

public void writeToParcel (Parcel dest, int flags)