public class Config extends Object implements Iterable<Choice>
Choice
s.
Config does the following things:
The GNU Lesser General Public License for details.
Modifier and Type | Field and Description |
---|---|
protected PropertyChangeSupport |
changeListeners
The set of property change listeners.
|
protected List<String> |
keys
The array that stores the keys
|
protected List<ConfigListener> |
listeners
The list of listeners
|
protected PropertyMap |
local
The set of local values
|
private static org.slf4j.Logger |
LOGGER
The log stream
|
protected List<Choice> |
models
The array that stores the models
|
protected String |
title
The name for dialog boxes and properties files
|
Modifier and Type | Method and Description |
---|---|
void |
add(Choice model)
Add a key/model pairing
|
void |
add(org.jdom2.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 removed.
|
Choice |
getChoice(String key)
Get the Choice for a given key
|
static String |
getLeaf(String key)
What is the last part of 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
|
PropertyMap |
getProperties()
Take the data in the local storage area and store it permanently.
|
String |
getTitle()
The name for the dialog boxes and properties files.
|
Iterator<Choice> |
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(PropertyMap prop)
Take the data stored permanently and copy it to the local storage area,
using the specified stream.
|
int |
size()
The number of Choices
|
protected String title
protected PropertyMap local
protected PropertyChangeSupport changeListeners
protected List<ConfigListener> listeners
private static final org.slf4j.Logger LOGGER
public Config(String title)
title
- The name for dialog boxes and properties filespublic String getTitle()
public void add(Choice model)
model
- The Choice model to map to its keypublic void add(org.jdom2.Document xmlconfig, ResourceBundle configResources)
xmlconfig
- The JDOM document to read.configResources
- contains the user level text for this configpublic void remove(String key)
key
- The name to killpublic Choice getChoice(String key)
key
- the key for the choicepublic int size()
public void setLocal(String name, String value)
name
- the key for the choicevalue
- the value for the choicepublic String getLocal(String name)
name
- the key for the choicepublic void applicationToLocal()
public void localToApplication()
public void setProperties(PropertyMap prop)
prop
- the set of properties to savepublic PropertyMap getProperties()
public void permanentToLocal(URI uri) throws IOException
uri
- the location of the permanent storageIOException
- if there was a problem getting the permanent config infopublic void localToPermanent(URI uri) throws IOException
uri
- the location of the permanent storageIOException
- if there was a problem storing the permanent config infopublic static String getPath(String key)
key
- the key of the propertypublic static String getLeaf(String key)
key
- the key of the propertypublic void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be addedpublic void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedpublic void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
propertyName
- The name of the property that was listened on.listener
- The PropertyChangeListener to be removedpublic void addConfigListener(ConfigListener li)
li
- The ConfigListener to be addedpublic void removeConfigListener(ConfigListener li)
li
- The ConfigListener to be removedprotected void fireChoiceAdded(String key, Choice model)
key
- the key of the choice that has been addedmodel
- the choice that was added