Package org.osgi.service.event
Class Event
java.lang.Object
org.osgi.service.event.Event
- Direct Known Subclasses:
FunctionEvent
An event.
Event
objects are delivered to EventHandler
services which
subscribe to the topic of the event.- "Immutable"
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
containsProperty
(String name) Indicate the presence of an event property.boolean
Compares thisEvent
object to another object.final Object
getProperty
(String name) Retrieve the value of an event property.final String[]
Returns a list of this event's property names.final String
getTopic()
Returns the topic of this event.int
hashCode()
Returns a hash code value for this object.final boolean
Tests this event's properties against the given filter using a case sensitive match.toString()
Returns the string representation of this event.
-
Constructor Details
-
Event
Constructs an event.- Parameters:
topic
- The topic of the event.properties
- The event's properties (may benull
). A property whose key is not of typeString
will be ignored. If the specified properties is anEventProperties
object, then it will be directly used. Otherwise, a copy of the specified properties is made.- Throws:
IllegalArgumentException
- If topic is not a valid topic name.- Since:
- 1.2
-
Event
Constructs an event.- Parameters:
topic
- The topic of the event.properties
- The event's properties (may benull
). A property whose key is not of typeString
will be ignored. A copy of the specified properties is made.- Throws:
IllegalArgumentException
- If topic is not a valid topic name.
-
-
Method Details
-
getProperty
Retrieve the value of an event property. The event topic may be retrieved with the property name "event.topics".- Parameters:
name
- The name of the property to retrieve.- Returns:
- The value of the property, or
null
if not found.
-
containsProperty
Indicate the presence of an event property. The event topic is present using the property name "event.topics".- Parameters:
name
- The name of the property.- Returns:
true
if a property with the specified name is in the event. This property may have anull
value.false
otherwise.- Since:
- 1.3
-
getPropertyNames
Returns a list of this event's property names. The list will include the event topic property name "event.topics".- Returns:
- A non-empty array with one element per property.
-
getTopic
Returns the topic of this event.- Returns:
- The topic of this event.
-
matches
Tests this event's properties against the given filter using a case sensitive match.- Parameters:
filter
- The filter to test.- Returns:
- true If this event's properties match the filter, false otherwise.
-
equals
Compares thisEvent
object to another object.An event is considered to be equal to another event if the topic is equal and the properties are equal. The properties are compared using the
java.util.Map.equals()
rules which includes identity comparison for array values. -
hashCode
public int hashCode()Returns a hash code value for this object. -
toString
Returns the string representation of this event.
-