net.sourceforge.esw.properties
Class PropertyUtil

java.lang.Object
  |
  +--net.sourceforge.esw.properties.PropertyUtil

public class PropertyUtil
extends java.lang.Object

Utilities for use with the Properties framework.

See Also:
PropertyFactory

Field Summary
protected static java.lang.String DEFAULT_PROPERTIES
          The name of the default ESW framework XML properties file.
protected static java.lang.String DEFAULT_PROPERTIES_FILE
          The name and path of the default ESW framework XML properties file.
static java.lang.String SYSTEM_PROPERTIES_NAME
          The name of the system property that specifies where properties file is on the file system.
 
Constructor Summary
PropertyUtil()
           
 
Method Summary
static void createFileDictionaryPropertySource(int aRank, java.lang.String aFilename, java.lang.String aDelimiter, boolean bWriteable)
          Creates and adds a file based Dictionary IPropertySource instance to the default IPropertyAggregator instance at the specified rank.
static void createFileXMLPropertySource(int aRank, java.lang.String aFilename, boolean bWriteable)
          Creates and adds a file based XML IPropertySource instance to the default IPropertyAggregator instance at the specified rank.
static void createJDBCPropertySource(int aRank, java.lang.String aDriver, java.lang.String aURL, java.lang.String aUser, java.lang.String aPassword, boolean bWriteable)
          Creates and adds a JDBC IPropertySource instance to the default IPropertyAggregator instance at the specified rank.
static void createSystemPropertySource(int aRank, boolean bWriteable)
          Creates and adds a java.lang.System IPropertySource instance to the default IPropertyAggregator instance at the specified rank.
static void createURLDictionaryPropertySource(int aRank, java.lang.String aURL, java.lang.String aDelimiter, boolean bWriteable)
          Creates and adds an URL based Dictionary IPropertySource instance to the default IPropertyAggregator instance at the specified rank.
static boolean getBooleanProperty(java.lang.String aPropertyName, boolean aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static boolean getBooleanPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, boolean aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static INode getContext(java.lang.String aContext, java.lang.String aPropertyName)
          Returns the first INode instance from the default IPropertyAggregator instance that matches the specified property name.
static double getDoubleProperty(java.lang.String aPropertyName, double aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static double getDoublePropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, double aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static float getFloatProperty(java.lang.String aPropertyName, float aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static float getFloatPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, float aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static int getIntProperty(java.lang.String aPropertyName, int aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static int getIntPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, int aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static long getLongProperty(java.lang.String aPropertyName, long aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static long getLongPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, long aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static java.lang.String getProperty(java.lang.String aPropertyName)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name.
static java.lang.String getProperty(java.lang.String aPropertyName, java.lang.String aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static java.lang.String getPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name.
static java.lang.String getPropertyInContext(java.lang.String aContext, java.lang.String aPropertyName, java.lang.String aDefaultValue)
          Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.
static void setupDefaultPropertySource(IPropertyAggregator aPropertyAggregator)
          Creates an IPropertySource instance from the default properties for the framework, and attaches it to the specified IPropertyAggregator instance at the 5th ranking.
static void setupSystemPropertySource(IPropertyAggregator aPropertyAggregator)
          Creates an IPropertySource instance from the java.lang.system properties for the framework, and attaches it to the specified IPropertyAggregator instance at the 10th ranking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROPERTIES

protected static final java.lang.String DEFAULT_PROPERTIES
The name of the default ESW framework XML properties file.

DEFAULT_PROPERTIES_FILE

protected static final java.lang.String DEFAULT_PROPERTIES_FILE
The name and path of the default ESW framework XML properties file.

SYSTEM_PROPERTIES_NAME

public static final java.lang.String SYSTEM_PROPERTIES_NAME
The name of the system property that specifies where properties file is on the file system. The default is in the user directory of the current user.
Constructor Detail

PropertyUtil

public PropertyUtil()
Method Detail

setupDefaultPropertySource

public static void setupDefaultPropertySource(IPropertyAggregator aPropertyAggregator)
Creates an IPropertySource instance from the default properties for the framework, and attaches it to the specified IPropertyAggregator instance at the 5th ranking.
Parameters:
aPropertyAggregator - the IPropertyAggregator instance to which to attach the created IPropertySource instance.

setupSystemPropertySource

public static void setupSystemPropertySource(IPropertyAggregator aPropertyAggregator)
Creates an IPropertySource instance from the java.lang.system properties for the framework, and attaches it to the specified IPropertyAggregator instance at the 10th ranking.
Parameters:
aPropertyAggregator - the IPropertyAggregator instance to which to attach the created IPropertySource instance.

createFileXMLPropertySource

public static void createFileXMLPropertySource(int aRank,
                                               java.lang.String aFilename,
                                               boolean bWriteable)
                                        throws java.lang.Exception
Creates and adds a file based XML IPropertySource instance to the default IPropertyAggregator instance at the specified rank. It also loads the contents of the represented property source into the created IPropertySource instance.
Parameters:
aRank - the rank the specifed IPropertySource instance should be added.
aFilename - the name of the file to find the XML data source.
bWriteable - if true, the added IPropertySource instance will be created as being writable, otherwise, the IPropertySource instance will be read-only.
Throws:
java.lang.Exception - if an error occurs during the creation.

createSystemPropertySource

public static void createSystemPropertySource(int aRank,
                                              boolean bWriteable)
                                       throws java.lang.Exception
Creates and adds a java.lang.System IPropertySource instance to the default IPropertyAggregator instance at the specified rank. It also loads the contents of the represented property source into the created IPropertySource instance.
Parameters:
aRank - the rank the specifed IPropertySource instance should be added.
bWriteable - if true, the added IPropertySource instance will be created as being writable, otherwise, the IPropertySource instance will be read-only.
Throws:
java.lang.Exception - if an error occurs during the creation.

createFileDictionaryPropertySource

public static void createFileDictionaryPropertySource(int aRank,
                                                      java.lang.String aFilename,
                                                      java.lang.String aDelimiter,
                                                      boolean bWriteable)
                                               throws java.lang.Exception
Creates and adds a file based Dictionary IPropertySource instance to the default IPropertyAggregator instance at the specified rank. It also loads the contents of the represented property source into the created IPropertySource instance.
Parameters:
aRank - the rank the specifed IPropertySource instance should be added.
aFilename - the name of the file to find the Dictionary data source.
aDelimiter - the delimiter for the Dictionary data source. (For java.land.Properties, '=' is the delimiter).
bWriteable - if true, the added IPropertySource instance will be created as being writable, otherwise, the IPropertySource instance will be read-only.
Throws:
java.lang.Exception - if an error occurs during the creation.

createURLDictionaryPropertySource

public static void createURLDictionaryPropertySource(int aRank,
                                                     java.lang.String aURL,
                                                     java.lang.String aDelimiter,
                                                     boolean bWriteable)
                                              throws java.lang.Exception
Creates and adds an URL based Dictionary IPropertySource instance to the default IPropertyAggregator instance at the specified rank. It also loads the contents of the represented property source into the created IPropertySource instance.
Parameters:
aRank - the rank the specifed IPropertySource instance should be added.
aURL - the URL of the Dictionary data source.
aDelimiter - the delimiter for the Dictionary data source. (For java.land.Properties, '=' is the delimiter).
bWriteable - if true, the added IPropertySource instance will be created as being writable, otherwise, the IPropertySource instance will be read-only.
Throws:
java.lang.Exception - if an error occurs during the creation.

createJDBCPropertySource

public static void createJDBCPropertySource(int aRank,
                                            java.lang.String aDriver,
                                            java.lang.String aURL,
                                            java.lang.String aUser,
                                            java.lang.String aPassword,
                                            boolean bWriteable)
                                     throws java.lang.Exception
Creates and adds a JDBC IPropertySource instance to the default IPropertyAggregator instance at the specified rank. It also loads the contents of the represented property source into the created IPropertySource instance.
Parameters:
aRank - the rank the specifed IPropertySource instance should be added.
aDriver - the fully-qualified JDBC Driver class name.
aURL - the URL for the JDBC driver.
aUser - the authorized user for the JDBC data source.
aPassword - the password for the authoized user.
bWriteable - if true, the added IPropertySource instance will be created as being writable, otherwise, the IPropertySource instance will be read-only.
Throws:
java.lang.Exception - if an error occurs during the creation.

getProperty

public static java.lang.String getProperty(java.lang.String aPropertyName)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.

getProperty

public static java.lang.String getProperty(java.lang.String aPropertyName,
                                           java.lang.String aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties.

getBooleanProperty

public static boolean getBooleanProperty(java.lang.String aPropertyName,
                                         boolean aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a boolean type. That is, if the property value is the String true, then true will be returned. Likewise, the String false will return the boolean value false. If the found value is anything else, the default value is returned. Case is ignored.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a boolean type.

getDoubleProperty

public static double getDoubleProperty(java.lang.String aPropertyName,
                                       double aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a double type. That is, if the property value can be sucessfully converted via Double.parseDouble( value ) then the resulting double will be returned. Otherwise, the default value will be returned.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a double type.

getFloatProperty

public static float getFloatProperty(java.lang.String aPropertyName,
                                     float aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a float type. That is, if the property value can be sucessfully converted via Float.parseFloat( value ) then the resulting float will be returned. Otherwise, the default value will be returned.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a float type.

getIntProperty

public static int getIntProperty(java.lang.String aPropertyName,
                                 int aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a int type. That is, if the property value can be sucessfully converted via Integer.parseInt( value ) then the resulting int will be returned. Otherwise, the default value will be returned.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a int type.

getLongProperty

public static long getLongProperty(java.lang.String aPropertyName,
                                   long aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a long type. That is, if the property value can be sucessfully converted via Long.parseLong( value ) then the resulting long will be returned. Otherwise, the default value will be returned.

This method is for properties that are not hierarchical.

Parameters:
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a long type.

getPropertyInContext

public static java.lang.String getPropertyInContext(java.lang.String aContext,
                                                    java.lang.String aPropertyName)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.

getPropertyInContext

public static java.lang.String getPropertyInContext(java.lang.String aContext,
                                                    java.lang.String aPropertyName,
                                                    java.lang.String aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties.

getBooleanPropertyInContext

public static boolean getBooleanPropertyInContext(java.lang.String aContext,
                                                  java.lang.String aPropertyName,
                                                  boolean aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a boolean type. That is, if the property value is the String true, then true will be returned. Likewise, the String false will return the boolean value false. If the found value is anything else, the default value is returned. Case is ignored.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a boolean type.

getDoublePropertyInContext

public static double getDoublePropertyInContext(java.lang.String aContext,
                                                java.lang.String aPropertyName,
                                                double aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a double type. That is, if the property value can be sucessfully converted via Double.parseDouble( value ) then the resulting double will be returned. Otherwise, the default value will be returned.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a double type.

getFloatPropertyInContext

public static float getFloatPropertyInContext(java.lang.String aContext,
                                              java.lang.String aPropertyName,
                                              float aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a float type. That is, if the property value can be sucessfully converted via Float.parseFloat( value ) then the resulting float will be returned. Otherwise, the default value will be returned.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a float type.

getIntPropertyInContext

public static int getIntPropertyInContext(java.lang.String aContext,
                                          java.lang.String aPropertyName,
                                          int aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a int type. That is, if the property value can be sucessfully converted via Integer.parseInt( value ) then the resulting int will be returned. Otherwise, the default value will be returned.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a int type.

getLongPropertyInContext

public static long getLongPropertyInContext(java.lang.String aContext,
                                            java.lang.String aPropertyName,
                                            long aDefaultValue)
Returns the first property value from the default IPropertyAggregator instance that matches the specified property name, or the specified default value if no match is found.

This method attempts to handle any found property value as a long type. That is, if the property value can be sucessfully converted via Long.parseLong( value ) then the resulting long will be returned. Otherwise, the default value will be returned.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the property to search for in the default IPropertyAggregator instance with the specified context.
aDefaultValue - the default value to return if the specified property name does not exist in the current set of properties, or if the found value cannot be intrepreted as a long type.

getContext

public static INode getContext(java.lang.String aContext,
                               java.lang.String aPropertyName)
Returns the first INode instance from the default IPropertyAggregator instance that matches the specified property name.

This method is for properties that are hierarchical to a 2 level depth.

Parameters:
aContext - the name of the context for the property.
aPropertyName - the name of the INode to search for in the default IPropertyAggregator instance with the specified context.


Copyright 2002 Free Software Foundation. All Rights Reserved.