# Print output for @column tags ?>
public
class
GenericDocument
extends Object
java.lang.Object | |
↳ | android.app.appsearch.GenericDocument |
Represents a document unit.
Documents contain structured data conforming to their AppSearchSchema
type. Each
document is uniquely identified by a namespace and a String ID within that namespace.
Documents are constructed by using the GenericDocument.Builder
.
See also:
Nested classes | |
---|---|
class |
GenericDocument.Builder<BuilderType extends Builder>
The builder class for |
Protected constructors | |
---|---|
GenericDocument(GenericDocument document)
Creates a new |
Public methods | |
---|---|
boolean
|
equals(Object other)
Indicates whether some other object is "equal to" this one. |
long
|
getCreationTimestampMillis()
Returns the creation timestamp of the |
String
|
getId()
Returns the unique identifier of the |
static
int
|
getMaxIndexedProperties()
The maximum number of indexed properties a document can have. |
String
|
getNamespace()
Returns the namespace of the |
Object
|
getProperty(String path)
Retrieves the property value with the given path as |
boolean
|
getPropertyBoolean(String path)
Retrieves a |
boolean[]
|
getPropertyBooleanArray(String path)
Retrieves a repeated |
byte[]
|
getPropertyBytes(String path)
Retrieves a |
byte[][]
|
getPropertyBytesArray(String path)
Retrieves a |
GenericDocument
|
getPropertyDocument(String path)
Retrieves a |
GenericDocument[]
|
getPropertyDocumentArray(String path)
Retrieves a repeated |
double
|
getPropertyDouble(String path)
Retrieves a |
double[]
|
getPropertyDoubleArray(String path)
Retrieves a repeated |
long
|
getPropertyLong(String path)
Retrieves a |
long[]
|
getPropertyLongArray(String path)
Retrieves a repeated |
Set<String>
|
getPropertyNames()
Returns the names of all properties defined in this document. |
String
|
getPropertyString(String path)
Retrieves a |
String[]
|
getPropertyStringArray(String path)
Retrieves a repeated |
String
|
getSchemaType()
Returns the |
int
|
getScore()
Returns the score of the |
long
|
getTtlMillis()
Returns the TTL (time-to-live) of the |
int
|
hashCode()
Returns a hash code value for the object. |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
---|---|
protected GenericDocument (GenericDocument document)
Creates a new GenericDocument
from an existing instance.
This method should be only used by constructor of a subclass.
Parameters | |
---|---|
document |
GenericDocument : This value cannot be null . |
public boolean equals (Object other)
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
Parameters | |
---|---|
other |
Object : This value may be null . |
Returns | |
---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
public long getCreationTimestampMillis ()
Returns the creation timestamp of the GenericDocument
, in milliseconds.
The value is in the System#currentTimeMillis
time base.
Value is a non-negative timestamp measured as the number of
milliseconds since 1970-01-01T00:00:00Z.
Returns | |
---|---|
long |
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
public String getId ()
Returns the unique identifier of the GenericDocument
.
Returns | |
---|---|
String |
This value cannot be null . |
public static int getMaxIndexedProperties ()
The maximum number of indexed properties a document can have.
Indexed properties are properties which are strings where the AppSearchSchema.StringPropertyConfig.getIndexingType()
value is anything other than AppSearchSchema.StringPropertyConfig.INDEXING_TYPE_NONE
.
Returns | |
---|---|
int |
public String getNamespace ()
Returns the namespace of the GenericDocument
.
Returns | |
---|---|
String |
This value cannot be null . |
public Object getProperty (String path)
Retrieves the property value with the given path as Object
.
A path can be a simple property name, such as those returned by getPropertyNames()
.
It may also be a dot-delimited path through the nested document hierarchy, with nested GenericDocument
properties accessed via '.'
and repeated properties optionally
indexed into via [n]
.
For example, given the following GenericDocument
:
(Message) { from: "sender@example.com" to: [{ name: "Albert Einstein" email: "einstein@example.com" }, { name: "Marie Curie" email: "curie@example.com" }] tags: ["important", "inbox"] subject: "Hello" }
Here are some example paths and their results:
"from"
returns "sender@example.com"
as a String
array with one
element
"to"
returns the two nested documents containing contact information as a
GenericDocument
array with two elements
"to[1]"
returns the second nested document containing Marie Curie's contact
information as a GenericDocument
array with one element
"to[1].email"
returns "curie@example.com"
"to[100].email"
returns null
as this particular document does not have
that many elements in its "to"
array.
"to.email"
aggregates emails across all nested documents that have them,
returning ["einstein@example.com", "curie@example.com"]
as a String
array with two elements.
If you know the expected type of the property you are retrieving, it is recommended to use
one of the typed versions of this method instead, such as getPropertyString(String)
or
getPropertyStringArray(String)
.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
Object |
The entry with the given path as an object or null if there is no such path.
The returned object will be one of the following types: String[] , long[] ,
double[] , boolean[] , byte[][] , GenericDocument[] . |
public boolean getPropertyBoolean (String path)
Retrieves a boolean
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
boolean |
The first boolean associated with the given path or default value false if there is no such value or the value is of a different type. |
public boolean[] getPropertyBooleanArray (String path)
Retrieves a repeated boolean
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
boolean[] |
The boolean[] associated with the given path, or null if no value is
set or the value is of a different type. |
public byte[] getPropertyBytes (String path)
Retrieves a byte[]
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
byte[] |
The first byte[] associated with the given path or null if there is
no such value or the value is of a different type. |
public byte[][] getPropertyBytesArray (String path)
Retrieves a byte[][]
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
byte[][] |
The byte[][] associated with the given path, or null if no value is
set or the value is of a different type. |
public GenericDocument getPropertyDocument (String path)
Retrieves a GenericDocument
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
GenericDocument |
The first GenericDocument associated with the given path or null if
there is no such value or the value is of a different type. |
public GenericDocument[] getPropertyDocumentArray (String path)
Retrieves a repeated GenericDocument
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
GenericDocument[] |
The GenericDocument [] associated with the given path, or null if no
value is set or the value is of a different type. |
public double getPropertyDouble (String path)
Retrieves a double
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
double |
The first double associated with the given path or default value 0.0
if there is no such value or the value is of a different type. |
public double[] getPropertyDoubleArray (String path)
Retrieves a repeated double
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
double[] |
The double[] associated with the given path, or null if no value is
set or the value is of a different type. |
public long getPropertyLong (String path)
Retrieves a long
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
long |
The first long associated with the given path or default value 0 if
there is no such value or the value is of a different type. |
public long[] getPropertyLongArray (String path)
Retrieves a repeated long[]
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
long[] |
The long[] associated with the given path, or null if no value is set
or the value is of a different type. |
public Set<String> getPropertyNames ()
Returns the names of all properties defined in this document.
Returns | |
---|---|
Set<String> |
This value cannot be null . |
public String getPropertyString (String path)
Retrieves a String
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
String |
The first String associated with the given path or null if there is
no such value or the value is of a different type. |
public String[] getPropertyStringArray (String path)
Retrieves a repeated String
property by path.
See getProperty(String)
for a detailed description of the path syntax.
Parameters | |
---|---|
path |
String : The path to look for.
This value cannot be null . |
Returns | |
---|---|
String[] |
The String[] associated with the given path, or null if no value is
set or the value is of a different type. |
public String getSchemaType ()
Returns the AppSearchSchema
type of the GenericDocument
.
Returns | |
---|---|
String |
This value cannot be null . |
public int getScore ()
Returns the score of the GenericDocument
.
The score is a query-independent measure of the document's quality, relative to other
GenericDocument
objects of the same AppSearchSchema
type.
Results may be sorted by score using SearchSpec.Builder#setRankingStrategy
.
Documents with higher scores are considered better than documents with lower scores.
Any non-negative integer can be used a score.
Returns | |
---|---|
int |
public long getTtlMillis ()
Returns the TTL (time-to-live) of the GenericDocument
, in milliseconds.
The TTL is measured against getCreationTimestampMillis()
. At the timestamp of
creationTimestampMillis + ttlMillis
, measured in the System#currentTimeMillis
time base, the document will be auto-deleted.
The default value is 0, which means the document is permanent and won't be auto-deleted
until the app is uninstalled or AppSearchSession#remove
is called.
Returns | |
---|---|
long |
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
hashCode
method
must consistently return the same integer, provided no information
used in equals
comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode
method on each of
the two objects must produce the same integer result.
equals(java.lang.Object)
method, then calling the hashCode
method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object
does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
Returns | |
---|---|
int |
a hash code value for this object. |
public String toString ()
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Returns | |
---|---|
String |
This value cannot be null . |