consciouscode.seedling.config.properties
Class PropertiesConfigResource

java.lang.Object
  extended by consciouscode.seedling.config.properties.PropertiesConfigResource
All Implemented Interfaces:
ConfigResource

public class PropertiesConfigResource
extends Object
implements ConfigResource

A configuration resource stored as a .properties file. The PropertiesConfigLoader provides a default evaluator, but an individual resource may reconfigure that via the .evaluator meta-property.


Field Summary
static String EVALUATOR_METAPROPERTY
          Names the meta-property that is used to configure the resource's ConfigEvaluator.
 
Constructor Summary
PropertiesConfigResource(String identifier, Properties properties, PropertiesConfigEvaluator defaultEvaluator)
           
 
Method Summary
 ConfigEvaluator getEvaluator(NodeReference location)
          Returns the evaluator being used by this resource.
 String getIdentifier()
          Returns a string identifying this resource, for use in messages.
 Properties getProperties()
          Gets the contents of this config resource, as a Java Properties collection.
 String getProperty(String property)
          Returns the unevaluated text of a specified property, or null if no value is assigned by this resource.
 Resource getResource()
          Gets the underlying resource from which this configuration is loaded.
 void setIdentifier(String id)
           
 String toString()
           
 void writeConfiguration(Writer out)
          Prints the content of this resource to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EVALUATOR_METAPROPERTY

public static final String EVALUATOR_METAPROPERTY
Names the meta-property that is used to configure the resource's ConfigEvaluator. Its value must be a full path to an evaluator.

See Also:
Constant Field Values
Constructor Detail

PropertiesConfigResource

public PropertiesConfigResource(String identifier,
                                Properties properties,
                                PropertiesConfigEvaluator defaultEvaluator)
Parameters:
identifier - identifies this resource; may be null.
properties - must not be null.
defaultEvaluator - must not be null.
Method Detail

getResource

public Resource getResource()
Description copied from interface: ConfigResource
Gets the underlying resource from which this configuration is loaded.

Specified by:
getResource in interface ConfigResource
Returns:
may be null.

getIdentifier

public String getIdentifier()
Description copied from interface: ConfigResource
Returns a string identifying this resource, for use in messages.

Specified by:
getIdentifier in interface ConfigResource
Returns:
an identifying string, or null if one is not available.

setIdentifier

public void setIdentifier(String id)

getEvaluator

public ConfigEvaluator getEvaluator(NodeReference location)
                             throws ConfigurationException
Description copied from interface: ConfigResource
Returns the evaluator being used by this resource. The evaluator depends on the kind of resource, and possibly on the contents of the resource as well.

Specified by:
getEvaluator in interface ConfigResource
Parameters:
location - identifies the node being configured.
Returns:
the evaluator for this resource; not null.
Throws:
ConfigurationException - if no evaluator could be located.

writeConfiguration

public void writeConfiguration(Writer out)
                        throws IOException
Description copied from interface: ConfigResource
Prints the content of this resource to a stream.

Specified by:
writeConfiguration in interface ConfigResource
Parameters:
out - the stream to get the configuration content.
Throws:
IOException - if it's thrown by out.

getProperties

public Properties getProperties()
Gets the contents of this config resource, as a Java Properties collection.

Returns:
not null.

getProperty

public String getProperty(String property)
Returns the unevaluated text of a specified property, or null if no value is assigned by this resource.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001–2012 Todd V. Jonker. All Rights Reserved.