ParcelableEx, Sequenceablepublic class PacMapEx extends Object implements ParcelableEx, Sequenceable
PacMapEx object. This object will be marshalled and
then transmitted to a process in another platform. After receiving the marshalled object, that process will unmarshal
it and then read the data.Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
protected HashMap<String,Object> |
dataMap |
Indicates the
Hashmap used to store key-value pairs in PacMapEx. |
| 构造器 | 说明 |
|---|---|
PacMapEx() |
Default constructor used to create a
PacMapEx instance, in which the HashMap object has no
key-value pair. |
PacMapEx(int capacity) |
A constructor used to create a
PacMapEx instance with the number of key-value pairs specified by
HashMap. |
PacMapEx(PacMapEx outMap,
boolean isDeepCopy) |
Construct a PacMapEx object from another PacMapEx, which can make a deep copy if the second parameter is true.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
ClassLoader |
getCustomClassLoader() |
Obtains the
ClassLoader used by the custom object within this PacMap instance. |
Optional<Object> |
getObjectValue(String key) |
Obtains an object with a specified key.
|
boolean |
hasFileDescriptor() |
Checks whether the implementation class of this
Sequenceable contains FileDescriptor object data. |
boolean |
marshalling(Parcel out) |
Marshals this
Sequenceable object into a Parcel. |
void |
marshallingEx(Parcel out) |
Writes a
ParcelableEx object into a Parcel. |
void |
putAll(Map<String,Object> map) |
Adds all key-value pairs of a specified
Map object into this PacMapEx. |
void |
putObjectValue(String key,
Object value) |
Adds a universal object with a specified key.
|
void |
setCustomClassLoader(ClassLoader loader) |
Sets the
ClassLoader used to create an custom object within this PacMap instance. |
int |
size() |
Obtains the number of key-value pairs stored in this
PacMapEx. |
boolean |
unmarshalling(Parcel in) |
Unmarshals this
Sequenceable object from a Parcel. |
void |
unmarshallingEx(Parcel in) |
Unmarshalls this
ParcelableEx object from a Parcel. |
public PacMapEx(int capacity)
PacMapEx instance with the number of key-value pairs specified by
HashMap.capacity - Indicates the number of key-value pairs specified by HashMap.public PacMapEx()
PacMapEx instance, in which the HashMap object has no
key-value pair.public PacMapEx(PacMapEx outMap, boolean isDeepCopy)
Note: deep copy only support primitive Data types, Object, and array of them, and also an inner PacMapEx.
If the PacMapEx has a map inner, the map will not be deep copied.
even if the isDeepCopy is true.
outMap - Indicates the PacMapEx to be copied.isDeepCopy - Indicates whether to do a deep copy. if set true, will do a deep copy.public void setCustomClassLoader(ClassLoader loader)
ClassLoader used to create an custom object within this PacMap instance.loader - Indicates the ClassLoader to set.getCustomClassLoader()public ClassLoader getCustomClassLoader()
ClassLoader used by the custom object within this PacMap instance.ClassLoader used by the custom object of this PacMap instance.setCustomClassLoader(ClassLoader loader)public int size()
PacMapEx.PacMapEx.public void putAll(Map<String,Object> map)
Map object into this PacMapEx.map - Indicates the Map object whose keys are in String format.public void putObjectValue(String key, Object value)
key - Indicates the key in String format, which can be null.value - Indicates the object to be added.public Optional<Object> getObjectValue(String key)
key - Indicates the key in String format, which can be null.Optional; returns
null if no such object is found.public void marshallingEx(Parcel out)
ParcelableExParcelableEx object into a Parcel.marshallingEx 在接口中 ParcelableExout - Indicates the Parcel object to which the ParcelableEx object will be written.public void unmarshallingEx(Parcel in)
ParcelableExParcelableEx object from a Parcel.
To achieve successful data unmarshalling,
you must provide a no-argument constructor for the class that inherits the ParcelableEx
interface and write the class name to Parcel in the ParcelableEx.marshallingEx(ohos.utils.Parcel) method.
unmarshallingEx 在接口中 ParcelableExin - Indicates the Parcel object from which the ParcelableEx object will be unmarshaled.public boolean marshalling(Parcel out)
SequenceableSequenceable object into a Parcel.marshalling 在接口中 Sequenceableout - Indicates the Parcel object to which the Sequenceable
object will be marshaled..true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
SequenceableSequenceable object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object into which the Sequenceable
object has been marshaled.true if the unmarshalling is successful; returns false otherwise.public boolean hasFileDescriptor()
SequenceableSequenceable contains FileDescriptor object data.
If the custom Sequenceable class contains any FileDescriptor data, you should override this
method.
This method return false by default.
hasFileDescriptor 在接口中 Sequenceabletrue if it contains FileDescriptor data; returns false otherwise.