Package org.osgi.service.event
Class Event
- java.lang.Object
-
- org.osgi.service.event.Event
-
public class Event extends java.lang.ObjectAn event.Eventobjects are delivered toEventHandlerservices which subscribe to the topic of the event.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsProperty(java.lang.String name)Indicate the presence of an event property.booleanequals(java.lang.Object object)Compares thisEventobject to another object.java.lang.ObjectgetProperty(java.lang.String name)Retrieve the value of an event property.java.lang.String[]getPropertyNames()Returns a list of this event's property names.java.lang.StringgetTopic()Returns the topic of this event.inthashCode()Returns a hash code value for this object.booleanmatches(org.osgi.framework.Filter filter)Tests this event's properties against the given filter using a case sensitive match.java.lang.StringtoString()Returns the string representation of this event.
-
-
-
Constructor Detail
-
Event
public Event(java.lang.String topic, java.util.Map<java.lang.String,?> properties)Constructs an event.- Parameters:
topic- The topic of the event.properties- The event's properties (may benull). A property whose key is not of typeStringwill be ignored. If the specified properties is anEventPropertiesobject, then it will be directly used. Otherwise, a copy of the specified properties is made.- Throws:
java.lang.IllegalArgumentException- If topic is not a valid topic name.- Since:
- 1.2
-
Event
public Event(java.lang.String topic, java.util.Dictionary<java.lang.String,?> properties)Constructs an event.- Parameters:
topic- The topic of the event.properties- The event's properties (may benull). A property whose key is not of typeStringwill be ignored. A copy of the specified properties is made.- Throws:
java.lang.IllegalArgumentException- If topic is not a valid topic name.
-
-
Method Detail
-
getProperty
public final java.lang.Object getProperty(java.lang.String name)
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
nullif not found.
-
containsProperty
public final boolean containsProperty(java.lang.String name)
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:
trueif a property with the specified name is in the event. This property may have anullvalue.falseotherwise.- Since:
- 1.3
-
getPropertyNames
public final java.lang.String[] 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
public final java.lang.String getTopic()
Returns the topic of this event.- Returns:
- The topic of this event.
-
matches
public final boolean matches(org.osgi.framework.Filter filter)
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
public boolean equals(java.lang.Object object)
Compares thisEventobject 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.- Overrides:
equalsin classjava.lang.Object- Parameters:
object- TheEventobject to be compared.- Returns:
trueifobjectis aEventand is equal to this object;falseotherwise.
-
hashCode
public int hashCode()
Returns a hash code value for this object.- Overrides:
hashCodein classjava.lang.Object- Returns:
- An integer which is a hash code value for this object.
-
toString
public java.lang.String toString()
Returns the string representation of this event.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation of this event.
-
-