Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.config
Class Config

    java.lang.Object
      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 `Choice`s.

Config does the following things:

- Provides a GUI independant API with which to create GUIs
- Stores a local store of settings
- Allows updates to the local store

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:

- Properties Files
- Resource Objects (J2SE 1.4)
- Network Sockets (see Remote)

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

- Permanent: This can be local file, a URI, or a remote server Data is stored here between invocations of the program.
- Application: This is the actual working copy of the data.
- Screen: This copy of the data is shown on screen whist a Config dialog box is showing.
- Local: This is required so that we can tell which bits of data have been changed in the screen data, and so that we can load data from disk to screen without involving the app.

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 PropertyChangeSupport` | `changeListeners` The set of property change listeners.
`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(Choice model)` Add a key/model pairing
`void` | `add(org.jdom.Document xmlconfig, ResourceBundle configResources)` Add the set of configuration options specified in the xml file.
`void` | `addConfigListener(ConfigListener li)` Add an Exception listener to the list of things wanting to know whenever we capture an Exception
`void` | `addPropertyChangeListener(PropertyChangeListener listener)` Add a PropertyChangeListener to the listener list.
`void` | `addPropertyChangeListener(String propertyName, PropertyChangeListener listener)` Add a PropertyChangeListener for a specific property.
`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)` Get the Choice for a given key
`static String` | `getLeaf(String key)` What is the Path of this key
`String` | `getLocal(String name)` Get a configuration Choice (by name).
`static String` | `getPath(String key)` What is the Path of this key
`Properties` | `getProperties()` Take the data in the local storage area and store it permanently
`String` | `getTitle()`
`Iterator` | `iterator()` The set of Choice that we are controlling
`void` | `localToApplication()` Take the data in the local storage area and copy it to the application.
`void` | `localToPermanent(URI uri)` Take the data in the local storage area and store it permanently, using the configured storage area.
`void` | `permanentToLocal(URI uri)` 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` | `removePropertyChangeListener(PropertyChangeListener listener)` Remove a PropertyChangeListener from the listener list.
`void` | `removePropertyChangeListener(String propertyName, PropertyChangeListener listener)` Remove a PropertyChangeListener for a specific property.
`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

### 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

### changeListeners

    protected PropertyChangeSupport changeListeners

  The set of property change listeners.

### listenerList

    protected EventListenerList listenerList

  The list of listeners

### log

    private static final Logger log

  The log stream

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(Choice model)

  Add a key/model pairing

  Parameters:
    `model` - The Choice model to map to its 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

### iterator

    public Iterator iterator()

  The set of Choice that we are controlling

  Returns:
    An enumeration over the choices

### getChoice

    public Choice getChoice(String key)

  Get the Choice for a given key

  Returns:
    the requested choice

### 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(URI uri)
                          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(URI uri)
                          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

### addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)

  Add a PropertyChangeListener to the listener list. The listener is registered for all properties.

  Parameters:
    `listener` - The PropertyChangeListener to be added

### removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)

  Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

  Parameters:
    `listener` - The PropertyChangeListener to be removed

### addPropertyChangeListener

    public void addPropertyChangeListener(String propertyName,
                                          PropertyChangeListener listener)

  Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property.

  Parameters:
    `propertyName` - The name of the property to listen on.
    `listener` - The PropertyChangeListener to be added

### removePropertyChangeListener

    public void removePropertyChangeListener(String propertyName,
                                             PropertyChangeListener listener)

  Remove a PropertyChangeListener for a specific property.

  Parameters:
    `propertyName` - The name of the property that was listened on.
    `listener` - The PropertyChangeListener to be removed

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2007
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD