com.monad.homerun.config
Interface ConfigContext


public interface ConfigContext

ConfigContext is a helper interface for using Config objects. It stores a 'context' or 'cursor' in the tree hierarchy from which a search for values commences - essentially traversing the tree, but hiding the underlying XML data structure from the user. The user can use a context object in 3 ways: (1) request a new context, via 'getContext', or 'getFeature' If the requested context is not found, an 'empty' context is returned. (2) request values from a context, which are either: (a) enabled status, via 'getEnabled' or 'isFeatureEnabled' If the status is not found, false is returned (b) a set of properties, via 'getProperties' or 'getPropertiesDefault' If there are no properties, an empty 'Properties' is returned (c) a named property value, via 'getProperty' If the property does not exist, null is returned (d) the set of feature names( just enabled or all ), via 'getFeatures' If there are no features, an empty String array is returned. (3) reset the context, via 'setContext' If the requested context cannot be constructed, the context goes empty The reset context is returned. The logic of these operations presupposes a specific structure of the XML document which obeys these rules. (1) at the document root, there are only 'containers' (2) a container's children may only be (a) 'features' or (b) containers (3) a feature must have a name attribute and its children must only be (a) 'properties' or (b) containers (4) a property must have 'type' and 'desc' attributes.


Method Summary
 java.lang.String getAttribute(java.lang.String attrName)
          Obtains a context attribute value
 boolean getBooleanAttr(java.lang.String attrName)
          Returns boolean value of context attribute
 ConfigContext getContext(java.lang.String contextPath)
          Returns arbitrary (container or feature) context from arbitrary context
 ConfigContext getFeature(java.lang.String feature)
          Returns feature context from a container context
 java.lang.String[] getFeatures(boolean enabledOnly)
          Returns list of features in this context
 Specifier[] getInputs(boolean isTemplate)
          Obtains a list of inputs
 java.util.Properties getNamedProperties()
          Obtains named context properties
 java.lang.String getNamedProperty(java.lang.String propName)
          Return the value of a named context property
 java.util.Properties getNamedPropertyAttributes(java.lang.String attribute)
          Returns named properties with given attribute
 java.util.Properties getProperties()
          Obtains context properties
 java.util.Properties getPropertiesDefault(java.lang.String feature)
          Returns deafault properties for a context feature
 java.lang.String getProperty(java.lang.String name)
          Obtains a context property value
 java.lang.String getPropertyAttr(java.lang.String propName, java.lang.String attrName)
          Obtains the value of a property attribute
 Specifier[] getSpecifiers(boolean isTemplate)
          Obtains a list of context specifiers
 boolean isEmpty()
          Returns whether context contains any values
 boolean isEnabled()
          Returns enabled status of this context
 boolean isFeatureEnabled(java.lang.String featureName)
          Returns enabled status of this context feature
 ConfigContext setContext(java.lang.String contextPath)
          Resets arbitrary context from arbitrary context
 ConfigContext setFeature(java.lang.String feature)
          Resets to feature context from a container context
 

Method Detail

isEmpty

boolean isEmpty()
Returns whether context contains any values

Returns:
true if context empty, else false

getContext

ConfigContext getContext(java.lang.String contextPath)
Returns arbitrary (container or feature) context from arbitrary context

Parameters:
contextPath - path to context
Returns:
context object

getFeature

ConfigContext getFeature(java.lang.String feature)
Returns feature context from a container context

Parameters:
feature - the feature name
Returns:
feature context object

setContext

ConfigContext setContext(java.lang.String contextPath)
Resets arbitrary context from arbitrary context

Parameters:
contextPath - path to context
Returns:
context object

setFeature

ConfigContext setFeature(java.lang.String feature)
Resets to feature context from a container context

Parameters:
feature - the feature name
Returns:
context object

getFeatures

java.lang.String[] getFeatures(boolean enabledOnly)
Returns list of features in this context

Parameters:
enabledOnly - if true, skip non-enable features
Returns:
list of feature names

isFeatureEnabled

boolean isFeatureEnabled(java.lang.String featureName)
Returns enabled status of this context feature

Parameters:
featureName - the feature name
Returns:
true if enabled, else false

isEnabled

boolean isEnabled()
Returns enabled status of this context

Returns:
true if enabled, else false

getBooleanAttr

boolean getBooleanAttr(java.lang.String attrName)
Returns boolean value of context attribute

Parameters:
attrName - the attribute name
Returns:
true if boolean and 'true'

getAttribute

java.lang.String getAttribute(java.lang.String attrName)
Obtains a context attribute value

Parameters:
attrName - the attribute name
Returns:
the attribute value

getProperty

java.lang.String getProperty(java.lang.String name)
Obtains a context property value

Parameters:
name - the property name
Returns:
the property value

getPropertyAttr

java.lang.String getPropertyAttr(java.lang.String propName,
                                 java.lang.String attrName)
Obtains the value of a property attribute

Parameters:
propName - the property name
attrName - the attribute name
Returns:
the attribute value

getSpecifiers

Specifier[] getSpecifiers(boolean isTemplate)
Obtains a list of context specifiers

Parameters:
isTemplate - if true, look only for template specifiers
Returns:
list of specifiers

getInputs

Specifier[] getInputs(boolean isTemplate)
Obtains a list of inputs

Parameters:
isTemplate - if true, look only for template inputs
Returns:
list of input specifiers

getProperties

java.util.Properties getProperties()
Obtains context properties

Returns:
the context properties

getNamedProperties

java.util.Properties getNamedProperties()
Obtains named context properties

Returns:
the context properties

getNamedPropertyAttributes

java.util.Properties getNamedPropertyAttributes(java.lang.String attribute)
Returns named properties with given attribute

Parameters:
attribute - attribute name
Returns:
the context properties

getNamedProperty

java.lang.String getNamedProperty(java.lang.String propName)
Return the value of a named context property

Parameters:
propName - the property name
Returns:
the property value

getPropertiesDefault

java.util.Properties getPropertiesDefault(java.lang.String feature)
Returns deafault properties for a context feature

Parameters:
feature - the feature name
Returns:
the context properties


Copyright © 2006-2009 Richard Rodgers. All Rights Reserved.