Sequenceablepublic final class CommonEventPublishInfo extends Object implements Sequenceable
If you call the CommonEventManager#publishCommonEvent(CommonEventData, CommonEventPublishInfo) or
CommonEventManager#publishCommonEvent(CommonEventData, CommonEventPublishInfo, CommonEventSubscriber)
method to publish a common event, you can publish the common event only to related subscribers by setting
the filter criteria, including the user ID and permissions.
If you call the setOrdered(boolean) method with a value of true, an ordered common event
will be published. If you call the setSticky(boolean) method with a value of true, a sticky common event
will be published. If you call either of the two methods with a value of false, a standard common event
will be published by default. You can allow only specified subscribers to receive a common event by calling
the setSubscriberPermissions(java.lang.String[]) method.
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static Sequenceable.Producer<CommonEventPublishInfo> |
PRODUCER |
Creates a
CommonEventPublishInfo instance from a Parcel. |
| 构造器 | 说明 |
|---|---|
CommonEventPublishInfo() |
Default constructor used to create an empty
CommonEventPublishInfo instance. |
CommonEventPublishInfo(CommonEventPublishInfo publishInfo) |
A constructor used to create a
CommonEventPublishInfo instance by copying parameters
from an existing one. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String[] |
getSubscriberPermissions() |
Obtains subscriber permissions to a common event, which can be set by
setSubscriberPermissions(java.lang.String[]). |
boolean |
isOrdered() |
Obtains whether it is an ordered common event, which can be set by
setOrdered(boolean). |
boolean |
isSticky() |
Obtains whether it is a sticky common event, which can be set by
setSticky(boolean). |
boolean |
marshalling(Parcel out) |
Marshals a
CommonEventPublishInfo object into a Parcel. |
void |
setOrdered(boolean ordered) |
Sets whether the type of a common event is ordered or not.
|
void |
setSticky(boolean sticky) |
Sets whether the type of a common event is sticky or not.
|
void |
setSubscriberPermissions(String[] subscriberPermissions) |
Sets permissions for subscribers.
|
String |
toString() |
Returns a string representation of the object.
|
boolean |
unmarshalling(Parcel in) |
Unmarshals a
CommonEventPublishInfo object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic static final Sequenceable.Producer<CommonEventPublishInfo> PRODUCER
CommonEventPublishInfo instance from a Parcel.public CommonEventPublishInfo()
CommonEventPublishInfo instance.public CommonEventPublishInfo(CommonEventPublishInfo publishInfo)
CommonEventPublishInfo instance by copying parameters
from an existing one.publishInfo - Indicates the CommonEventPublishInfo object.public void setSticky(boolean sticky)
A sticky common event can be received by subscribers immediately after subscription. You are advised not to set a common event to be sticky.
sticky - Specifies whether the common event is sticky. The value true indicates
sticky and the value false indicates standard.public boolean isSticky()
setSticky(boolean).true if the common event is sticky; returns false otherwise.public void setOrdered(boolean ordered)
An ordered common event is received by subscribers in descending priority. Specifically, a highest-priority subscriber receives the event, then high-priority subscribers, and finally low-priority subscribers. priority limit -1000~1000 and the highest priority is 1000.
ordered - Specifies whether the common event is ordered.
The value true indicates ordered and the value false indicates standard.public boolean isOrdered()
setOrdered(boolean).true if the common event is ordered; returns false otherwise.public void setSubscriberPermissions(String[] subscriberPermissions)
Currently, only one permission can be set for subscribers. If multiple permissions are specified
in subscriberPermissions, only the first one takes effect.
subscriberPermissions - Indicates the permissions to be set. This parameter is optional. If it is
specified, the value must be permissions that have been defined in the system.public String[] getSubscriberPermissions()
setSubscriberPermissions(java.lang.String[]).public boolean marshalling(Parcel out)
CommonEventPublishInfo object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal
a CommonEventPublishInfo object from a Parcel to implement
inter-process communication (IPC).
marshalling 在接口中 Sequenceableout - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
CommonEventPublishInfo object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.public String toString()
ObjecttoString 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())