com.arsdigita.initializer
Class Configuration

java.lang.Object
  extended bycom.arsdigita.initializer.Configuration

public class Configuration
extends Object

This class is used by the initialization system to pass configuration parameters to an initializer. Every initializer should contain a member variable with exactly one instance of this class. The initializer should instantiate this class in the constructor and set the types and optionally set default values for each parameter the initializer requires.

  public class MyInitializer implements Initializer {

      Configuration m_config = new Configuration();

      public MyInitializer() throws InitializationException {
          m_config.initParameter("stringParam", "This is a usage string.",
                                 String.class,"This is a string.");
          m_config.initParameter("intParam",
                                 "Please enter a value for the intParam.")
          m_config.initParameter("listParam", "Should be a list.",
                                 java.util.List.class, new ArrayList());
      }

      public Configuration getConfiguration() {
          return m_config;
      }

      public void startup() {
          // Run startup code here.
      }

      public void shutdown() {
          // Run shutdown code here.
      }

  }
  

Version:
$Revision: #9 $ $Date: 2004/04/07 $
Author:
rhs@mit.edu

Field Summary
static String versionId
           
 
Constructor Summary
Configuration()
           
 
Method Summary
 Object getParameter(String name)
          Returns the parameter value for the parameter specified by name.
 Set getParameterNames()
          Returns the legal parameter names for this Configuration object.
 boolean hasParameter(String name)
          Returns true if this configuration has the specified parameter.
 void initParameter(String name, String usage, Class type)
          Initializes the parameter, passing in null as the default value.
 void initParameter(String name, String usage, Class type, Object defaultValue)
          Initializes the parameter to the default value.
 void setParameter(String name, Object value)
          Sets the parameter specified by name to the value
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Method Detail

initParameter

public void initParameter(String name,
                          String usage,
                          Class type,
                          Object defaultValue)
                   throws InitializationException
Initializes the parameter to the default value.

Parameters:
name - The parameter name.
usage - Documentation on the parameter usage.
type - The parameter type.
defaultValue - The parameter default value.
Throws:
InitializationException

initParameter

public void initParameter(String name,
                          String usage,
                          Class type)
                   throws InitializationException
Initializes the parameter, passing in null as the default value.

Parameters:
name - The parameter name.
usage - Documentation on the parameter usage.
type - The parameter type.
Throws:
InitializationException

setParameter

public void setParameter(String name,
                         Object value)
                  throws InitializationException
Sets the parameter specified by name to the value

Parameters:
name - The parameter name.
value - The parameter value.
Throws:
InitializationException

getParameter

public Object getParameter(String name)
                    throws InitializationException
Returns the parameter value for the parameter specified by name.

Parameters:
name - The parameter name.
Returns:
The parameter value.
Throws:
InitializationException

hasParameter

public boolean hasParameter(String name)
Returns true if this configuration has the specified parameter.

Parameters:
name - The parameter.
Returns:
True if the configuration contains the parameter, false otherwise.

getParameterNames

public Set getParameterNames()
Returns the legal parameter names for this Configuration object.


toString

public String toString()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC