org.nakedobjects.metamodel.config
Interface NakedObjectConfiguration

All Superinterfaces:
DebugInfo, Injectable
All Known Implementing Classes:
PropertiesConfiguration

public interface NakedObjectConfiguration
extends DebugInfo, Injectable

(Mostly!) immutable set of properties representing the configuration of the running system.

The NakedObjectConfiguration is one part of a mutable/immutable pair pattern (cf String and StringBuilder). What this means is, as components are loaded they can discover their own configuration resources. These are added to ConfigurationBuilder.

Thus the NakedObjectConfiguration held by different components may vary, but with each being a possible superset of the previous.

TODO: we should make this strictly immutable by removing the add(String, String) method.


Method Summary
 void add(java.lang.String name, java.lang.String value)
          Adds a name-value pair to the list of properties.
 NakedObjectConfiguration createSubset(java.lang.String prefix)
          Creates a new NakedObjectConfiguration containing the properties starting with the specified prefix.
 boolean getBoolean(java.lang.String name)
          Gets the boolean value for the specified name where no value or 'on' will result in true being returned; anything gives false.
 boolean getBoolean(java.lang.String name, boolean defaultValue)
          Gets the boolean value for the specified name.
 java.awt.Color getColor(java.lang.String name)
          Gets the color for the specified name.
 java.awt.Color getColor(java.lang.String name, java.awt.Color defaultValue)
          Gets the color for the specified name.
 java.awt.Font getFont(java.lang.String name)
          Gets the font for the specified name.
 java.awt.Font getFont(java.lang.String name, java.awt.Font defaultValue)
          Gets the font for the specified name.
 int getInteger(java.lang.String name)
          Gets the number value for the specified name.
 int getInteger(java.lang.String name, int defaultValue)
          Gets the number value for the specified name.
 java.lang.String[] getList(java.lang.String name)
          Returns a list of entries for the single configuration property with the specified name.
 NakedObjectConfiguration getProperties(java.lang.String withPrefix)
          Creates a new NakedObjectConfiguration containing the properties starting with the specified prefix.
 ResourceStreamSource getResourceStreamSource()
          The ResourceStreamSource that was used to build this configuration.
 java.lang.String getString(java.lang.String name)
          Returns the configuration property with the specified name.
 java.lang.String getString(java.lang.String name, java.lang.String defaultValue)
           
 boolean hasProperty(java.lang.String name)
           
 boolean isEmpty()
           
 java.util.Enumeration<java.lang.String> propertyNames()
           
 int size()
           
 
Methods inherited from interface org.nakedobjects.metamodel.commons.debug.DebugInfo
debugData, debugTitle
 
Methods inherited from interface org.nakedobjects.metamodel.commons.component.Injectable
injectInto
 

Method Detail

add

void add(java.lang.String name,
         java.lang.String value)
Adds a name-value pair to the list of properties. If the named property already exists then the specified value replaces the existing one.


createSubset

NakedObjectConfiguration createSubset(java.lang.String prefix)
Creates a new NakedObjectConfiguration containing the properties starting with the specified prefix. The names of the new properties will have the prefixed stripped. This is similar to the getProperties(String) method, except the property names have their prefixes removed.

See Also:
getProperties(String)

getBoolean

boolean getBoolean(java.lang.String name)
Gets the boolean value for the specified name where no value or 'on' will result in true being returned; anything gives false. If no boolean property is specified with this name then false is returned.

Parameters:
name - the property name

getBoolean

boolean getBoolean(java.lang.String name,
                   boolean defaultValue)
Gets the boolean value for the specified name. If no property is specified with this name then the specified default boolean value is returned.

Parameters:
name - the property name
defaultValue - the value to use as a default

getColor

java.awt.Color getColor(java.lang.String name)
Gets the color for the specified name. If no color property is specified with this name then null is returned.

Parameters:
name - the property name

getColor

java.awt.Color getColor(java.lang.String name,
                        java.awt.Color defaultValue)
Gets the color for the specified name. If no color property is specified with this name then the specified default color is returned.

Parameters:
name - the property name
defaultValue - the value to use as a default

getFont

java.awt.Font getFont(java.lang.String name)
Gets the font for the specified name. If no font property is specified with this name then null is returned.

Parameters:
name - the property name

getFont

java.awt.Font getFont(java.lang.String name,
                      java.awt.Font defaultValue)
Gets the font for the specified name. If no font property is specified with this name then the specified default font is returned.

Parameters:
name - the property name
defaultValue - the color to use as a default

getList

java.lang.String[] getList(java.lang.String name)
Returns a list of entries for the single configuration property with the specified name.

If there is no matching property then returns an empty array.


getInteger

int getInteger(java.lang.String name)
Gets the number value for the specified name. If no property is specified with this name then 0 is returned.

Parameters:
name - the property name

getInteger

int getInteger(java.lang.String name,
               int defaultValue)
Gets the number value for the specified name. If no property is specified with this name then the specified default number value is returned.

Parameters:
name - the property name
defaultValue - the value to use as a default

getProperties

NakedObjectConfiguration getProperties(java.lang.String withPrefix)
Creates a new NakedObjectConfiguration containing the properties starting with the specified prefix. The names of the properties in the copy are the same as in the original, ie the prefix is not removed. This is similar to the createSubset(String) method except the names of the properties are not altered when copied.

See Also:
createSubset(String)

getString

java.lang.String getString(java.lang.String name)
Returns the configuration property with the specified name. If there is no matching property then null is returned.


getString

java.lang.String getString(java.lang.String name,
                           java.lang.String defaultValue)

hasProperty

boolean hasProperty(java.lang.String name)

isEmpty

boolean isEmpty()

propertyNames

java.util.Enumeration<java.lang.String> propertyNames()

size

int size()

getResourceStreamSource

ResourceStreamSource getResourceStreamSource()
The ResourceStreamSource that was used to build this configuration.

This replaces the old rootPath() method.

See Also:
ConfigurationBuilder.getResourceStreamSource()


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.