MessageParcelpublic class Parcel extends Object
During IPC, the sender can use the write methods provided by Parcel to
write the to-be-sent data into a Parcel object in a specific format, and the receiver can use the
read methods provided by Parcel to read data of the specific format from the Parcel object.
The default capacity of a Parcel instance is 200KB. If you want more or less, use setCapacity(int)
to change it.
Parcel: byte,
byteArray, short, shortArray, int, intArray, long, longArray, float, floatArray, double, doubleArray, boolean,
booleanArray, char, charArray, String, StringArray, PlainBooleanArray, Serializable,
Sequenceable, and SequenceableArray.| 限定符 | 构造器 | 说明 |
|---|---|---|
protected |
Parcel() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addAppClassLoader(ClassLoader newClassLoader) |
Adds a third-party
ClassLoader for instance initialization. |
boolean |
appendFrom(Parcel other) |
Appends the serialized value of a specified
Parcel object to this Parcel instance. |
static Parcel |
create() |
Creates an empty
Parcel instance. |
static Parcel |
create(long nativeHandler) |
Creates an empty
Parcel instance with a specified handler. |
<T extends Sequenceable> |
createSequenceable() |
Creates a specific
Sequenceable object from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel). |
<T extends Sequenceable> |
createSequenceable(ClassLoader classLoader) |
Creates a specific
Sequenceable object from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel). |
Sequenceable[] |
createSequenceableArray() |
Creates a specific
Sequenceable object array from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel) |
protected void |
finalize() |
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
protected void |
flushBuffer() |
Clears data in the
Parcel instance. |
byte[] |
getBytes() |
Reads all bytes from the
Parcel instance. |
int |
getCapacity() |
Obtains the storage capacity (in bytes) of the
Parcel instance. |
int |
getReadableBytes() |
Obtains the readable data space (in bytes) in the
Parcel instance. |
int |
getReadPosition() |
Obtains the current read position in the
Parcel instance. |
int |
getSize() |
Obtains the size of data (in bytes) contained in the
Parcel instance. |
int |
getWritableBytes() |
Obtains the writable data space (in bytes) in the
Parcel instance. |
int |
getWritePosition() |
Obtains the current write position in the
Parcel instance. |
boolean |
readBoolean() |
Reads a boolean value from the
Parcel instance. |
boolean[] |
readBooleanArray() |
Reads a boolean array from the
Parcel instance. |
void |
readBooleanArray(boolean[] val) |
Reads a boolean array from the
Parcel instance. |
byte |
readByte() |
Reads a byte value from the
Parcel instance. |
byte[] |
readByteArray() |
Reads a byte array from the
Parcel instance. |
void |
readByteArray(byte[] val) |
Reads a byte array from the
Parcel instance. |
char |
readChar() |
Reads a single character value from the
Parcel instance. |
char[] |
readCharArray() |
Reads a single character array from the
Parcel instance. |
void |
readCharArray(char[] val) |
Reads a single character array from the
Parcel instance. |
double |
readDouble() |
Reads a double-precision floating point value from the
Parcel instance. |
double[] |
readDoubleArray() |
Reads a double-precision floating point array from the
Parcel instance. |
void |
readDoubleArray(double[] val) |
Reads a double-precision floating point array from the
Parcel instance. |
float |
readFloat() |
Reads a floating point value from the
Parcel instance. |
float[] |
readFloatArray() |
Reads a floating point array from the
Parcel instance. |
void |
readFloatArray(float[] val) |
Reads a floating point array from the
Parcel instance. |
int |
readInt() |
Reads an integer value from the
Parcel instance. |
int[] |
readIntArray() |
Reads an integer array from the
Parcel instance. |
void |
readIntArray(int[] val) |
Reads an integer array from the
Parcel instance. |
List<?> |
readList() |
Reads a list of objects from this
Parcel instance. |
long |
readLong() |
Reads a long integer value from the
Parcel instance. |
long[] |
readLongArray() |
Reads a long integer array from the
Parcel instance. |
void |
readLongArray(long[] val) |
Reads a long integer array from the
Parcel instance. |
Map<?,?> |
readMap() |
Reads a
Map object from this Parcel instance. |
void |
readPacMapEx(PacMapEx pacMapEx) |
Reads a
PacMapEx object from this Parcel object. |
ParcelableEx |
readParcelableEx(ClassLoader loader) |
Reads a
ParcelableEx object from this Parcel instance. |
<T> PlainArray<T> |
readPlainArray(Class<T> clzType) |
Reads a
PlainArray object from this Parcel instance. |
PlainBooleanArray |
readPlainBooleanArray() |
Reads a
PlainBooleanArray object from this Parcel instance. |
boolean |
readSequenceable(Sequenceable in) |
Reads a
Sequenceable object from the Parcel instance. |
void |
readSequenceableArray(Sequenceable[] val) |
Reads a
Sequenceable object array from the Parcel instance. |
<T extends Sequenceable> |
readSequenceableList(Class<T> clz) |
Reads a list of
Sequenceable objects of a specified type from this Parcel instance. |
<T extends Sequenceable> |
readSequenceableMap(Class<T> valueType) |
Reads a
Map object from this Parcel instance. |
<T extends Serializable> |
readSerializable(Class<T> clz) |
Reads a serializable object from this
Parcel instance. |
short |
readShort() |
Reads a short integer value from the
Parcel instance. |
short[] |
readShortArray() |
Reads a short integer array from the
Parcel instance. |
void |
readShortArray(short[] val) |
Reads a short integer array from the
Parcel instance. |
String |
readString() |
Reads a string value from the
Parcel instance. |
String[] |
readStringArray() |
Reads a string array from the
Parcel instance. |
void |
readStringArray(String[] val) |
Reads a string array from the
Parcel instance. |
List<String> |
readStringList() |
Reads a string list from
Parcel. |
Object |
readValue() |
Reads an object from this
Parcel instance. |
void |
reclaim() |
Clears data in the
Parcel instance. |
boolean |
rewindRead(int pos) |
Changes the current read position in the
Parcel instance. |
boolean |
rewindWrite(int pos) |
Changes the current write position in the
Parcel instance. |
boolean |
setCapacity(int capacity) |
Sets the storage capacity (in bytes) of the
Parcel instance. |
boolean |
setSize(int size) |
Sets the size of data (in bytes) contained in the
Parcel instance. |
boolean |
writeBoolean(boolean val) |
Writes a boolean value into the
Parcel instance. |
boolean |
writeBooleanArray(boolean[] values) |
Writes a boolean array into the
Parcel instance. |
boolean |
writeByte(byte val) |
Writes a byte value into the
Parcel instance. |
boolean |
writeByteArray(byte[] val) |
Writes a byte array into the
Parcel instance. |
boolean |
writeBytes(byte[] val) |
Writes bytes into the
Parcel instance. |
boolean |
writeChar(char val) |
Writes a single character value into the
Parcel instance. |
boolean |
writeCharArray(char[] values) |
Writes a single character array into the
Parcel instance. |
boolean |
writeDouble(double val) |
Writes a double-precision floating point value into the
Parcel instance. |
boolean |
writeDoubleArray(double[] values) |
Writes a double-precision floating point array into the
Parcel instance. |
boolean |
writeFloat(float val) |
Writes a floating point value into the
Parcel instance. |
boolean |
writeFloatArray(float[] values) |
Writes a floating point array into the
Parcel instance. |
boolean |
writeInt(int val) |
Writes an integer value into the
Parcel instance. |
boolean |
writeIntArray(int[] values) |
Writes an integer array into the
Parcel instance. |
void |
writeList(List<?> values) |
Writes a list of objects into this
Parcel instance. |
boolean |
writeLong(long val) |
Writes a long integer value into the
Parcel instance. |
boolean |
writeLongArray(long[] values) |
Writes a long integer array into the
Parcel instance. |
void |
writeMap(Map<?,?> values) |
Writes a
Map object into this Parcel instance. |
void |
writeMap(Map<?,?> values,
boolean isCross) |
Writes a
Map object into this Parcel instance by supporting cross platform. |
void |
writePacMapEx(PacMapEx val) |
Writes a
PacMapEx object into this Parcel instance. |
void |
writeParcelableEx(ParcelableEx val) |
Writes a
ParcelableEx object into this Parcel instance. |
<T> void |
writePlainArray(PlainArray<T> value) |
Writes a
PlainArray object into this Parcel instance. |
boolean |
writePlainBooleanArray(PlainBooleanArray value) |
Writes a
PlainBooleanArray object into this Parcel instance. |
void |
writeSequenceable(Sequenceable val) |
Writes a
Sequenceable object into the Parcel instance. |
boolean |
writeSequenceableArray(Sequenceable[] values) |
Writes a
Sequenceable object array into the Parcel instance. |
boolean |
writeSequenceableList(List<? extends Sequenceable> values) |
Writes a
Sequenceable list into this Parcel instance. |
boolean |
writeSequenceableMap(Map<String,? extends Sequenceable> values) |
Writes a
Map object into this Parcel instance. |
void |
writeSerializable(Serializable object) |
Writes a serializable object into this
Parcel instance. |
boolean |
writeShort(short val) |
Writes a short integer value into the
Parcel instance. |
boolean |
writeShortArray(short[] values) |
Writes a short integer array into the
Parcel instance. |
boolean |
writeString(String val) |
Writes a string value into the
Parcel instance. |
boolean |
writeStringArray(String[] values) |
Writes a string array into the
Parcel instance. |
boolean |
writeStringList(List<String> values) |
Writes a string list into this
Parcel instance. |
void |
writeTypedSequenceable(Sequenceable sequenceable) |
Writes a
Sequenceable object into the Parcel instance by using
Sequenceable.Producer#createFromParcel(Parcel). |
<T extends Sequenceable> |
writeTypedSequenceableArray(T[] values) |
Writes a
Sequenceable object array into the Parcel instance by using
Sequenceable.Producer#createFromParcel(Parcel). |
void |
writeValue(Object value) |
Writes an object into this
Parcel instance. |
protected void flushBuffer()
Parcel instance.protected void finalize()
throws Throwable
Objectfinalize method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked
if and when the Java™ virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize method may take any action, including
making this object available again to other threads; the usual purpose
of finalize, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize method of class Object performs no
special action; it simply returns normally. Subclasses of
Object may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize 在类中 ObjectThrowable - the Exception raised by this methodWeakReference,
PhantomReferencepublic static Parcel create()
Parcel instance.Parcel instance.public static Parcel create(long nativeHandler)
Parcel instance with a specified handler.nativeHandler - Indicates the handler in native pointed to a parcel object.Parcel instance with the specified handler.public void reclaim()
Parcel instance.public final int getSize()
Parcel instance.Parcel instance.public final int getCapacity()
Parcel instance.Parcel instance.public final boolean setSize(int size)
Parcel instance.
false is returned if the data size set in this method is greater
than the storage capacity of the Parcel.
size - Indicates the data size of the Parcel instance.true if the setting is successful; returns false otherwise.public final boolean setCapacity(int capacity)
Parcel instance.
false is returned if the capacity set in this method is less than
the size of data contained in the Parcel.
capacity - Indicates the storage capacity of the Parcel instance.true if the setting is successful; returns false otherwise.public final int getWritableBytes()
Parcel instance.
Writable data space = Storage capacity of the Parcel – Size of data contained in the Parcel.
Parcel instance.public final int getReadableBytes()
Parcel instance.
Readable data space = Size of data contained in the Parcel – Size of data that has been read.
Parcel instance.public final int getReadPosition()
Parcel instance.Parcel instance.public final int getWritePosition()
Parcel instance.Parcel instance.public final boolean rewindRead(int pos)
Parcel instance.
Generally, you are advised not to change the current read position. If you must change it, change it to an accurate position. Otherwise, the read data may be incorrect.
pos - Indicates the target position to start data reading.true if the read position is changed; returns false otherwise.public final boolean rewindWrite(int pos)
Parcel instance.
Generally, you are advised not to change the current write position. If you must change it, change it to an accurate position. Otherwise, the data to be read may be incorrect.
pos - Indicates the target position to start data writing.true if the write position is changed; returns false otherwise.public final boolean writeByte(byte val)
Parcel instance.val - Indicates the byte value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeShort(short val)
Parcel instance.val - Indicates the short integer value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeInt(int val)
Parcel instance.val - Indicates the integer value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeLong(long val)
Parcel instance.val - Indicates the long integer value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeFloat(float val)
Parcel instance.val - Indicates the floating point value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeDouble(double val)
Parcel instance.val - Indicates the double-precision floating point value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeBoolean(boolean val)
Parcel instance.val - Indicates the boolean value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeChar(char val)
Parcel instance.val - Indicates the single character value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeString(String val)
Parcel instance.val - Indicates the string value to write.true if the value has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final void writeSequenceable(Sequenceable val)
Sequenceable object into the Parcel instance.val - Indicates the Sequenceable object to write.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final byte readByte()
Parcel instance.public final short readShort()
Parcel instance.public final int readInt()
Parcel instance.public final long readLong()
Parcel instance.public final float readFloat()
Parcel instance.public final double readDouble()
Parcel instance.public final boolean readBoolean()
Parcel instance.public final char readChar()
Parcel instance.public final String readString()
Parcel instance.public final boolean readSequenceable(Sequenceable in)
Sequenceable object from the Parcel instance.in - Indicates the Sequenceable object that needs to perform the unmarshalling operation
using the Parcel.true if the unmarshalling is successful; returns false otherwise.public final boolean writeByteArray(byte[] val)
Parcel instance.val - Indicates the byte array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeBytes(byte[] val)
Parcel instance.
This method is different from the writeByteArray method. In this method, the
Parcel cannot call other methods to write data, and the written data can be read
only by calling getBytes().
val - Indicates the bytes to write.true if the bytes have been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeShortArray(short[] values)
Parcel instance.values - Indicates the short integer array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeIntArray(int[] values)
Parcel instance.values - Indicates the integer array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeLongArray(long[] values)
Parcel instance.values - Indicates the long integer array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeFloatArray(float[] values)
Parcel instance.values - Indicates the floating point array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeDoubleArray(double[] values)
Parcel instance.values - Indicates the double-precision floating point array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeBooleanArray(boolean[] values)
Parcel instance.values - Indicates the boolean array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeCharArray(char[] values)
Parcel instance.values - Indicates the single character array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeStringArray(String[] values)
Parcel instance.values - Indicates the string array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeStringList(List<String> values)
Parcel instance.values - Indicates the string list to write.true if the string list is successfully written;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeSequenceableArray(Sequenceable[] values)
Sequenceable object array into the Parcel instance.values - Indicates the Sequenceable object array to write.true if the array has been written into the Parcel;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writeSequenceableList(List<? extends Sequenceable> values)
Sequenceable list into this Parcel instance.
The type of elements in this list must be something that implements Sequenceable. When you call the
readSequenceableList(java.lang.Class) method to read the list, ensure that the elements of values are of
the
same type.
values - Indicates the Sequenceable list to write.true if the Sequenceable list is successfully written;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.readSequenceableList(Class)public final boolean writeSequenceableMap(Map<String,? extends Sequenceable> values)
Map object into this Parcel instance.
In the Map object, keys are of the String type and values are from something that implements
Sequenceable. When you call the readSequenceableMap(java.lang.Class) method to read the map, ensure that
the elements of values are of the same type.
values - Indicates the Map object to write.true if the Map object is successfully written;
returns false otherwise.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.readSequenceableMap(Class)public final void readByteArray(byte[] val)
Parcel instance.val - Indicates the byte array to read.ParcelException - If read byte array failed will throw this exception.public final byte[] readByteArray()
Parcel instance.public final byte[] getBytes()
Parcel instance.
This method is different from the readByteArray method. In this method,
the Parcel cannot call other methods to read data, and this method can only
read data written by using writeBytes(byte[]).
public final void readShortArray(short[] val)
Parcel instance.val - Indicates the short integer array to read.ParcelException - Throws this exception if reading the short array fails.public final short[] readShortArray()
Parcel instance.public final void readIntArray(int[] val)
Parcel instance.val - Indicates the integer array to read.ParcelException - Throws this exception if reading the integer array fails.public final int[] readIntArray()
Parcel instance.public final void readLongArray(long[] val)
Parcel instance.val - Indicates the long integer array to read.ParcelException - Throws this exception if reading the long array fails.public final long[] readLongArray()
Parcel instance.public final void readFloatArray(float[] val)
Parcel instance.val - Indicates the floating point array to read.ParcelException - Throws this exception if reading the float array fails.public final float[] readFloatArray()
Parcel instance.public final void readDoubleArray(double[] val)
Parcel instance.val - Indicates the double-precision floating point array to read.ParcelException - Throws this exception if reading the double array fails.public final double[] readDoubleArray()
Parcel instance.public final void readBooleanArray(boolean[] val)
Parcel instance.val - Indicates the boolean array to read.ParcelException - Throws this exception if reading the boolean array fails.public final boolean[] readBooleanArray()
Parcel instance.public final void readCharArray(char[] val)
Parcel instance.val - Indicates the single character array to read.ParcelException - Throws this exception if reading the char array fails.public final char[] readCharArray()
Parcel instance.public final void readStringArray(String[] val)
Parcel instance.val - Indicates the string array to read.ParcelException - Throws this exception if reading the string array fails.public final String[] readStringArray()
Parcel instance.public final List<String> readStringList()
Parcel.
You can use this method to read the strings that are written into Parcel by
writeStringList(java.util.List) and writeStringArray(java.lang.String[]).
writeStringList(List),
writeStringArray(String[])public final void readSequenceableArray(Sequenceable[] val)
Sequenceable object array from the Parcel instance.val - Indicates the Sequenceable object array to read.ParcelException - Throws this exception if reading the sequenceable array fails.public final <T extends Sequenceable> List<T> readSequenceableList(Class<T> clz)
Sequenceable objects of a specified type from this Parcel instance.
The class that provides the Sequenceable objects must have a static member variable CREATOR of
the
Sequenceable.Producer type.
clz - Indicates the type of the Sequenceable objects to read.Sequenceable objects.ParcelException - Throws this exception if CREATOR of Sequenceable fails to be obtained.writeSequenceableArray(Sequenceable[]),
writeSequenceableList(List)public final <T extends Sequenceable> Map<String,T> readSequenceableMap(Class<T> valueType)
Map object from this Parcel instance. In the Map object, keys are of the
String type and values are from something that implements Sequenceable.valueType - Indicates the value type of the Map object to read.Map object whose keys are of the String type and values are from something that
implements Sequenceable.writeSequenceableMap(Map)public final void writeTypedSequenceable(Sequenceable sequenceable)
Sequenceable object into the Parcel instance by using
Sequenceable.Producer#createFromParcel(Parcel).
This method will also write the class name of the Sequenceable object into the Parcel. The class
name
will be used for restoring the Sequenceable object from the Parcel.
sequenceable - Indicates the Sequenceable object that has implemented
Sequenceable.Producer#createFromParcel.ParcelException - Throws this exception if an exception occurs during data writing.createSequenceable()public final <T extends Sequenceable> T createSequenceable()
Sequenceable object from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel).
This method restores Sequenceable object based on the class name written by
writeTypedSequenceable(ohos.utils.Sequenceable).
Sequenceable object; returns null if no Sequenceable
object can be restored.ParcelException - Throws this exception if an exception occurs during data reading.writeTypedSequenceable(Sequenceable)public final <T extends Sequenceable> T createSequenceable(ClassLoader classLoader)
Sequenceable object from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel).
This method restores Sequenceable object based on the class name written by
writeTypedSequenceable(ohos.utils.Sequenceable).
T - Indicates the class that extends Sequenceable.classLoader - Indicates the class loader used to load the Sequenceable class..Sequenceable object; returns null if no Sequenceable
object can be restored.public final <T extends Sequenceable> void writeTypedSequenceableArray(T[] values)
Sequenceable object array into the Parcel instance by using
Sequenceable.Producer#createFromParcel(Parcel).values - Indicates the Sequenceable object array to write.ParcelException - Throws this exception if an exception occurs during data writing.writeTypedSequenceable(Sequenceable),
createSequenceableArray()public final void writeSerializable(Serializable object)
Parcel instance.object - Indicates the serializable object to write.ParcelException - Throws this exception if object cannot be serialized or an I/O error occurs.public final <T extends Serializable> T readSerializable(Class<T> clz)
Parcel instance.clz - Indicates the type of the serializable object to read.null
if no serializable object can be read.ParcelException - Throws this exception if the type of the serializable object
to read does not match clz or an I/O error occurs.public final Sequenceable[] createSequenceableArray()
Sequenceable object array from the Parcel by using
Sequenceable.Producer#createFromParcel(Parcel)Sequenceable object array; returns null if no
Sequenceable
object array can be restored.ParcelException - Throws this exception if an exception occurs during data reading.createSequenceable(),
writeTypedSequenceableArray(Sequenceable[])public List<?> readList()
Parcel instance.ParcelException - Throws this exception if the list contains
the object types not supported by Parcel.public void writeList(List<?> values)
Parcel instance.values - Indicates the object list to write.ParcelException - Throws this exception if the list contains
the object types not supported by Parcel or capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public Map<?,?> readMap()
Map object from this Parcel instance.Map object.ParcelException - Throws this exception if the Map object
contains the key-value pair types not supported by Parcel.public void writeMap(Map<?,?> values)
Map object into this Parcel instance.
The types of key-value pairs in the Map object must be supported by Parcel.
Otherwise, an exception will be thrown.
values - Indicates the Map object to write.ParcelException - Throws this exception if the Map object
contains the key-value pair types not supported by ParcelParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final void writeMap(Map<?,?> values, boolean isCross)
Map object into this Parcel instance by supporting cross platform.
The types of key-value pairs in the Map object must be supported by Parcel.
Otherwise, an exception will be thrown.
values - Indicates the Map object to write.isCross - Indicates the flag of cross platform.ParcelException - Throws this exception if the Map object
contains the key-value pair types not supported by ParcelParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final void writeValue(Object value)
Parcel instance.
This is a general-purpose method for writing an object with no need to declare its type. Note the following:
Parcel.readValue() to read the object that has been written.value - Indicates the object to write.ParcelException - Throws this exception if the object type is not supported by ParcelParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.readValue()public final Object readValue()
Parcel instance.
This method can only read the object written by writeValue(java.lang.Object).
ParcelException - Throws this exception if the object type is not supported by Parcel.writeValue(Object)public final boolean appendFrom(Parcel other)
Parcel object to this Parcel instance.other - Indicates the Parcel object to append.NullPointerException - Throws this exception if other is null.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final boolean writePlainBooleanArray(PlainBooleanArray value)
PlainBooleanArray object into this Parcel instance.value - Indicates the PlainBooleanArray object to write.true if the PlainBooleanArray object is successfully written; returns
false otherwise.NullPointerException - Throws this exception if value is null.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.readPlainBooleanArray()public final PlainBooleanArray readPlainBooleanArray()
PlainBooleanArray object from this Parcel instance.PlainBooleanArray object.writePlainBooleanArray(PlainBooleanArray)public final <T> void writePlainArray(PlainArray<T> value)
PlainArray object into this Parcel instance.T - Indicates the type of the value stored in a PlainArray object.value - Indicates the PlainArray object to write.NullPointerException - Throws this exception if value is null.ParcelException - Throws this exception if the list contains the object types not supported by
Parcel.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.readPlainArray(Class)public final <T> PlainArray<T> readPlainArray(Class<T> clzType)
PlainArray object from this Parcel instance.T - Indicates the type of the value stored in a PlainArray object.PlainArray object.ParcelException - Throws this exception if the list contains the object types not supported by
Parcel.writePlainArray(PlainArray)public final void writeParcelableEx(ParcelableEx val)
ParcelableEx object into this Parcel instance.val - Indicates the ParcelableEx object to write.ParcelException - if the marshallingEx operation fails.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final void writePacMapEx(PacMapEx val)
PacMapEx object into this Parcel instance.val - Indicates the PacMapEx object to write.ParcelException - if marshalling operation failed.ParcelException - When capacity in this parcel is insufficient,
exception message: ParcelException#NO_CAPACITY_ERROR.public final void readPacMapEx(PacMapEx pacMapEx)
PacMapEx object from this Parcel object.pacMapEx - Indicates the PacMapEx object into which the read data will be unmarshalled.ParcelException - if the unmarshalling operation failed.public final ParcelableEx readParcelableEx(ClassLoader loader)
ParcelableEx object from this Parcel instance.
If the Parcel instance does not contain the class name or
the class name cannot be used to call the no-argument constructor for creating
a ParcelableEx object, the read operation fails.
loader - ClassLoader used for create custom class object if needed.ParcelableEx object if the operation is successful;
returns null otherwise.ParcelException - if the unmarshalling operation failed.public void addAppClassLoader(ClassLoader newClassLoader)
ClassLoader for instance initialization.
If you need to marshal or unmarshal a custom Sequenceable instance, add your own ClassLoader.
newClassLoader - Indicates the ClassLoader used to initialize the Sequenceable instance of
your application..