public class RestrictionEntry extends Object implements Parcelable
Intent.ACTION_GET_RESTRICTION_ENTRIES
action.
The receiver then returns a result bundle that contains an entry called "restrictions", whose
value is an ArrayListParcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<RestrictionEntry> |
CREATOR |
static int |
TYPE_BOOLEAN
Restriction of type "bool".
|
static int |
TYPE_BUNDLE
Restriction of type "bundle".
|
static int |
TYPE_BUNDLE_ARRAY
Restriction of type "bundle_array".
|
static int |
TYPE_CHOICE
Restriction of type "choice".
|
static int |
TYPE_CHOICE_LEVEL
Internal restriction type.
|
static int |
TYPE_INTEGER
Restriction of type "integer".
|
static int |
TYPE_MULTI_SELECT
Restriction of type "multi-select".
|
static int |
TYPE_NULL
Hidden restriction type.
|
static int |
TYPE_STRING
Restriction of type "string".
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
RestrictionEntry(int type,
String key)
Constructor for specifying the type and key, with no initial value;
|
RestrictionEntry(Parcel in) |
RestrictionEntry(String key,
boolean selectedState)
Constructor for
TYPE_BOOLEAN type. |
RestrictionEntry(String key,
int selectedInt)
Constructor for
TYPE_INTEGER type. |
RestrictionEntry(String key,
String selectedString)
Constructor for
TYPE_CHOICE type. |
RestrictionEntry(String key,
String[] selectedStrings)
Constructor for
TYPE_MULTI_SELECT type. |
Modifier and Type | Method and Description |
---|---|
static RestrictionEntry |
createBundleArrayEntry(String key,
RestrictionEntry[] restrictionEntries)
Creates an entry of type
TYPE_BUNDLE_ARRAY . |
static RestrictionEntry |
createBundleEntry(String key,
RestrictionEntry[] restrictionEntries)
Creates an entry of type
TYPE_BUNDLE . |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
String[] |
getAllSelectedStrings()
Returns the list of currently selected values.
|
String[] |
getChoiceEntries()
Returns the list of strings, set earlier, that will be presented as choices to the user.
|
String[] |
getChoiceValues()
Returns the list of possible string values set earlier.
|
String |
getDescription()
Returns the provided user-visible description of the entry, if any.
|
int |
getIntValue()
Returns the value of the entry as an integer when the type is
TYPE_INTEGER . |
String |
getKey()
This is the unique key for the restriction entry.
|
RestrictionEntry[] |
getRestrictions()
Returns array of possible restriction entries that this entry may contain.
|
boolean |
getSelectedState()
Returns the current selected state for an entry of type
TYPE_BOOLEAN . |
String |
getSelectedString()
Returns the currently selected string value.
|
String |
getTitle()
Returns the user-visible title for the entry, if any.
|
int |
getType()
Returns the type for this restriction.
|
int |
hashCode()
Returns a hash code value for the object.
|
void |
setAllSelectedStrings(String[] allSelectedStrings)
Sets the current list of selected values for an entry of type
TYPE_MULTI_SELECT . |
void |
setChoiceEntries(Context context,
int stringArrayResId)
Sets a list of strings that will be presented as choices to the user.
|
void |
setChoiceEntries(String[] choiceEntries)
Sets a list of strings that will be presented as choices to the user.
|
void |
setChoiceValues(Context context,
int stringArrayResId)
Sets a list of string values that can be selected by the user, similar to
setChoiceValues(String[]) . |
void |
setChoiceValues(String[] choiceValues)
Sets a list of string values that can be selected by the user.
|
void |
setDescription(String description)
Sets the user-visible description of the entry, as a possible sub-text for the title.
|
void |
setIntValue(int value)
Sets the integer value of the entry when the type is
TYPE_INTEGER . |
void |
setRestrictions(RestrictionEntry[] restrictions)
Sets an array of possible restriction entries, that this entry may contain.
|
void |
setSelectedState(boolean state)
Sets the current selected state for an entry of type
TYPE_BOOLEAN . |
void |
setSelectedString(String selectedString)
Sets the string value to use as the selected value for this restriction.
|
void |
setTitle(String title)
Sets the user-visible title for the entry.
|
void |
setType(int type)
Sets the type for this restriction.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final int TYPE_NULL
public static final int TYPE_BOOLEAN
public static final int TYPE_CHOICE
setChoiceEntries(String[])
and
setChoiceValues(String[])
to set the localized list entries to present to the user
and the corresponding values, respectively.public static final int TYPE_CHOICE_LEVEL
setChoiceEntries(String[])
and
setChoiceValues(String[])
to set the localized list entries to present to the user
and the corresponding values, respectively.
The presentation could imply that values in lower array indices are included when a
particular value is chosen.public static final int TYPE_MULTI_SELECT
setChoiceEntries(String[])
and
setChoiceValues(String[])
to set the localized list entries to present to the user
and the corresponding values, respectively.
Use getAllSelectedStrings()
and setAllSelectedStrings(String[])
to
manipulate the selections.public static final int TYPE_INTEGER
Integer.MIN_VALUE
to Integer.MAX_VALUE
.public static final int TYPE_STRING
public static final int TYPE_BUNDLE
bundles
of
restrictionspublic static final int TYPE_BUNDLE_ARRAY
bundles
of restrictionspublic static final Parcelable.Creator<RestrictionEntry> CREATOR
public RestrictionEntry(int type, String key)
type
- the restriction type.key
- the unique key for this restrictionpublic RestrictionEntry(String key, String selectedString)
TYPE_CHOICE
type.key
- the unique key for this restrictionselectedString
- the current valuepublic RestrictionEntry(String key, boolean selectedState)
TYPE_BOOLEAN
type.key
- the unique key for this restrictionselectedState
- whether this restriction is selected or notpublic RestrictionEntry(String key, String[] selectedStrings)
TYPE_MULTI_SELECT
type.key
- the unique key for this restrictionselectedStrings
- the list of values that are currently selectedpublic RestrictionEntry(String key, int selectedInt)
TYPE_INTEGER
type.key
- the unique key for this restrictionselectedInt
- the integer value of the restrictionpublic RestrictionEntry(Parcel in)
public static RestrictionEntry createBundleEntry(String key, RestrictionEntry[] restrictionEntries)
TYPE_BUNDLE
.key
- the unique key for this restrictionrestrictionEntries
- array of nested restriction entries.public static RestrictionEntry createBundleArrayEntry(String key, RestrictionEntry[] restrictionEntries)
TYPE_BUNDLE_ARRAY
.key
- the unique key for this restrictionrestrictionEntries
- array of nested restriction entries. The array may only contain
elements of type bundle
.public void setType(int type)
type
- the type for this restriction.public int getType()
public String getSelectedString()
public String[] getAllSelectedStrings()
TYPE_MULTI_SELECT
,
null otherwise.public boolean getSelectedState()
TYPE_BOOLEAN
.public int getIntValue()
TYPE_INTEGER
.public void setIntValue(int value)
TYPE_INTEGER
.value
- the integer value to set.public void setSelectedString(String selectedString)
selectedString
- the string value to select.public void setSelectedState(boolean state)
TYPE_BOOLEAN
. This value will
be persisted by the system for later use by the application.state
- the current selected statepublic void setAllSelectedStrings(String[] allSelectedStrings)
TYPE_MULTI_SELECT
.
These values will be persisted by the system for later use by the application.allSelectedStrings
- the current list of selected values.public void setChoiceValues(String[] choiceValues)
setChoiceEntries(String[])
, these values will be the ones
shown to the user. Values will be chosen from this list as the user's selection and the
selected values can be retrieved by a call to getAllSelectedStrings()
, or
getSelectedString()
, depending on whether it is a multi-select type or choice type.
This method is not relevant for types other than
TYPE_CHOICE
, and TYPE_MULTI_SELECT
.choiceValues
- an array of Strings which will be the selected values for the user's
selections.getChoiceValues()
,
getAllSelectedStrings()
public void setChoiceValues(Context context, @ArrayRes int stringArrayResId)
setChoiceValues(String[])
.context
- the application context for retrieving the resources.stringArrayResId
- the resource id for a string array containing the possible values.setChoiceValues(String[])
public RestrictionEntry[] getRestrictions()
public void setRestrictions(RestrictionEntry[] restrictions)
This method is only relevant for types TYPE_BUNDLE
and
TYPE_BUNDLE_ARRAY
public String[] getChoiceValues()
public void setChoiceEntries(String[] choiceEntries)
setChoiceValues(String[])
. This method is not relevant for types other
than TYPE_CHOICE
, and TYPE_MULTI_SELECT
.choiceEntries
- the list of user-visible choices.setChoiceValues(String[])
public void setChoiceEntries(Context context, @ArrayRes int stringArrayResId)
setChoiceEntries(String[])
.context
- the application context, used for retrieving the resources.stringArrayResId
- the resource id of a string array containing the possible entries.public String[] getChoiceEntries()
public String getDescription()
public void setDescription(String description)
description
- the user-visible description string.public String getKey()
public String getTitle()
public void setTitle(String title)
title
- the user-visible title for the entry.public boolean equals(Object o)
Object
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.
equals
in class Object
o
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public int hashCode()
Object
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.
Object.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
JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public String toString()
Object
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())