Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) OSGi Alliance (2010, 2013). All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.osgi.service.event;
 
 import static org.osgi.service.event.EventConstants.EVENT_TOPIC;
 import java.util.Map;
 import java.util.Set;

The properties for an Event. An event source can create an EventProperties object if it needs to reuse the same event properties for multiple events.

The keys are all of type String. The values are of type Object. The key "event.topics" is ignored as event topics can only be set when an Event is constructed.

Once constructed, an EventProperties object is unmodifiable. However, the values of the map used to construct an EventProperties object are still subject to modification as they are not deeply copied.

Author(s):
$Id: 8e4c47e16aca69e725321223fcd388ee7e3ee7ba $
Since:
1.3
Immutable:
 
 public class EventProperties implements Map<StringObject> {
The properties for an event. Keys are strings and values are objects. The object is unmodifiable.
 
 	private final Map<StringObject>	properties;

Create an EventProperties from the specified properties.

The specified properties will be copied into this EventProperties. Properties whose key is not of type String will be ignored. A property with the key "event.topics" will be ignored.

Parameters:
properties The properties to use for this EventProperties object (may be null).
 
 	public EventProperties(Map<String, ?> properties) {
 		int size = (properties == null) ? 0 : properties.size();
 		Map<StringObjectp = new HashMap<StringObject>(size);
 		if (size > 0) {
 			for (Object key : (Set<?>) properties.keySet()) {
 				if ((key instanceof String) && !.equals(key)) {
 					Object value = properties.get(key);
 					p.put((Stringkeyvalue);
 				}
 			}
 		}
 		// safely publish the map
 		this. = Collections.unmodifiableMap(p);
 	}

Create an EventProperties from the specified dictionary.

The specified properties will be copied into this EventProperties. Properties whose key is not of type String will be ignored. A property with the key "event.topics" will be ignored.

Parameters:
properties The properties to use for this EventProperties object (may be null).
 
 	EventProperties(Dictionary<String, ?> properties) {
 		int size = (properties == null) ? 0 : properties.size();
 		Map<StringObjectp = new HashMap<StringObject>(size);
 		if (size > 0) {
 			for (Enumeration<?> e = properties.keys(); e.hasMoreElements();) {
 				Object key = e.nextElement();
 				if ((key instanceof String) && !.equals(key)) {
 					Object value = properties.get(key);
 					p.put((Stringkeyvalue);
				}
			}
		}
		// safely publish the map
		this. = Collections.unmodifiableMap(p);
	}

	public void clear() {
	}

Indicates if the specified property is present.

Parameters:
name The property name.
Returns:
true If the property is present, false otherwise.
	public boolean containsKey(Object name) {
		return .containsKey(name);
	}

Indicates if the specified value is present.

Parameters:
value The property value.
Returns:
true If the value is present, false otherwise.
	public boolean containsValue(Object value) {
		return .containsValue(value);
	}

Return the property entries.

Returns:
A set containing the property name/value pairs.
	}

Return the value of the specified property.

Parameters:
name The name of the specified property.
Returns:
The value of the specified property.
	public Object get(Object name) {
		return .get(name);
	}

Indicate if this properties is empty.

Returns:
true If this properties is empty, false otherwise.
	public boolean isEmpty() {
	}

Return the names of the properties.

Returns:
The names of the properties.
	public Set<StringkeySet() {
		return .keySet();
	}

	public Object put(String keyObject value) {
		return .put(keyvalue);
	}

	public void putAll(Map<? extends String, ? extends Objectmap) {
	}

	public Object remove(Object key) {
		return .remove(key);
	}

Return the number of properties.

Returns:
The number of properties.
	public int size() {
		return .size();
	}

Return the properties values.

Returns:
The values of the properties.
	public Collection<Objectvalues() {
		return .values();
	}

Compares this EventProperties object to another object.

The properties are compared using the java.util.Map.equals() rules which includes identity comparison for array values.

Parameters:
object The EventProperties object to be compared.
Returns:
true if object is a EventProperties and is equal to this object; false otherwise.
	public boolean equals(Object object) {
		if (this == object) {
			return true;
		}
		if (!(object instanceof EventProperties)) {
			return false;
		}
		EventProperties other = (EventPropertiesobject;
		return .equals(other.properties);
	}

Returns a hash code value for this object.

Returns:
An integer which is a hash code value for this object.
	public int hashCode() {
	}

Returns the string representation of this object.

Returns:
The string representation of this object.
	public String toString() {
	}
New to GrepCode? Check out our FAQ X