|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.util.parameter.AbstractParameterContext
com.arsdigita.runtime.AbstractConfig
AbstractConfig is a base class for groups of customizable
configuration parameters
. A
CCM Developer wishing to add a new group of configuration
parameters to his application will extend this class and provide a
public noargs constructer that registers his parameters with the
superclass. For example:
When this pattern is followed, the resulting subclass of abstract config may be used by developers writing java code to access the values of customizable configuration parameters in a convenient and type safe manner. In addition, the very same class is also usable by the ccm configuration tools to allow customization and validation of the new parameters.package com.arsdigita.exampleApp; public final class ExampleConfig extends AbstractConfig { private Parameter m_string = new StringParameter ("example.string", Parameter.OPTIONAL, "default"); private Parameter m_integer = new IntegerParameter ("example.integer", Parameter.OPTIONAL, new Integer(0)); private Parameter m_boolean = new BooleanParameter ("example.boolean", Parameter.OPTIONAL, Boolean.TRUE); public ExampleConfig() { register(m_string); register(m_integer); register(m_boolean); loadInfo(); } public String getString() { return (String) get(m_string); } public int getInteger() { return ((Integer) get(m_integer)).intValue(); } public boolean getBoolean() { return Boolean.TRUE.equals(get(m_boolean)); } }
Field Summary | |
static String |
versionId
|
Constructor Summary | |
protected |
AbstractConfig()
Default constructor for subclasses. |
Method Summary | |
ErrorList |
load()
Invokes the load(ErrorList) method with a new and
empty ErrorList for accumulating errors, and returns that
ErrorList. |
void |
load(ErrorList errors)
Loads this AbstractConfig object with values from the default configuration registry. |
ErrorList |
load(String resource)
Deprecated. Use @{link #load()} instead. |
ErrorList |
require(String resource)
Deprecated. Use @{link #load()} instead. |
Methods inherited from class com.arsdigita.util.parameter.AbstractParameterContext |
get, get, getParameters, load, load, loadInfo, register, save, set, validate, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
protected AbstractConfig()
Method Detail |
public final void load(ErrorList errors)
errors
ErrorList. This method should not be
called from the constructor of a config object since the ccm
configuration tools need to be able to construct empty config
objects.
errors
- The ErrorList used to record errors during
unmarshaling and loading.ConfigRegistry
public final ErrorList load()
load(ErrorList)
method with a new and
empty ErrorList for accumulating errors, and returns that
ErrorList. This method can be used in combination with the
ErrorList.check()
method to load and assert that this
configuration object is valid in one simple idiom. For example:
ExampleConfig conf = new ExampleConfig(); conf.load().check(); ...
load(ErrorList)
public final ErrorList load(String resource)
public final ErrorList require(String resource)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |