org.crosswire.common.config
Class Config

java.lang.Object
  extended by org.crosswire.common.config.Config

public class Config
extends Object

Config is the core part of the configuration system; it is simply a Collection of Choices.

Config does the following things:

Config does not attempt to make permanent copies of the config data because different apps may wish to store the data in different ways. Possible storage mechanisms include:

The Config class stored the current Choices, and moves the data between the various places that it is stored. There are 4 storage areas:

Author:
Joe Walker [joe at eireneh dot com]
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
protected  List keys
          The array that stores the keys
protected  EventListenerList listenerList
          The list of listeners
protected  Properties local
          The set of local values
private static Logger log
          The log stream
protected  List models
          The array that stores the models
protected  String title
          The name for dialog boxes and properties files
 
Constructor Summary
Config(String title)
          Config ctor
 
Method Summary
 void add(org.jdom.Document xmlconfig, ResourceBundle configResources)
          Add the set of configuration options specified in the xml file.
 void add(String key, Choice model)
          Add a key/model pairing
 void addConfigListener(ConfigListener li)
          Add an Exception listener to the list of things wanting to know whenever we capture an Exception
 void applicationToLocal()
          Take the data in the application and copy it to the local storage area.
protected  void fireChoiceAdded(String key, Choice model)
          A Choice got added
protected  void fireChoiceRemoved(String key, Choice model)
          A Choice got added
 Choice getChoice(String key)
          Step through the keys
static String getLeaf(String key)
          What is the Path of this key
 String getLocal(String name)
          Get a configuration Choice (by name).
 Iterator getNames()
          The set of Choice Names that we are controlling
static String getPath(String key)
          What is the Path of this key
 Iterator getPaths()
          The set of Choice Names that we are controlling
 Properties getProperties()
          Take the data in the local storage area and store it permanently
 String getTitle()
           
 void localToApplication()
          Take the data in the local storage area and copy it to the application.
 void localToPermanent(URL url)
          Take the data in the local storage area and store it permanently, using the configured storage area.
 void permanentToLocal(URL url)
          Take the data stored permanently and copy it to the local storage area, using the configured storage area
 void remove(String key)
          Remove a key/model pairing
 void removeConfigListener(ConfigListener li)
          Remove an Exception listener from the list of things wanting to know whenever we capture an Exception
 void setLocal(String name, String value)
          Set a configuration Choice (by name) to a new value.
 void setProperties(Properties prop)
          Take the data stored permanetly and copy it to the local storage area, using the specified stream
 int size()
          The number of Choices
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
The log stream


title

protected String title
The name for dialog boxes and properties files


keys

protected List keys
The array that stores the keys


models

protected List models
The array that stores the models


local

protected Properties local
The set of local values


listenerList

protected EventListenerList listenerList
The list of listeners

Constructor Detail

Config

public Config(String title)
Config ctor

Parameters:
title - The name for dialog boxes and properties files
Method Detail

getTitle

public String getTitle()

add

public void add(String key,
                Choice model)
Add a key/model pairing

Parameters:
key - The new name
model - The Field model to map to the key

add

public void add(org.jdom.Document xmlconfig,
                ResourceBundle configResources)
Add the set of configuration options specified in the xml file.

Parameters:
xmlconfig - The JDOM document to read.
configResources - contains the user level text for this config

remove

public void remove(String key)
Remove a key/model pairing

Parameters:
key - The name to kill

getPaths

public Iterator getPaths()
The set of Choice Names that we are controlling

Returns:
An enumeration over the keys

getNames

public Iterator getNames()
The set of Choice Names that we are controlling

Returns:
An enumeration over the keys

getChoice

public Choice getChoice(String key)
Step through the keys

Returns:
an enum of the keys

size

public int size()
The number of Choices

Returns:
The number of Choices

setLocal

public void setLocal(String name,
                     String value)
Set a configuration Choice (by name) to a new value. This method is only of use to classes displaying config information


getLocal

public String getLocal(String name)
Get a configuration Choice (by name). This method is only of use to classes displaying config information


applicationToLocal

public void applicationToLocal()
Take the data in the application and copy it to the local storage area.


localToApplication

public void localToApplication()
Take the data in the local storage area and copy it to the application.


setProperties

public void setProperties(Properties prop)
Take the data stored permanetly and copy it to the local storage area, using the specified stream


getProperties

public Properties getProperties()
Take the data in the local storage area and store it permanently


permanentToLocal

public void permanentToLocal(URL url)
                      throws IOException
Take the data stored permanently and copy it to the local storage area, using the configured storage area

Throws:
IOException

localToPermanent

public void localToPermanent(URL url)
                      throws IOException
Take the data in the local storage area and store it permanently, using the configured storage area.

Throws:
IOException

getPath

public static String getPath(String key)
What is the Path of this key


getLeaf

public static String getLeaf(String key)
What is the Path of this key


addConfigListener

public void addConfigListener(ConfigListener li)
Add an Exception listener to the list of things wanting to know whenever we capture an Exception


removeConfigListener

public void removeConfigListener(ConfigListener li)
Remove an Exception listener from the list of things wanting to know whenever we capture an Exception


fireChoiceAdded

protected void fireChoiceAdded(String key,
                               Choice model)
A Choice got added


fireChoiceRemoved

protected void fireChoiceRemoved(String key,
                                 Choice model)
A Choice got added


Copyright ยจ 2003-2006