qflib 0.98.1

de.qfs.lib.config
Class Configurator

java.lang.Object
  |
  +--de.qfs.lib.config.Configurator

public class Configurator
extends java.lang.Object

A Configurator is a composite, holding Configurables and other Configurators, thus building a hierarchy which is used to determine the names under which the Configurables are registered with the Configuration. This way it is possible to register similar Configurables under different names, without them having to know anything about their place in the hierarchy.

A Configurator is especially useful when building a reusable GUI component that has various subcomponents requiring confguration. All the nested Configurables can be collected under one Configurator hierarchy, that can be made accessible through the components interface. The user of the component can the register all Configurables at once.

Version:
$Revision: 1.10 $
Author:
Gregor Schmid

Constructor Summary
Configurator(java.lang.String name)
          Create a new Configurator.
 
Method Summary
 void add(Configurable configurable)
          Add a Configurable to the Configurator's children.
 void add(Configurator configurator)
          Add a Configurator to the Configurator's children.
 Configurator copy()
          Create a deep copy of the Configurator hierarchy rooted at this Configurator.
 java.lang.String getName()
          Get the name of the Configurator.
 boolean isRegistered()
          Query whether the Configurator is registered with the Configuration.
 boolean isRegistered(Configuration configuration)
          Query whether the Configurator is registered with a special Configuration.
 void register()
          Register the children of the Configurator with the Configuration.
 void register(Configuration configuration)
          Register the children of the Configurator with a special Configuration.
 void remove(Configurable configurable, boolean keepValues)
          Remove a Configurable from the Configurator's children.
 void remove(Configurator configurator, boolean keepValues)
          Remove a Configurator from the Configurator's children.
protected  void setParent(Configurator parent)
          Set the Configurator's parent.
 void unregister(boolean keepValues)
          Unregister the Configurator's children from the Configuration.
 void unregister(Configuration configuration, boolean keepValues)
          Unregister the Configurator's children from a special Configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurator

public Configurator(java.lang.String name)
Create a new Configurator.
Parameters:
name - The name of the Configurator.
Method Detail

add

public void add(Configurable configurable)
Add a Configurable to the Configurator's children. If the receiver was already registered with the Configuration, the Configurable is registered as well.
Parameters:
configurable - The Configurable to add.

add

public void add(Configurator configurator)
Add a Configurator to the Configurator's children. If the receiver was already registered with the Configuration, the new Configurator is registered as well.
Parameters:
configurator - The Configurator to add.

remove

public void remove(Configurable configurable,
                   boolean keepValues)
Remove a Configurable from the Configurator's children. If the receiver was already registered with the Configuration, the Configurable is removed.
Parameters:
configurable - The Configurable to remove.
keepValues - If true, the Configurable's state is kept in the Configuration.

remove

public void remove(Configurator configurator,
                   boolean keepValues)
Remove a Configurator from the Configurator's children. If the receiver was already registered with the Configuration, the Configurator is removed.
Parameters:
configurator - The Configurator to remove.
keepValues - If true, the Configurator's state is kept in the Configuration.

isRegistered

public boolean isRegistered()
Query whether the Configurator is registered with the Configuration.
Returns:
True is the Configurator is registered.

isRegistered

public boolean isRegistered(Configuration configuration)
Query whether the Configurator is registered with a special Configuration.
Parameters:
configuration - The Configuration to test for.
Returns:
True is the Configurator is registered.

register

public void register()
Register the children of the Configurator with the Configuration. The names used are constructed from the Configurator's parent's name, the Configurator's name and the children's own names.

register

public void register(Configuration configuration)
Register the children of the Configurator with a special Configuration. The names used are constructed from the Configurator's parent's name, the Configurator's name and the children's own names.
Parameters:
configuration - The Configuration to register with.

unregister

public void unregister(boolean keepValues)
Unregister the Configurator's children from the Configuration.
Parameters:
keepValues - If true, keep the state of the Configurables in the Configuration.

unregister

public void unregister(Configuration configuration,
                       boolean keepValues)
Unregister the Configurator's children from a special Configuration.
Parameters:
configuration - The Configuration to unregister from.
keepValues - If true, keep the state of the Configurables in the Configuration.

getName

public java.lang.String getName()
Get the name of the Configurator. This includes the Configurator's parent's name. When the Configurator is registered with the Configuration, its name will be frozen, even if it is moved to a different parent.
Returns:
The name of the Configurator.

copy

public Configurator copy()
Create a deep copy of the Configurator hierarchy rooted at this Configurator. Configurator children are copied themselves, while Configurable children are added identically to the result.

This method is useful to save parts of a Configuration in different files, while still keeping the whole Configuration in one big hierarchy.

Returns:
A deep copy of the Configurator.

setParent

protected void setParent(Configurator parent)
Set the Configurator's parent.
Parameters:
parent - The parent to set.

qflib 0.98.1