Compoze Software, Inc.

com.compoze.util
Class MutableProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--com.compoze.util.ObjectProperties
                          |
                          +--com.compoze.util.MutableProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
FileProperties, ResourceProperties

public class MutableProperties
extends ObjectProperties
implements java.io.Serializable

This class provides a properties object that can change the response for its values based on a named configuration. An example listing of properties is as follows:

 # default property
 link.yahoo = http://www.yahoo.com/

 # property used for named configuration "europe"
 europe-link.yahoo = http://www.europe.yahoo.com/
 

So, for example, the value for link.yahoo in the named configuration europe would be http://www.europe.yahoo.com/. In the named configuration asia the value would default to http://www.yahoo.com/. Named configurations are listed in order of precedence.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
MutableProperties()
          Constructor.
MutableProperties(java.util.LinkedList configuration)
          Constructor.
MutableProperties(java.util.Properties defaults)
          Constructor.
MutableProperties(java.util.Properties defaults, java.util.LinkedList configuration)
          Constructor.
 
Method Summary
 java.lang.String getProperty(java.lang.String sKey)
          Get a property.
 java.lang.String getProperty(java.lang.String sKey, java.lang.String sDefault)
          Get a property.
 java.util.Enumeration propertyNames()
          This method overrides the same method in java.util.Properties, and returns property names without their mutable property prefixes.
 void setConfiguration(java.util.LinkedList configuration)
          Set the current configuration.
 
Methods inherited from class com.compoze.util.ObjectProperties
getBoolean, getBoolean, getByte, getByte, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getString, getString, getStringArray, getStringArray, getStringArray, replaceSubstitutions
 
Methods inherited from class java.util.Properties
list, list, load, save, setProperty, store
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutableProperties

public MutableProperties()
Constructor.

MutableProperties

public MutableProperties(java.util.Properties defaults)
Constructor.
Parameters:
defaults - default properties

MutableProperties

public MutableProperties(java.util.LinkedList configuration)
Constructor.
Parameters:
configuration - the list of configurations to set (in order of precedence)

MutableProperties

public MutableProperties(java.util.Properties defaults,
                         java.util.LinkedList configuration)
Constructor.
Parameters:
defaults - default properties
configuration - the list of configurations to set (in order of precedence)
Method Detail

propertyNames

public java.util.Enumeration propertyNames()
This method overrides the same method in java.util.Properties, and returns property names without their mutable property prefixes.
Overrides:
propertyNames in class java.util.Properties
Returns:
the enumeration of property names without their mutable property prefixes

setConfiguration

public void setConfiguration(java.util.LinkedList configuration)
Set the current configuration.
Parameters:
configuration - the list of configurations to set (in order of precedence)

getProperty

public java.lang.String getProperty(java.lang.String sKey)
Get a property. If a configuration is set and a value for that configuration is available then that is returned, otherwise the default value is returned.
Overrides:
getProperty in class ObjectProperties
Parameters:
sKey - the key of the property
Returns:
the value

getProperty

public java.lang.String getProperty(java.lang.String sKey,
                                    java.lang.String sDefault)
Get a property. If a configuration is set and a value for that configuration is available then that is returned, otherwise the default value is returned.
Overrides:
getProperty in class ObjectProperties
Parameters:
sKey - the key of the property
sDefault - the default to return if a value for the configuration is not found
Returns:
the value

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.