org.osgi.service.event
Class Event

java.lang.Object
  extended by org.osgi.service.event.Event

public class Event
extends java.lang.Object

An event. Event objects are delivered to EventHandler services which subscribe to the topic of the event.

Version:
$Revision: 7003 $
Immutable

Nested Class Summary
private static class Event.UnmodifiableDictionary
          Unmodifiable wrapper for Dictionary.
 
Field Summary
private  java.util.Map properties
          The properties carried by this event.
private  java.lang.String topic
          The topic of this event.
 
Constructor Summary
Event(java.lang.String topic, java.util.Dictionary properties)
          Constructs an event.
Event(java.lang.String topic, java.util.Map properties)
          Constructs an event.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

topic

private final java.lang.String topic
The topic of this event.


properties

private final java.util.Map properties
The properties carried by this event. Keys are strings and values are objects

Constructor Detail

Event

public Event(java.lang.String topic,
             java.util.Map properties)
Constructs an event.

Parameters:
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.
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 properties)
Constructs an event.

Parameters:
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.
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)
Retrieves a property.

Parameters:
name - the name of the property to retrieve
Returns:
The value of the property, or null if not found.

getPropertyNames

public final java.lang.String[] getPropertyNames()
Returns a list of this event's property names.

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 this 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.

Overrides:
equals in class java.lang.Object
Parameters:
object - The Event object to be compared.
Returns:
true if object is a Event and is equal to this object; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.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:
toString in class java.lang.Object
Returns:
The string representation of this event.

validateTopicName

private static void validateTopicName(java.lang.String topic)
Called by the constructor to validate the topic name.

Parameters:
topic - The topic name to validate.
Throws:
java.lang.IllegalArgumentException - If the topic name is invalid.


Copyright © 2001-2010 Eclipse Foundation. All Rights Reserved.