|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ccg.io.ConfigAttributes
public class ConfigAttributes
Tools from "magically" transferring configuration to/from beans.
For an general overview of configuration issues (and how this class fits in to the scheme), refer to the Configuration Files document.
This object makes use of introspection techniques to allow one to save one or more attributes from one or more beans such that the attributes can be restored at a later time.
For example, if you had a GUI panel which had text input fields for "name" and "phone" number fields which you would like to preserve between runs (that is "remember" them the next time the user starts the program - so the user doesn't need to re-enter them), then this is the class for you.
ConfigSource,
Serialized Form| Constructor Summary | |
|---|---|
ConfigAttributes()
Construct a empty ConfigAttributes object. |
|
| Method Summary | |
|---|---|
int |
restoreAttributes(Object o,
String[] beanNames)
Load values back into a object that were previously saved. |
void |
saveAttributes(Object o,
String[] beanNames)
Register a Object and associated set of attributes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConfigAttributes()
ConfigAttributes object.
You typically construct these objects when you are ready to transfer attribute information from your "beans" into this object (just before you write this object to disk).
When you restore your attributes, you typically do NOT use the
constructor directly - you simply deserialized the object from
your stream (read it back from the config file using ConfigSource.loadObject()).
saveAttributes(java.lang.Object, java.lang.String[])| Method Detail |
|---|
public void saveAttributes(Object o,
String[] beanNames)
throws ConfigException
Object and associated set of attributes.
This method is used to transfer one or more "bean" values from
a object to the ConfigAttributes object so that it can be
serialized and then later restored. Refer to the class overview
for more information and pointers to example programs.
o - The Object to register and pull values from - its OK
to pass null, but only to register a null entry. Typically you
only pass null if you make a new revision that no longer
requires ANY attributes to be saved from a object.bnames - The names of the "bean" methods in your object which you would
like to retrieve in the attributes object.
ConfigException - If we were unable to locate both a "setXXX(X)" and "getXXX()"
or "isXXX()" method for one of the bean names passed
(triggered by a NoSuchMethodException). Or, if the
security manager comes up and bites you (triggered by a SecurityException). Or, if you pass a bean name which your
method doesn't have access rights to (the name of a private
method of a parent class for example - triggered by a IllegalAccessException). Or, if an exception is thrown by
your object when we try to fetch a value for a particular bean
field (triggered by a InvocationTargetException).restoreAttributes(java.lang.Object, java.lang.String[])
public int restoreAttributes(Object o,
String[] beanNames)
throws ConfigException
saved.
This method is used to transfer one or more "bean" values this
objects set of attributes back into a Object (this is the
"reverse" of the saveAttributes(java.lang.Object, java.lang.String[]) method). This method is
typically called after de-serializing a ConfigAttributes
object. Each invocation of "restore" should have a corresponding
invocation of "save" and the order is important. Refer to the
class overview for more information and
pointers to example programs.
o - The Object to register and pull values from - its OK
to pass null, but only to register a null entry. Typically you
only pass null if you make a new revision that no longer
requires ANY attributes to be saved from a object.bnames - The names of the "bean" methods in your object which you would
like to retrieve in the attributes object.
ConfigException - If you pass a bean name which your method doesn't have access
rights to (the name of a private method of a parent class for
example - triggered by a IllegalAccessException). Or,
if an exception is thrown by your object when we try to fetch
a value for a particular bean field (triggered by a InvocationTargetException).saveAttributes(java.lang.Object, java.lang.String[])
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||