edu.cmu.sphinx.util.props
Class PropertySheet

java.lang.Object
  extended by edu.cmu.sphinx.util.props.PropertySheet
All Implemented Interfaces:
java.lang.Cloneable

public class PropertySheet
extends java.lang.Object
implements java.lang.Cloneable

A property sheet which defines a collection of properties for a single component in the system.

Author:
Holger Brandl

Nested Class Summary
static class PropertySheet.PropertyType
           
 
Field Summary
static java.lang.String COMP_LOG_LEVEL
           
 
Constructor Summary
PropertySheet(java.lang.Class<? extends Configurable> confClass, java.lang.String name, ConfigurationManager cm, RawPropertyData rpd)
           
PropertySheet(Configurable configurable, java.lang.String name, RawPropertyData rpd, ConfigurationManager ConfigurationManager)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if two property sheet define the same object in terms of configuration.
 java.lang.Boolean getBoolean(java.lang.String name)
          Gets the value associated with this name
 Configurable getComponent(java.lang.String name)
          Gets a component associated with the given parameter name
 java.lang.Class<? extends Configurable> getComponentClass(java.lang.String propName)
          Returns the class of of a registered component property without instantiating it.
 java.util.List<? extends Configurable> getComponentList(java.lang.String name)
          Gets a list of components associated with the given parameter name
 java.lang.Class<? extends Configurable> getConfigurableClass()
          Returns the class of the owner configurable of this property sheet.
 double getDouble(java.lang.String name)
          Gets the value associated with this name
 float getFloat(java.lang.String name)
          Gets the value associated with this name
 java.lang.String getInstanceName()
           
 int getInt(java.lang.String name)
          Gets the value associated with this name
 java.util.logging.Logger getLogger()
          Returns a logger to use for this configurable component.
 Configurable getOwner()
          Returns the owner of this property sheet.
 S4PropWrapper getProperty(java.lang.String name, java.lang.Class propertyClass)
          Returns the property names name which is still wrapped into the annotation instance.
 java.lang.Object getRaw(java.lang.String name)
          Gets the raw value associated with this name
 java.lang.Object getRawNoReplacement(java.lang.String name)
          Gets the raw value associated with this name, no global symbol replacement is performed.
 java.util.Collection<java.lang.String> getRegisteredProperties()
          Returns the names of registered properties of this PropertySheet object.
 java.lang.String getString(java.lang.String name)
          Gets the value associated with this name
 PropertySheet.PropertyType getType(java.lang.String propName)
          Returns the type of the given property.
 java.util.Collection<java.lang.String> getUndefinedMandatoryProps()
          Returns the set of all component properties which were tagged as mandatory but which are not set (or no default value is given).
 boolean isInstanciated()
          Returns true if the owner of this property sheet is already instanciated.
static void processAnnotations(PropertySheet propertySheet, java.lang.Class<? extends Configurable> configurable)
          use annotation based class parsing to detect the configurable properties of a Configurable-class
 void setBoolean(java.lang.String name, java.lang.Boolean value)
          Sets the given property to the given name
 void setCM(ConfigurationManager cm)
           
 void setComponent(java.lang.String name, java.lang.String cmName, Configurable value)
          Sets the given property to the given name
 void setComponentList(java.lang.String name, java.util.List<java.lang.String> valueNames, java.util.List<Configurable> value)
          Sets the given property to the given name
 void setDouble(java.lang.String name, double value)
          Sets the given property to the given name
 void setInstanceName(java.lang.String newInstanceName)
           
 void setInt(java.lang.String name, int value)
          Sets the given property to the given name
 void setString(java.lang.String name, java.lang.String value)
          Sets the given property to the given name
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMP_LOG_LEVEL

public static final java.lang.String COMP_LOG_LEVEL
See Also:
Constant Field Values
Constructor Detail

PropertySheet

public PropertySheet(Configurable configurable,
                     java.lang.String name,
                     RawPropertyData rpd,
                     ConfigurationManager ConfigurationManager)

PropertySheet

public PropertySheet(java.lang.Class<? extends Configurable> confClass,
                     java.lang.String name,
                     ConfigurationManager cm,
                     RawPropertyData rpd)
Method Detail

getProperty

public S4PropWrapper getProperty(java.lang.String name,
                                 java.lang.Class propertyClass)
                          throws PropertyException
Returns the property names name which is still wrapped into the annotation instance.

Throws:
PropertyException

getString

public java.lang.String getString(java.lang.String name)
                           throws PropertyException
Gets the value associated with this name

Parameters:
name - the name
Returns:
the value
Throws:
PropertyException

getInt

public int getInt(java.lang.String name)
           throws PropertyException
Gets the value associated with this name

Parameters:
name - the name
Returns:
the value
Throws:
PropertyException - if the named property is not of this type

getFloat

public float getFloat(java.lang.String name)
               throws PropertyException
Gets the value associated with this name

Parameters:
name - the name
Returns:
the value
Throws:
PropertyException - if the named property is not of this type

getDouble

public double getDouble(java.lang.String name)
                 throws PropertyException
Gets the value associated with this name

Parameters:
name - the name
Returns:
the value
Throws:
PropertyException - if the named property is not of this type

getBoolean

public java.lang.Boolean getBoolean(java.lang.String name)
                             throws PropertyException
Gets the value associated with this name

Parameters:
name - the name
Returns:
the value
Throws:
PropertyException - if the named property is not of this type

getComponent

public Configurable getComponent(java.lang.String name)
                          throws PropertyException
Gets a component associated with the given parameter name

Parameters:
name - the parameter name
Returns:
the component associated with the name
Throws:
PropertyException - if the component does not exist or is of the wrong type.

getComponentClass

public java.lang.Class<? extends Configurable> getComponentClass(java.lang.String propName)
Returns the class of of a registered component property without instantiating it.


getComponentList

public java.util.List<? extends Configurable> getComponentList(java.lang.String name)
                                                        throws InternalConfigurationException
Gets a list of components associated with the given parameter name

Parameters:
name - the parameter name
Returns:
the component associated with the name
Throws:
PropertyException - if the component does not exist or is of the wrong type.
InternalConfigurationException

getInstanceName

public java.lang.String getInstanceName()

setInstanceName

public void setInstanceName(java.lang.String newInstanceName)

isInstanciated

public boolean isInstanciated()
Returns true if the owner of this property sheet is already instanciated.


getOwner

public Configurable getOwner()
Returns the owner of this property sheet. In most cases this will be the configurable instance which was instrumented by this property sheet.


getUndefinedMandatoryProps

public java.util.Collection<java.lang.String> getUndefinedMandatoryProps()
Returns the set of all component properties which were tagged as mandatory but which are not set (or no default value is given).


getConfigurableClass

public java.lang.Class<? extends Configurable> getConfigurableClass()
Returns the class of the owner configurable of this property sheet.


setString

public void setString(java.lang.String name,
                      java.lang.String value)
               throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
Throws:
PropertyException

setInt

public void setInt(java.lang.String name,
                   int value)
            throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
value - the value for the property
Throws:
PropertyException

setDouble

public void setDouble(java.lang.String name,
                      double value)
               throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
value - the value for the property
Throws:
PropertyException

setBoolean

public void setBoolean(java.lang.String name,
                       java.lang.Boolean value)
                throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
value - the value for the property
Throws:
PropertyException

setComponent

public void setComponent(java.lang.String name,
                         java.lang.String cmName,
                         Configurable value)
                  throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
cmName - the name of the configurable within the configuration manager (required for serialization only)
value - the value for the property
Throws:
PropertyException

setComponentList

public void setComponentList(java.lang.String name,
                             java.util.List<java.lang.String> valueNames,
                             java.util.List<Configurable> value)
                      throws PropertyException
Sets the given property to the given name

Parameters:
name - the simple property name
valueNames - the list of names of the configurables within the configuration manager (required for serialization only)
value - the value for the property
Throws:
PropertyException

getRaw

public java.lang.Object getRaw(java.lang.String name)
Gets the raw value associated with this name

Parameters:
name - the name
Returns:
the value as an object (it could be a String or a String[] depending upon the property type)

getRawNoReplacement

public java.lang.Object getRawNoReplacement(java.lang.String name)
Gets the raw value associated with this name, no global symbol replacement is performed.

Parameters:
name - the name
Returns:
the value as an object (it could be a String or a String[] depending upon the property type)

getType

public PropertySheet.PropertyType getType(java.lang.String propName)
Returns the type of the given property.


getLogger

public java.util.logging.Logger getLogger()
Returns a logger to use for this configurable component. The logger can be configured with the property: 'logLevel' - The default logLevel value is defined (within the xml configuration file by the global property 'defaultLogLevel' (which defaults to WARNING).

implementation note: the logger became configured within the constructor of the parenting configuration manager.

Returns:
the logger for this component
Throws:
PropertyException - if an error occurs

getRegisteredProperties

public java.util.Collection<java.lang.String> getRegisteredProperties()
Returns the names of registered properties of this PropertySheet object.


setCM

public void setCM(ConfigurationManager cm)

equals

public boolean equals(java.lang.Object obj)
Returns true if two property sheet define the same object in terms of configuration. The owner (and the parent configuration manager) are not expected to be the same.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

processAnnotations

public static void processAnnotations(PropertySheet propertySheet,
                                      java.lang.Class<? extends Configurable> configurable)
use annotation based class parsing to detect the configurable properties of a Configurable-class

Parameters:
propertySheet - of type PropertySheet
configurable - of type Class