edu.cmu.sphinx.util.props
Class ConfigurationManagerUtils

java.lang.Object
  extended by edu.cmu.sphinx.util.props.ConfigurationManagerUtils

public final class ConfigurationManagerUtils
extends java.lang.Object

Some static utitity methods which ease the handling of system configurations.

Author:
Holger Brandl

Field Summary
static java.lang.String CM_FILE_SUFFIX
          The default file suffix of configuration files.
static java.lang.String GLOBAL_COMMON_LOGLEVEL
          A common property (used by all components) that sets the log level for the component.
 
Method Summary
static void configureLogger(ConfigurationManager cm)
          Configure the logger
static void configureLogger(java.util.logging.Logger logger)
          Configures a logger to use the sphinx4-log-formatter.
static void dumpPropStructure(ConfigurationManager cm)
           
static void editConfig(ConfigurationManager cm, java.lang.String name)
           
static java.util.Map<java.lang.String,java.lang.String> fixDuplicateNames(ConfigurationManager baseCM, ConfigurationManager subCM)
          This method will automatically rename all components of subCM for which there is component named the same in the baseCM .
static java.lang.String getLogPrefix(ConfigurationManager cm)
           
static java.util.Collection<java.lang.String> getNonInstaniatedComps(ConfigurationManager cm)
          Returns the not yet instantiated components registered to this configuration manager.
static ConfigurationManager getPropertyManager(PropertySheet ps)
          Why do we need this method?
static java.net.URL getResource(java.lang.String name, PropertySheet ps)
          Gets a resource associated with the given parameter name given an property sheet.
static java.net.URL getURL(java.io.File file)
           
static boolean isDerivedClass(java.lang.Class aClass, java.lang.Class possibleParent)
           
static boolean isImplementingInterface(java.lang.Class aClass, java.lang.Class interfaceClass)
           
static boolean isSubClass(java.lang.Class aClass, java.lang.Class possibleSuperclass)
           
static java.util.Map<java.lang.String,java.util.List<PropertySheet>> listAllsPropNames(ConfigurationManager cm)
          Returns a map of all component-properties of this config-manager (including their associeted property-sheets.
static void save(ConfigurationManager cm, java.io.File cmLocation)
           
static void setProperty(ConfigurationManager cm, java.lang.String propName, java.lang.String propValue)
          Attempts to set the value of an arbitrary component-property.
static void showConfig(ConfigurationManager cm)
          Shows the current configuration
static void showConfig(ConfigurationManager cm, java.lang.String name)
          Show the configuration for the compnent with the given name
static java.lang.String stripGlobalSymbol(java.lang.String symbol)
          Strips the ${ and } off of a global symbol of the form ${symbol}.
static java.lang.String toXML(ConfigurationManager cm)
          converts a configuration manager instance into a xml-string .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_COMMON_LOGLEVEL

public static final java.lang.String GLOBAL_COMMON_LOGLEVEL
A common property (used by all components) that sets the log level for the component.

See Also:
Constant Field Values

CM_FILE_SUFFIX

public static final java.lang.String CM_FILE_SUFFIX
The default file suffix of configuration files.

See Also:
Constant Field Values
Method Detail

stripGlobalSymbol

public static java.lang.String stripGlobalSymbol(java.lang.String symbol)
Strips the ${ and } off of a global symbol of the form ${symbol}.

Parameters:
symbol - the symbol to strip
Returns:
the stripped symbol

editConfig

public static void editConfig(ConfigurationManager cm,
                              java.lang.String name)

getLogPrefix

public static java.lang.String getLogPrefix(ConfigurationManager cm)

configureLogger

public static void configureLogger(ConfigurationManager cm)
Configure the logger


configureLogger

public static void configureLogger(java.util.logging.Logger logger)
Configures a logger to use the sphinx4-log-formatter.


fixDuplicateNames

public static java.util.Map<java.lang.String,java.lang.String> fixDuplicateNames(ConfigurationManager baseCM,
                                                                                 ConfigurationManager subCM)
This method will automatically rename all components of subCM for which there is component named the same in the baseCM .

Note: This is ie. required when merging two system configurations into one.

Returns:
A map which maps all renamed component names to their new names.

toXML

public static java.lang.String toXML(ConfigurationManager cm)
converts a configuration manager instance into a xml-string .

Note: This methods will not instantiate configurables.


save

public static void save(ConfigurationManager cm,
                        java.io.File cmLocation)

showConfig

public static void showConfig(ConfigurationManager cm)
Shows the current configuration


showConfig

public static void showConfig(ConfigurationManager cm,
                              java.lang.String name)
Show the configuration for the compnent with the given name

Parameters:
name - the component name

getResource

public static java.net.URL getResource(java.lang.String name,
                                       PropertySheet ps)
                                throws PropertyException
Gets a resource associated with the given parameter name given an property sheet.

Parameters:
name - the parameter name
ps - The property sheet which contains the property
Returns:
the resource associated with the name or NULL if it doesn't exist.
Throws:
PropertyException - if the resource cannot be found

isDerivedClass

public static boolean isDerivedClass(java.lang.Class aClass,
                                     java.lang.Class possibleParent)
Returns:
true if aClass is either equal to poosibleParent, a subclass of it, or implements it if possibleParent is an interface.

isImplementingInterface

public static boolean isImplementingInterface(java.lang.Class aClass,
                                              java.lang.Class interfaceClass)

isSubClass

public static boolean isSubClass(java.lang.Class aClass,
                                 java.lang.Class possibleSuperclass)

getPropertyManager

public static ConfigurationManager getPropertyManager(PropertySheet ps)
Why do we need this method? The reason is, that we would like to avoid this method ot be part of the PropertySheet-API. In some circumstances it is nevertheless required to get access to the managing ConfigurationManager.


listAllsPropNames

public static java.util.Map<java.lang.String,java.util.List<PropertySheet>> listAllsPropNames(ConfigurationManager cm)
Returns a map of all component-properties of this config-manager (including their associeted property-sheets.


dumpPropStructure

public static void dumpPropStructure(ConfigurationManager cm)

setProperty

public static void setProperty(ConfigurationManager cm,
                               java.lang.String propName,
                               java.lang.String propValue)
Attempts to set the value of an arbitrary component-property. If the property-name is ambiguous with resepect to the given ConfiguratioManager an extended syntax (componentName->propName) can be used to acess the property.


getURL

public static java.net.URL getURL(java.io.File file)

getNonInstaniatedComps

public static java.util.Collection<java.lang.String> getNonInstaniatedComps(ConfigurationManager cm)
Returns the not yet instantiated components registered to this configuration manager.