/******************************************************************************* * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.tcf.te.runtime.interfaces.properties; import java.util.Map; import java.util.UUID; import org.eclipse.core.runtime.IAdaptable; /** * A generic properties container. */ public interface IPropertiesContainer extends IAdaptable { /** * Returns the unique identified of the properties container. * * @return The unique identifier. */ public UUID getUUID(); /** * Set if or if not firing change events is enabled. * * @param param enabled True to enable the change events, false to disable the change events. * @return True if the enablement has changed, false if not. */ public boolean setChangeEventsEnabled(boolean enabled); /** * Returns if or if not firing change events is enabled. * * @return True if change events are enabled, false if disabled. */ public boolean changeEventsEnabled(); /** * Fires a change event with the given parameter. * * @param key The property key. Must not be null. * @param oldValue The old properties value, or null. * @param newValue The new properties value, or null. */ public void fireChangeEvent(String key, Object oldValue, Object newValue); /** * Set the properties from the given map. Calling this method * will overwrite all previous set properties. *

* Note: The method will have no effect if the given properties are the * same as the already set properties. * * @param properties The map of properties to set. Must not be null. */ public void setProperties(Map properties); /** * Adds all properties from the given map. If a property already exist * in the properties container, than the value of the property is overwritten. * * @param properties The map of properties to add. Must not be null. */ public void addProperties(Map properties); /** * Stores the property under the given property key using the given property value. * If the current property value is equal to the given property value, no store * operation will be executed. If the property value is not null and * is different from the current property value, the new value will be written to * the property store and a property change event is fired. If the property value * is null, the property key and the currently stored value are removed * from the property store. * * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. */ public boolean setProperty(String key, Object value); /** * Stores the property under the given property key using the given long * property value. The given long value is transformed to an Long * object and stored to the properties store via setProperty(java.lang.String, java.lang.Object). * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. * * @see setProperty(java.lang.String, java.lang.Object) */ public boolean setProperty(String key, long value); /** * Stores the property under the given property key using the given integer * property value. The given integer value is transformed to an Integer * object and stored to the properties store via setProperty(java.lang.String, java.lang.Object). * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. * * @see setProperty(java.lang.String, java.lang.Object) */ public boolean setProperty(String key, int value); /** * Stores the property under the given property key using the given boolean * property value. The given boolean value is transformed to an Boolean * object and stored to the properties store via setProperty(java.lang.String, java.lang.Object). * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. * * @see setProperty(java.lang.String, java.lang.Object) */ public boolean setProperty(String key, boolean value); /** * Stores the property under the given property key using the given float * property value. The given float value is transformed to an Float * object and stored to the properties store via setProperty(java.lang.String, java.lang.Object). * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. * * @see setProperty(java.lang.String, java.lang.Object) */ public boolean setProperty(String key, float value); /** * Stores the property under the given property key using the given double * property value. The given double value is transformed to an Double * object and stored to the properties store via setProperty(java.lang.String, java.lang.Object). * * @param key The property key. Must not be null! * @param value The property value. * @return true if the property value had been applied to the property store, false otherwise. * * @see setProperty(java.lang.String, java.lang.Object) */ public boolean setProperty(String key, double value); /** * Return all properties. The result map is read-only. * * @return A map containing all properties. */ public Map getProperties(); /** * Queries the property value stored under the given property key. If the property * does not exist, null is returned. * * @param key The property key. Must not be null! * @return The stored property value or null. */ public Object getProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.String, the property value casted to * java.lang.String is returned. In all other cases, null * is returned. * * @param key The property key. Must not be null! * @return The stored property value casted java.lang.String or null. */ public String getStringProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.Long, the property value converted * to an long value is returned. In all other cases, -1 is returned. * * @param key The property key. Must not be null! * @return The stored property value converted to a long value or -1. */ public long getLongProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.Integer, the property value converted * to an integer value is returned. In all other cases, -1 is returned. * * @param key The property key. Must not be null! * @return The stored property value converted to an integer value or -1. */ public int getIntProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.Boolean, the property value converted * to an boolean value is returned. In all other cases, false is returned. * * @param key The property key. Must not be null! * @return The stored property value converted to an boolean value or false. */ public boolean getBooleanProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.Float, the property value converted * to an float value is returned. In all other cases, Float.NaN is returned. * * @param key The property key. Must not be null! * @return The stored property value converted to a float value or Float.NaN. */ public float getFloatProperty(String key); /** * Queries the property value stored under the given property key. If the property * exist and is of type java.lang.Double, the property value converted * to an double value is returned. In all other cases, Double.NaN is returned. * * @param key The property key. Must not be null! * @return The stored property value converted to a double value or Double.NaN. */ public double getDoubleProperty(String key); /** * Remove all properties from the properties store. The method does not fire any * properties changed event. */ public void clearProperties(); /** * Returns whether this properties container is empty or not. * * @return True if the properties container is empty, false if not. */ public boolean isEmpty(); /** * Returns whether this properties container contains the given key. * * @param key The key. Must not be null. * @return True if the properties container contains the key, false if not. */ public boolean containsKey(String key); /** * Test if the property value stored under the given property is equal ignoring the case to the given * expected string value. * * @param key The property key. Must not be null. * @param value The expected property string value. * @return true if the expected string value is equal ignoring the case to the stored property value, false otherwise. */ public boolean isPropertyIgnoreCase(String key, String value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, Object value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, long value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, int value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, boolean value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, float value); /** * Test if the property value stored under the given property is equal to the given * expected value. * * @param key The property key. Must not be null. * @param value The expected property value. * @return true if the expected value is equal to the stored property value, false otherwise. */ public boolean isProperty(String key, double value); }