Nitido Inc.

com.nitido.qabase
Class Configurator

java.lang.Object
  extended by com.nitido.qabase.Configurator
Direct Known Subclasses:
FileConfigurator

public abstract class Configurator
extends java.lang.Object

Configurator that retrieve the Nitido Configuration files.


Constructor Summary
protected Configurator(java.lang.String instanceName, Configurator inConfig)
          Copy Constructor that is called by getInstance( String, Configurator).
  Configurator(java.lang.String instanceName, java.lang.String identifier)
          Default constructor.
 
Method Summary
abstract  void append(Configurator appendConfig)
          Append the information from the specified incoming configurator.
abstract  void append(java.lang.String identifier)
          Append to the Configurator with the information specified by the identifier.
protected abstract  Configurator clone(java.lang.String instanceName)
          Create a cloned configurator with the same properties settings, but with the specified instanceName.
static Configurator getInstance(java.lang.String instanceName, Configurator inConfig)
           
static Configurator getInstance(java.lang.String classname, java.lang.String instanceName, java.lang.String identifier)
          Return an instance of the specified Configurator.
static java.util.Enumeration getInstanceNames()
           
abstract  java.util.Properties getProperties(java.lang.String section)
          Retrieve the Properties associated to the section.
abstract  java.lang.String getProperty(java.lang.String key)
          Retrieve the specified property value from the default section.
abstract  java.lang.String getProperty(java.lang.String section, java.lang.String key)
          Retrieve the specified property value.
abstract  java.util.Enumeration getPropertyNames(java.lang.String section)
          Get all property names stored under the specific section.
abstract  java.lang.String getPropertyWithDefault(java.lang.String key, java.lang.String defaultValue)
          Retrieve the specified property value from the default section.
abstract  java.lang.String getPropertyWithDefault(java.lang.String section, java.lang.String key, java.lang.String defaultValue)
          Retrieve the specified property value.
abstract  java.util.Enumeration getSectionNames()
          Retrieve all section names stored by this Configurator instance.
abstract  void prepend(Configurator prependConfig)
          Prepend the information from the specified incoming configurator.
abstract  void prepend(java.lang.String prependIdentifier)
          Prepend to the Configurator with the information specificed by the prependIdentifier.
abstract  void setProperty(java.lang.String section, java.lang.String name, java.lang.String value)
          Set a specific property value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurator

public Configurator(java.lang.String instanceName,
                    java.lang.String identifier)
Default constructor.

All extended implementaiton of this class must have a constructor with this signature (i.e. taking in parameters instanceName and identifier).

Note: Both parameters are not really used by this constructor it's just here to inidicate to developers that the extended class must have this parameter.


Configurator

protected Configurator(java.lang.String instanceName,
                       Configurator inConfig)
Copy Constructor that is called by getInstance( String, Configurator). This constructor should never be invoked by objects other than Configurator and extenders of Configurator.

All extended implementation of this class must have a constructor with this signature (i.e. taking in parameters instanceName and origConfig)

The content of the Configurator must be copy over from the origConfig to this new Configurator. (i.e. even if they are of the same class, you can't simply copy the member fields. You should use the getProperties to clone the Properties and copy to the new Configurator.

Method Detail

getInstance

public static Configurator getInstance(java.lang.String classname,
                                       java.lang.String instanceName,
                                       java.lang.String identifier)
                                throws ConfiguratorException
Return an instance of the specified Configurator.

Parameters:
classname - the classname of the instance.
instanceName - the instance name.
identifier - The system property to find the default login property.
Returns:
An instance of the Configurator, null if error occurred
Throws:
ConfiguratorException - If some of the important settings are incorrect, such as the specified Configurator class is not found.

getInstance

public static Configurator getInstance(java.lang.String instanceName,
                                       Configurator inConfig)

getInstanceNames

public static java.util.Enumeration getInstanceNames()

getProperty

public abstract java.lang.String getProperty(java.lang.String key)
Retrieve the specified property value from the default section.

Parameters:
key - the key of the property.
Returns:
the String value of the specified property. The method will return null object if the property has not been declared.

getProperty

public abstract java.lang.String getProperty(java.lang.String section,
                                             java.lang.String key)
Retrieve the specified property value.

Parameters:
section - the section name.
key - the key of the property.
Returns:
the String value of the specified property. The method will return null object if the property has not been declared.

getPropertyWithDefault

public abstract java.lang.String getPropertyWithDefault(java.lang.String key,
                                                        java.lang.String defaultValue)
Retrieve the specified property value from the default section. If the specified value is not found, it returns the defaultValue.

Parameters:
key - the key of the property.
defaultValue - the default value to be returned in case the property is not found.
Returns:
the String value of the specified property. The method will return the default value if the property has not been declared.

getPropertyWithDefault

public abstract java.lang.String getPropertyWithDefault(java.lang.String section,
                                                        java.lang.String key,
                                                        java.lang.String defaultValue)
Retrieve the specified property value. If the specified value is not found, it returns the defaultValue.

Parameters:
section - the section name
key - the key of the property
Returns:
the String value of the specified property. The method will return the default value if the property has not been declared.

append

public abstract void append(Configurator appendConfig)
Append the information from the specified incoming configurator. If the same section name exists in both Configurator object, this method will go through each property in the appendConfig object and append the values one by one. If a property in this object has a value already, it will be replaced by the value from the appendConfig.

In other words, all the property values stored in this oject before will remain the same only if the appendConfig has no value associated to the same property.

Parameters:
appendConfig - the Configurator object whose value is going to be appended to this Configurator.
See Also:
prepend( Configurator )

append

public abstract void append(java.lang.String identifier)
Append to the Configurator with the information specified by the identifier. The exact interpretation and syntax of the parameter identifier depends on the implementation.

Parameters:
identifier - The string which has the information required by the Configurator implementation.

prepend

public abstract void prepend(Configurator prependConfig)
Prepend the information from the specified incoming configurator. This method behaves similar to append( Configurator ) except it would NOT replace any value stored in this object. It will go through each property in the prependConfig and insert the value into this object only if the property doesn't exists.

In other words, this method will not affect any property values that are already stored in this object before its invocation.

See Also:
append( Configurator )

prepend

public abstract void prepend(java.lang.String prependIdentifier)
Prepend to the Configurator with the information specificed by the prependIdentifier. This method behaves similar to append( String ) except it would NOT replace any value stored in this object. It will go through each property in the prependConfig and insert the value into this object only if the property doesn't exists.

In other words, this method will not affect any property values that are already stored in this object before its invocation.

See Also:
append( String )

setProperty

public abstract void setProperty(java.lang.String section,
                                 java.lang.String name,
                                 java.lang.String value)
Set a specific property value.

Parameters:
section - the section name
name - the name of the property
value - the value of the property

getProperties

public abstract java.util.Properties getProperties(java.lang.String section)
Retrieve the Properties associated to the section.

REMINDER: The Properties object returned by this method should be a cloned version of the one stored by the Configurator. Thus, developers are free to do whatever he/she want on the returned Properties object without worrying screwing up other modules using the same Configurator.

If the developer need to set a property value that affect the whole system, the setProperty( action, name, value ) should be invoked instead.

Parameters:
section - the section name
Returns:
the Properties object associated to the section. If the specified section doesn't have any properties, it will return null.
See Also:
setProperty( String, String, String )

getSectionNames

public abstract java.util.Enumeration getSectionNames()
Retrieve all section names stored by this Configurator instance.

Returns:
An enumeration of all the section names under this configurator. If there is no property stored, this method will return an empty Enumeration object.

getPropertyNames

public abstract java.util.Enumeration getPropertyNames(java.lang.String section)
Get all property names stored under the specific section.

Parameters:
section - the section name.
Returns:
An enumeration of all the property names under the section. If the section name is invalid or there is no property stored, this method will return an empty Enumeration object.

clone

protected abstract Configurator clone(java.lang.String instanceName)
Create a cloned configurator with the same properties settings, but with the specified instanceName. This method should not be invoked by other object!


Nitido NiM 2.5 Java API

These JavaDoc pages are generated for release/nim_2_5-2.5.44

Copyright © 1999-2009 Nitido Inc.    Proprietary and Confidential.    All Rights Reserved.