|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.config.ConfigGroup<T>
public class ConfigGroup<T extends ManagedConfig>
Contains a group of managed configurations, all of the same class.
| Field Summary | |
|---|---|
protected Class<T> |
_cclass
The configuration class. |
protected ConfigManager |
_cfgmgr
The configuration manager that created this group. |
protected HashMap<String,T> |
_configsByName
Configurations mapped by name. |
protected ObserverList<ConfigGroupListener<T>> |
_listeners
Configuration event listeners. |
protected String |
_name
The name of this group. |
| Constructor Summary | |
|---|---|
ConfigGroup()
No-arg constructor for deserialization. |
|
ConfigGroup(Class<T> clazz)
Creates a new config group for the specified class. |
|
| Method Summary | |
|---|---|
void |
addConfig(T config)
Adds a configuration to the set. |
void |
addConfigs(Collection<T> configs)
Adds all of the supplied configurations to the set. |
void |
addListener(ConfigGroupListener<T> listener)
Adds a listener for configuration events. |
Object |
copy(Object dest)
Creates a copy of this object, (re)populating the supplied destination object if possible. |
Object |
copy(Object dest,
Object outer)
Creates a copy of this object, (re)populating the supplied destination object if possible. |
protected void |
fireConfigAdded(T config)
Fires a configuration added event. |
protected void |
fireConfigRemoved(T config)
Fires a configuration removed event. |
T |
getConfig(String name)
Retrieves a configuration by name. |
Class<T> |
getConfigClass()
Returns the class of the configurations in this group. |
protected File |
getConfigFile(boolean xml)
Returns the configuration file. |
protected String |
getConfigPath(boolean xml)
Returns the path of the config resource associated with this group. |
Collection<T> |
getConfigs()
Returns the collection of all registered configurations. |
protected InputStream |
getConfigStream(boolean xml)
Returns the configuration stream, or null if it doesn't exist. |
String |
getName()
Returns the name of this group. |
static String |
getName(Class<?> clazz)
Returns the group name for the specified config class. |
void |
init(ConfigManager cfgmgr)
Initializes this group. |
protected void |
initConfigClass(Class<T> clazz)
Initializes the configuration class immediately after construction or deserialization. |
protected void |
initConfigs(T[] configs)
Sets the initial set of configs. |
protected void |
load(Collection<T> nconfigs,
boolean merge,
boolean clone)
Loads the specified configurations. |
void |
load(File file)
Loads the configurations from the specified file. |
void |
load(File file,
boolean merge)
Loads the configurations from the specified file. |
protected boolean |
readConfigs(boolean xml)
Attempts to read the initial set of configurations. |
void |
readFields(Importer in)
Reads the fields of this object. |
void |
removeConfig(T config)
Removes a configuration from the set. |
void |
removeListener(ConfigGroupListener<T> listener)
Removes a configuration event listener. |
void |
revert()
Reverts to the last saved configurations. |
void |
save()
Saves this group's configurations. |
void |
save(Collection<T> configs,
File file)
Saves the provided collection of configurations to a file. |
void |
save(File file)
Saves this group's configurations to the specified file. |
protected T[] |
toSortedArray(Collection<T> configs)
Converts the supplied collection of configs to a sorted array. |
protected void |
validateOuters(T[] configs)
Validates the outer object references of the supplied configs. |
void |
writeFields(Exporter out)
Writes the fields of this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ConfigManager _cfgmgr
protected String _name
protected Class<T extends ManagedConfig> _cclass
protected HashMap<String,T extends ManagedConfig> _configsByName
protected ObserverList<ConfigGroupListener<T extends ManagedConfig>> _listeners
| Constructor Detail |
|---|
public ConfigGroup(Class<T> clazz)
public ConfigGroup()
| Method Detail |
|---|
public static String getName(Class<?> clazz)
public void init(ConfigManager cfgmgr)
public String getName()
public Class<T> getConfigClass()
public T getConfig(String name)
public Collection<T> getConfigs()
public void addListener(ConfigGroupListener<T> listener)
public void removeListener(ConfigGroupListener<T> listener)
public void addConfigs(Collection<T> configs)
public void addConfig(T config)
public void removeConfig(T config)
public void save()
public void save(File file)
public void save(Collection<T> configs,
File file)
public void revert()
public void load(File file)
public void load(File file,
boolean merge)
merge - if true, merge with the existing configurations; do not delete configurations
that do not exist in the file.
public void writeFields(Exporter out)
throws IOException
IOException
public void readFields(Importer in)
throws IOException
IOExceptionpublic Object copy(Object dest)
Copyable
copy in interface Copyable
public Object copy(Object dest,
Object outer)
Copyable
copy in interface Copyableouter - the outer object reference to use for inner object creation, if any.
protected void initConfigClass(Class<T> clazz)
protected boolean readConfigs(boolean xml)
protected InputStream getConfigStream(boolean xml)
null if it doesn't exist.
protected File getConfigFile(boolean xml)
protected String getConfigPath(boolean xml)
protected void validateOuters(T[] configs)
protected void initConfigs(T[] configs)
protected void load(Collection<T> nconfigs,
boolean merge,
boolean clone)
merge - if true, merge with the existing configurations; do not delete configurations
that do not exist in the collection.clone - if true, we must clone configurations that do not yet exist in the group.protected T[] toSortedArray(Collection<T> configs)
protected void fireConfigAdded(T config)
protected void fireConfigRemoved(T config)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||