Most visited

Recently visited

Added in API level 5

ParcelUuid

public final class ParcelUuid
extends Object implements Parcelable

java.lang.Object
   ↳ android.os.ParcelUuid


这个类是一个围绕 UUID包装器,它是一个128位通用唯一标识符的不可变表示。

Summary

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<ParcelUuid> CREATOR

Public constructors

ParcelUuid(UUID uuid)

构造函数从给定的 UUID创建一个ParcelUuid实例。

Public methods

int describeContents()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。

boolean equals(Object object)

将此ParcelUuid与另一个对象进行比较以求相等。

static ParcelUuid fromString(String uuid)

UUID的字符串表示形式创建一个新的 UUID

UUID getUuid()

获取由 UUID表示的UUID

int hashCode()

返回对象的哈希码值。

String toString()

返回ParcelUuid的字符串表示例如:0000110B-0000-1000-8000-00805F9B34FB将作为返回值。

void writeToParcel(Parcel dest, int flags)

将此对象平铺到一个包裹中。

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

CREATOR

Added in API level 5
Creator<ParcelUuid> CREATOR

Public constructors

ParcelUuid

Added in API level 5
ParcelUuid (UUID uuid)

构造函数从给定的 UUID创建一个ParcelUuid实例。

Parameters
uuid UUID: UUID

Public methods

describeContents

Added in API level 5
int describeContents ()

描述此Parcelable实例的封送表示中包含的特殊对象的种类。 例如,如果对象将在writeToParcel(Parcel, int)的输出中包含writeToParcel(Parcel, int) ,则此方法的返回值必须包含CONTENTS_FILE_DESCRIPTOR位。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

equals

Added in API level 5
boolean equals (Object object)

将此ParcelUuid与另一个对象进行比较以求相等。 如果object不是null ,是ParcelUuid实例,并且所有位均相等,则返回true

Parameters
object Object: the Object to compare to.
Returns
boolean true if this ParcelUuid is equal to object or false if not.

fromString

Added in API level 5
ParcelUuid fromString (String uuid)

UUID的字符串表示形式创建一个新的 UUID

Parameters
uuid String: the UUID string to parse.
Returns
ParcelUuid a ParcelUuid instance.
Throws
NullPointerException if uuid is null.
IllegalArgumentException if uuid is not formatted correctly.

getUuid

Added in API level 5
UUID getUuid ()

获取由 UUID表示的UUID

Returns
UUID UUID contained in the ParcelUuid.

hashCode

Added in API level 5
int hashCode ()

返回对象的哈希码值。 为了散列表的好处而支持此方法,例如由HashMap提供的HashMap

hashCode的总合同是:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the 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.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the 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.

尽可能合理实用,类Object定义的hashCode方法确实为不同的对象返回不同的整数。 (这通常通过将对象的内部地址转换为整数来实现,但Java TM编程语言不需要此实现技术。)

Returns
int a hash code value for this object.

toString

Added in API level 5
String toString ()

返回ParcelUuid的字符串表示例如:0000110B-0000-1000-8000-00805F9B34FB将作为返回值。

Returns
String a String instance.

writeToParcel

Added in API level 5
void writeToParcel (Parcel dest, 
                int flags)

将此对象平铺到一个包裹中。

Parameters
dest Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Hooray!