站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 common API Documentation 英文版文档

PropertyMap (JBoss/Common API) - JBoss 4.0.1 sp1 common API Documentation 英文版文档


org.jboss.util.property
Class PropertyMap

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byjava.util.Properties
              extended byorg.jboss.util.property.PropertyMap
All Implemented Interfaces:
Cloneable, Map, Serializable
Direct Known Subclasses:
PropertyContainer, PropertyGroup

public class PropertyMap
extends Properties

A replacement for the standard java.util.Properties class which adds, among others, property event capabilities.

Version:
$Revision: 1.5 $
Author:
Jason Dillon, Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
protected  Map boundListeners
          Bound property name -> listener list map
static String[] EMPTY_ARRAY_PROPERTY
          Empty array property
static String PROPERTY_NAME_SEPARATOR
          Property name separator
protected  List unboundListeners
          Property listener list
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
PropertyMap()
          Construct a PropertyMap.
PropertyMap(Properties defaults)
          Construct a PropertyMap with default properties.
 
Method Summary
protected  void addPropertyListener(BoundPropertyListener listener)
          Add a bound property listener.
 void addPropertyListener(PropertyListener listener)
          Add a property listener.
 void addPropertyListeners(PropertyListener[] listeners)
          Add an array of property listeners.
 boolean containsProperty(String name)
          Check if this map contains a given property.
 Set entrySet(boolean includeDefaults)
          Returns a set of entrys for all entries in this group and optionally all of the entrys in the defaults map.
protected  void firePropertyAdded(PropertyEvent event)
          Fire a property added event to all registered listeners.
protected  void firePropertyChanged(PropertyEvent event)
          Fire a property changed event to all listeners.
protected  void firePropertyRemoved(PropertyEvent event)
          Fire a property removed event to all registered listeners.
 String[] getArrayProperty(String name)
          Get an array style property.
 String[] getArrayProperty(String base, String[] defaultValues)
          Get an array style property.
 String getProperty(String name)
           
 PropertyGroup getPropertyGroup(String basename)
          Get a property group for the given property base.
 PropertyGroup getPropertyGroup(String basename, int index)
          Get a property group for the given property base at the given index.
 Set keySet(boolean includeDefaults)
          Returns a set of keys for all entries in this group and optionally all of the keys in the defaults map.
 void load(Map map)
          Load properties from a map.
 void load(PropertyReader reader)
          Load properties from a PropertyReader.
 void load(String className)
          Load properties from a PropertyReader specifed by the given class name.
 void load(String prefix, Map map)
          Load properties from a map.
protected  String makeIndexPropertyName(String base, int index)
          Make an indexed property name.
protected  String makePrefixedPropertyName(String base, String prefix)
          Make a optionaly prefixed property name.
 Iterator names()
          Return an iterator over all contained property names.
 Object put(Object name, Object value)
          Set a property.
 Object remove(Object name)
          Remove a property.
 String removeProperty(String name)
          Remove a property.
protected  boolean removePropertyListener(BoundPropertyListener listener)
          Remove a bound property listener.
 boolean removePropertyListener(PropertyListener listener)
          Remove a property listener.
 Object setProperty(String name, String value)
          Set a property.
 
Methods inherited from class java.util.Properties
getProperty, list, list, load, propertyNames, save, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_NAME_SEPARATOR

public static final String PROPERTY_NAME_SEPARATOR
Property name separator

See Also:
Constant Field Values

EMPTY_ARRAY_PROPERTY

public static final String[] EMPTY_ARRAY_PROPERTY
Empty array property


unboundListeners

protected transient List unboundListeners
Property listener list


boundListeners

protected transient Map boundListeners
Bound property name -> listener list map

Constructor Detail

PropertyMap

public PropertyMap(Properties defaults)
Construct a PropertyMap with default properties.

Parameters:
defaults - Default properties.

PropertyMap

public PropertyMap()
Construct a PropertyMap.

Method Detail

put

public Object put(Object name,
                  Object value)
Set a property.

Parameters:
name - Property name.
value - Property value.
Returns:
Previous property value or null.

remove

public Object remove(Object name)
Remove a property.

Parameters:
name - Property name.
Returns:
Removed property value.

keySet

public Set keySet(boolean includeDefaults)
Returns a set of keys for all entries in this group and optionally all of the keys in the defaults map.


entrySet

public Set entrySet(boolean includeDefaults)
Returns a set of entrys for all entries in this group and optionally all of the entrys in the defaults map.


addPropertyListener

public void addPropertyListener(PropertyListener listener)
Add a property listener.

Parameters:
listener - Property listener to add.

addPropertyListener

protected void addPropertyListener(BoundPropertyListener listener)
Add a bound property listener.

Parameters:
listener - Bound property listener to add.

addPropertyListeners

public void addPropertyListeners(PropertyListener[] listeners)
Add an array of property listeners.

Parameters:
listeners - Array of property listeners to add.

removePropertyListener

public boolean removePropertyListener(PropertyListener listener)
Remove a property listener.

Parameters:
listener - Property listener to remove.
Returns:
True if listener was removed.

removePropertyListener

protected boolean removePropertyListener(BoundPropertyListener listener)
Remove a bound property listener.

Parameters:
listener - Bound property listener to remove.
Returns:
True if listener was removed.

firePropertyAdded

protected void firePropertyAdded(PropertyEvent event)
Fire a property added event to all registered listeners.

Parameters:
event - Property event.

firePropertyRemoved

protected void firePropertyRemoved(PropertyEvent event)
Fire a property removed event to all registered listeners.

Parameters:
event - Property event.

firePropertyChanged

protected void firePropertyChanged(PropertyEvent event)
Fire a property changed event to all listeners.

Parameters:
event - Property event.

makePrefixedPropertyName

protected String makePrefixedPropertyName(String base,
                                          String prefix)
Make a optionaly prefixed property name.

Parameters:
base - Base property name.
prefix - Optional prefix (can be null).
Returns:
Property name.

load

public void load(String prefix,
                 Map map)
          throws PropertyException
Load properties from a map.

Parameters:
prefix - Prefix to append to all map keys (or null).
map - Map containing properties to load.
Throws:
PropertyException

load

public void load(Map map)
          throws PropertyException
Load properties from a map.

Parameters:
map - Map containing properties to load.
Throws:
PropertyException

load

public void load(PropertyReader reader)
          throws PropertyException,
                 IOException
Load properties from a PropertyReader.

Parameters:
reader - PropertyReader to read properties from.
Throws:
PropertyException
IOException

load

public void load(String className)
          throws PropertyException,
                 IOException
Load properties from a PropertyReader specifed by the given class name.

Parameters:
className - Class name of a PropertyReader to read from.
Throws:
PropertyException
IOException

setProperty

public Object setProperty(String name,
                          String value)
Set a property.

Returns Object instead of String due to limitations with java.util.Properties.

Parameters:
name - Property name.
value - Property value.
Returns:
Previous property value or null.

getProperty

public String getProperty(String name)

removeProperty

public String removeProperty(String name)
Remove a property.

Parameters:
name - Property name.
Returns:
Removed property value or null.

makeIndexPropertyName

protected String makeIndexPropertyName(String base,
                                       int index)
Make an indexed property name.

Parameters:
base - Base property name.
index - Property index.
Returns:
Indexed property name.

getArrayProperty

public String[] getArrayProperty(String base,
                                 String[] defaultValues)
Get an array style property.

Array properties are specified as: base_property_name.INDEX.

Indexes begin with zero and must be contiguous. A break in continuity signals the end of the array.

Parameters:
base - Base property name.
defaultValues - Default property values.
Returns:
Array of property values or default.

getArrayProperty

public String[] getArrayProperty(String name)
Get an array style property.

Parameters:
name - Property name.
Returns:
Array of property values or empty array.

names

public Iterator names()
Return an iterator over all contained property names.

Returns:
Property name iterator.

containsProperty

public boolean containsProperty(String name)
Check if this map contains a given property.

Parameters:
name - Property name.
Returns:
True if contains property.

getPropertyGroup

public PropertyGroup getPropertyGroup(String basename)
Get a property group for the given property base.

Parameters:
basename - Base property name.
Returns:
Property group.

getPropertyGroup

public PropertyGroup getPropertyGroup(String basename,
                                      int index)
Get a property group for the given property base at the given index.

Parameters:
basename - Base property name.
index - Array property index.
Returns:
Property group.


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.