DESY ACOP Beans Home

com.cosylab.util
Class ExtendedProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by com.cosylab.util.ExtendedProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class ExtendedProperties
extends java.util.Properties

DOCUMENT ME!

Version:
$id$
See Also:
Serialized Form

Field Summary
static java.lang.String DELIMITER
          The delimiter that is used to separate each part in the property name that makes the hierarchy.
static java.lang.String LINK_SUFFIX
          Suffix used to speficy a linked properties file.
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
ExtendedProperties()
          Creates a new ExtendedProperties object.
ExtendedProperties(java.util.Properties defaults)
          Creates a new ExtendedProperties object.
 
Method Summary
 void checkForLinks(java.net.URL resource)
           
 java.lang.Class getClassProperty(java.lang.String key)
          Convenience method that tries to return Class instace specified by fully qualified string.
 double getDoubleProperty(java.lang.String key)
          Convenience method that tries to return double value of property.
 int getIntProperty(java.lang.String key)
          Convenience method that tries to return int value of property.
 ExtendedProperties getProperties(java.lang.String mementoName)
          Returns an instance of the ExtendedProperties object which have only properties under the hierarchy given by mementoName.
 void load(java.io.InputStream inStream)
          Deprecated. Use @link #load(URL) to process links properly
 void load(java.net.URL resource)
           
 void setProperties(java.lang.String mementoName, ExtendedProperties ep)
          Inserts the content of the given ExtendedProperties to this properties by prefixing each key with given mementoName.
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
 
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
 

Field Detail

LINK_SUFFIX

public static final java.lang.String LINK_SUFFIX
Suffix used to speficy a linked properties file. The key up to the string is used as the root for all the properties found in the referenced file.

e.g.: icon.@link = gui/icons.properties will look for a file "gui/icons.properties" and a property named text.edit from this file will be referenced in the parent properties as "icon.text.edit".

If multiple links are assigned to the same prefix, they should be numbered so that their property keys remain unique, e.g.:
icon.@link1 = gui/myIcons.properties icon.@link2 = gui/otherIcons.properties

See Also:
Constant Field Values

DELIMITER

public static final java.lang.String DELIMITER
The delimiter that is used to separate each part in the property name that makes the hierarchy. For example the property name 'windowX' under the property 'Panel1' becomes 'Panel1.windowX' and the dot between those names is the ExtendedProperties.DELIMITER

See Also:
Constant Field Values
Constructor Detail

ExtendedProperties

public ExtendedProperties()
Creates a new ExtendedProperties object.


ExtendedProperties

public ExtendedProperties(java.util.Properties defaults)
Creates a new ExtendedProperties object.

Parameters:
defaults - DOCUMENT ME!
Method Detail

getIntProperty

public int getIntProperty(java.lang.String key)
                   throws java.lang.NumberFormatException
Convenience method that tries to return int value of property.

Parameters:
key - Name of key to query value for
Returns:
int type value of property
Throws:
java.lang.NumberFormatException
See Also:
Properties.getProperty(String)

getDoubleProperty

public double getDoubleProperty(java.lang.String key)
                         throws java.lang.NumberFormatException
Convenience method that tries to return double value of property.

Parameters:
key - Name of key to query value for
Returns:
double type value of property
Throws:
java.lang.NumberFormatException
See Also:
Properties.getProperty(String)

getClassProperty

public java.lang.Class getClassProperty(java.lang.String key)
Convenience method that tries to return Class instace specified by fully qualified string.

Parameters:
key - Name of key associated with value.
Returns:
Instance of Class or null if not found.
See Also:
Properties.getProperty(String)

getProperties

public ExtendedProperties getProperties(java.lang.String mementoName)
Returns an instance of the ExtendedProperties object which have only properties under the hierarchy given by mementoName. For example if this object has 'window.x', 'window.y' and 'something else' properties then invoking getProperties("window") will return ExtendedProperties with anly 'x' and 'y' properties.

Parameters:
mementoName - name to extract from this properties
Returns:
an ExtendedProperties object with properties matching mementoName

setProperties

public void setProperties(java.lang.String mementoName,
                          ExtendedProperties ep)
Inserts the content of the given ExtendedProperties to this properties by prefixing each key with given mementoName.

Parameters:
mementoName -
ep -

load

public void load(java.net.URL resource)
          throws java.io.IOException,
                 java.net.MalformedURLException
Throws:
java.io.IOException
java.net.MalformedURLException

load

public void load(java.io.InputStream inStream)
          throws java.io.IOException
Deprecated. Use @link #load(URL) to process links properly

Overrides:
load in class java.util.Properties
Throws:
java.io.IOException

checkForLinks

public void checkForLinks(java.net.URL resource)
                   throws java.io.IOException,
                          java.net.MalformedURLException
Throws:
java.io.IOException
java.net.MalformedURLException


Copyright © 2010. All Rights Reserved.