Top Description Inners Fields Constructors Methods
org.osgi.service.event

public Class Event

extends Object
Class Inheritance
Static Imports
org.osgi.service.event.EventConstants.EVENT_TOPIC

An event. Event objects are delivered to EventHandler services which subscribe to the topic of the event.
Author
$Id: 13cd9f2a04f5e69fbc2b736808495962a2d67f8a $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Event.FilterProperties

Dictionary to use for Filter matching.

Field Summary

Modifier and TypeField and Description
private final EventProperties
properties

The properties carried by this event.

private final String
topic

The topic of this event.

Constructor Summary

AccessConstructor and Description
public
Event(String
The topic of the event.
topic
,
Map<String, ?>
The event's properties (may be null). A property whose key is not of type String will be ignored. If the specified properties is an EventProperties object, then it will be directly used. Otherwise, a copy of the specified properties is made.
properties
)

Constructs an event.

public
Event(String
The topic of the event.
topic
,
Dictionary<String, ?>
The event's properties (may be null). A property whose key is not of type String will be ignored. A copy of the specified properties is made.
properties
)

Constructs an event.

Method Summary

Modifier and TypeMethod and Description
public final boolean

Returns:

true if a property with the specified name is in the event. This property may have a null value. false otherwise.
containsProperty
(String
The name of the property.
name
)

Indicate the presence of an event property.

public boolean

Returns:

true if object is a Event and is equal to this object; false otherwise.
equals
(Object
The Event object to be compared.
object
)

Overrides java.lang.Object.equals.

Compares this Event object to another object.

public final Object

Returns:

The value of the property, or null if not found.
getProperty
(String
The name of the property to retrieve.
name
)

Retrieve the value of an event property.

public final String[]

Returns:

A non-empty array with one element per property.
getPropertyNames
()

Returns a list of this event's property names.

public final String

Returns:

The topic of this event.
getTopic
()

Returns the topic of this event.

public int

Returns:

An integer which is a hash code value for this object.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public final boolean

Returns:

true If this event's properties match the filter, false otherwise.
matches
(Filter
The filter to test.
filter
)

Tests this event's properties against the given filter using a case sensitive match.

public String

Returns:

The string representation of this event.
toString
()

Overrides java.lang.Object.toString.

Returns the string representation of this event.

private static void
validateTopicName(String
The topic name to validate.
topic
)

Called by the constructor to validate the topic name.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

propertiesback to summary
private final EventProperties properties

The properties carried by this event. Keys are strings and values are objects

topicback to summary
private final String topic

The topic of this event.

Constructor Detail

Eventback to summary
public Event(String topic, Map<String, ?> properties)

Constructs an event.

Parameters
topic:String

The topic of the event.

properties:Map<String, ?>

The event's properties (may be null). A property whose key is not of type String will be ignored. If the specified properties is an EventProperties object, then it will be directly used. Otherwise, a copy of the specified properties is made.

Exceptions
IllegalArgumentException:
If topic is not a valid topic name.
Since
1.2
Eventback to summary
public Event(String topic, Dictionary<String, ?> properties)

Constructs an event.

Parameters
topic:String

The topic of the event.

properties:Dictionary<String, ?>

The event's properties (may be null). A property whose key is not of type String will be ignored. A copy of the specified properties is made.

Exceptions
IllegalArgumentException:
If topic is not a valid topic name.

Method Detail

containsPropertyback to summary
public final boolean containsProperty(String name)

Indicate the presence of an event property. The event topic is present using the property name "event.topics".

Parameters
name:String

The name of the property.

Returns:boolean

true if a property with the specified name is in the event. This property may have a null value. false otherwise.

Since
1.3
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

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. The properties are compared using the java.util.Map.equals() rules which includes identity comparison for array values.

Parameters
object:Object

The Event object to be compared.

Returns:boolean

true if object is a Event and is equal to this object; false otherwise.

Annotations
@Override
getPropertyback to summary
public final Object getProperty(String name)

Retrieve the value of an event property. The event topic may be retrieved with the property name "event.topics".

Parameters
name:String

The name of the property to retrieve.

Returns:Object

The value of the property, or null if not found.

getPropertyNamesback to summary
public final String[] getPropertyNames()

Returns a list of this event's property names. The list will include the event topic property name "event.topics".

Returns:String[]

A non-empty array with one element per property.

getTopicback to summary
public final String getTopic()

Returns the topic of this event.

Returns:String

The topic of this event.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Returns:int

An integer which is a hash code value for this object.

Annotations
@Override
matchesback to summary
public final boolean matches(Filter filter)

Tests this event's properties against the given filter using a case sensitive match.

Parameters
filter:Filter

The filter to test.

Returns:boolean

true If this event's properties match the filter, false otherwise.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns the string representation of this event.

Returns:String

The string representation of this event.

Annotations
@Override
validateTopicNameback to summary
private static void validateTopicName(String topic)

Called by the constructor to validate the topic name.

Parameters
topic:String

The topic name to validate.

Exceptions
IllegalArgumentException:
If the topic name is invalid.
org.osgi.service.event back to summary

private final Class Event.FilterProperties

extends Dictionary<String, Object>
Class Inheritance

Dictionary to use for Filter matching.

Field Summary

Modifier and TypeField and Description
private final EventProperties
private final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Enumeration<Object>
elements()

Implements abstract java.util.Dictionary.elements.

Returns an enumeration of the values in this dictionary.

public Object
get(Object
a key in this dictionary. null if the key is not mapped to any value in this dictionary.
key
)

Implements abstract java.util.Dictionary.get.

Returns the value to which the key is mapped in this dictionary.

public boolean
isEmpty()

Implements abstract java.util.Dictionary.isEmpty.

Tests if this dictionary maps no keys to value.

public Enumeration<String>
keys()

Implements abstract java.util.Dictionary.keys.

Returns an enumeration of the keys in this dictionary.

public Object
put(String
the hashtable key.
key
,
Object
the value.
value
)

Implements abstract java.util.Dictionary.put.

Maps the specified key to the specified value in this dictionary.

public Object
remove(Object
the key that needs to be removed.
key
)

Implements abstract java.util.Dictionary.remove.

Removes the key (and its corresponding value) from this dictionary.

public int
size()

Implements abstract java.util.Dictionary.size.

Returns the number of entries (distinct keys) in this dictionary.

Field Detail

propertiesback to summary
private final EventProperties properties
topicback to summary
private final String topic

Constructor Detail

FilterPropertiesback to summary
pack-priv FilterProperties(String topic, EventProperties properties)

Method Detail

elementsback to summary
public Enumeration<Object> elements()

Implements abstract java.util.Dictionary.elements.

Doc from java.util.Dictionary.elements.

Returns an enumeration of the values in this dictionary. The general contract for the elements method is that an Enumeration is returned that will generate all the elements contained in entries in this dictionary.

Returns:Enumeration<Object>

an enumeration of the values in this dictionary.

Annotations
@Override
getback to summary
public Object get(Object key)

Implements abstract java.util.Dictionary.get.

Doc from java.util.Dictionary.get.

Returns the value to which the key is mapped in this dictionary. The general contract for the isEmpty method is that if this dictionary contains an entry for the specified key, the associated value is returned; otherwise, null is returned.

Parameters
key:Object

a key in this dictionary. null if the key is not mapped to any value in this dictionary.

Returns:Object

the value to which the key is mapped in this dictionary;

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements abstract java.util.Dictionary.isEmpty.

Doc from java.util.Dictionary.isEmpty.

Tests if this dictionary maps no keys to value. The general contract for the isEmpty method is that the result is true if and only if this dictionary contains no entries.

Returns:boolean

true if this dictionary maps no keys to values; false otherwise.

Annotations
@Override
keysback to summary
public Enumeration<String> keys()

Implements abstract java.util.Dictionary.keys.

Doc from java.util.Dictionary.keys.

Returns an enumeration of the keys in this dictionary. The general contract for the keys method is that an Enumeration object is returned that will generate all the keys for which this dictionary contains entries.

Returns:Enumeration<String>

an enumeration of the keys in this dictionary.

Annotations
@Override
putback to summary
public Object put(String key, Object value)

Implements abstract java.util.Dictionary.put.

Doc from java.util.Dictionary.put.

Maps the specified key to the specified value in this dictionary. Neither the key nor the value can be null.

If this dictionary already contains an entry for the specified key, the value already in this dictionary for that key is returned, after modifying the entry to contain the new element.

If this dictionary does not already have an entry for the specified key, an entry is created for the specified key and value, and null is returned.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters
key:String

the hashtable key.

value:Object

the value.

Returns:Object

the previous value to which the key was mapped in this dictionary, or null if the key did not have a previous mapping.

Annotations
@Override
removeback to summary
public Object remove(Object key)

Implements abstract java.util.Dictionary.remove.

Doc from java.util.Dictionary.remove.

Removes the key (and its corresponding value) from this dictionary. This method does nothing if the key is not in this dictionary.

Parameters
key:Object

the key that needs to be removed.

Returns:Object

the value to which the key had been mapped in this dictionary, or null if the key did not have a mapping.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.Dictionary.size.

Doc from java.util.Dictionary.size.

Returns the number of entries (distinct keys) in this dictionary.

Returns:int

the number of keys in this dictionary.

Annotations
@Override