public class Event
extends java.lang.Object
Event
objects are delivered to EventHandler
services which subscribe to the topic of the event.Modifier and Type | Class and Description |
---|---|
private static class |
Event.UnmodifiableDictionary
Unmodifiable wrapper for Dictionary.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map |
properties
The properties carried by this event.
|
private java.lang.String |
topic
The topic of this event.
|
Constructor and Description |
---|
Event(java.lang.String topic,
java.util.Dictionary properties)
Constructs an event.
|
Event(java.lang.String topic,
java.util.Map properties)
Constructs an event.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object)
Compares this
Event object to another object. |
java.lang.Object |
getProperty(java.lang.String name)
Retrieves a property.
|
java.lang.String[] |
getPropertyNames()
Returns a list of this event's property names.
|
java.lang.String |
getTopic()
Returns the topic of this event.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
matches(org.osgi.framework.Filter filter)
Tests this event's properties against the given filter using a case
sensitive match.
|
java.lang.String |
toString()
Returns the string representation of this event.
|
private static void |
validateTopicName(java.lang.String topic)
Called by the constructor to validate the topic name.
|
private final java.lang.String topic
private final java.util.Map properties
public Event(java.lang.String topic, java.util.Map properties)
topic
- The topic of the event.properties
- The event's properties (may be null
). A
property whose key is not of type String
will be
ignored.java.lang.IllegalArgumentException
- If topic is not a valid topic name.public Event(java.lang.String topic, java.util.Dictionary properties)
topic
- The topic of the event.properties
- The event's properties (may be null
). A
property whose key is not of type String
will be
ignored.java.lang.IllegalArgumentException
- If topic is not a valid topic name.public final java.lang.Object getProperty(java.lang.String name)
name
- the name of the property to retrievenull
if not found.public final java.lang.String[] getPropertyNames()
public final java.lang.String getTopic()
public final boolean matches(org.osgi.framework.Filter filter)
filter
- The filter to test.public boolean equals(java.lang.Object object)
Event
object to another object.
An event is considered to be equal to another event if the topic is equal and the properties are equal.
equals
in class java.lang.Object
object
- The Event
object to be compared.true
if object
is a Event
and is equal to this object; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
private static void validateTopicName(java.lang.String topic)
topic
- The topic name to validate.java.lang.IllegalArgumentException
- If the topic name is invalid.