|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Memento
An in-memory hierarchichal data structure, intended primarily for persisting
a program component's settings. Mementos form trees, and each tree
node can have data attached (by string key) and can have children (more
Mementos).
In short, things you can do with a Memento:
A Memento must accept multiple children with the same name. The child
collection's order is unspecified (this is important to remember when calling
getChild(String), which returns any child node with the matching
name). Memento names and attribute names are case-sensitive.
The String key names for all types of attributes (int, long, boolean, String, etc.) share the same namespace. The different types of accessors are for convenience, they may be stored as string representations inside.
| Method Summary | |
|---|---|
Memento |
createChild(java.lang.String name)
Creates a new Memento with the given name and attaches it as a
child to this Memento. |
java.util.Map |
getAllAttributes()
Gets a map of attribute keys to values. |
Memento[] |
getAllChildren()
Gets all the children. |
java.lang.Boolean |
getBoolean(java.lang.String key)
Gets the Boolean value of the given key. |
Memento |
getChild(java.lang.String name)
Returns a child with the given name. |
Memento[] |
getChildren(java.lang.String name)
Returns all children with the given name. |
java.lang.Double |
getDouble(java.lang.String key)
Gets the double floating point value of the given key. |
java.lang.Float |
getFloat(java.lang.String key)
Gets the floating point value of the given key. |
java.lang.Integer |
getInteger(java.lang.String key)
Gets the integer value of the given key. |
java.lang.Long |
getLong(java.lang.String key)
Gets the long integer value of the given key. |
java.lang.String |
getName()
|
java.lang.String |
getString(java.lang.String key)
Gets the string value of the given key. |
java.lang.String |
getTextData()
Gets the data from the special text area of the Memento. |
void |
putBoolean(java.lang.String key,
boolean value)
Sets the value of the given key to the given boolean value. |
void |
putDouble(java.lang.String key,
double value)
Sets the value of the given key to the given double floating point number. |
void |
putFloat(java.lang.String key,
float value)
Sets the value of the given key to the given floating point number. |
void |
putInteger(java.lang.String key,
int value)
Sets the value of the given key to the given integer. |
void |
putLong(java.lang.String key,
long value)
Sets the value of the given key to the given long integer. |
void |
putMemento(Memento memento)
Copy the special text, attributes, and children from the given Memento into the receiver. |
void |
putString(java.lang.String key,
java.lang.String value)
Sets the value of the given key to the given string. |
void |
putTextData(java.lang.String text)
Sets the Memento's special text area to contain the given data. |
boolean |
removeChild(Memento memento)
Removes the given child. |
Memento[] |
removeChildren(java.lang.String name)
Removes all children with the given name. |
| Method Detail |
|---|
Memento createChild(java.lang.String name)
Creates a new Memento with the given name and attaches it as a
child to this Memento. Child names do not have to be unique
within a memento; multiple children with the same name are allowed.
Use the getChild(String) and getChildren(String)
methods to retrieve children by name.
name - the name of the child Memento (must not be
null or empty)
Memento created in this mementoMemento getChild(java.lang.String name)
getChildren(String).
name - the name of the child Memento to get (must not be
null or empty)
Memento[] getChildren(java.lang.String name)
name - the name of the child Mementos to get (must not be
null or empty)
Memento[] getAllChildren()
Memento[] removeChildren(java.lang.String name)
name - the name of the children to remove (must not be null
or empty)
boolean removeChild(Memento memento)
memento - the child to remove (must not be null)
java.lang.String getName()
Memento's name (never null or empty)java.util.Map getAllAttributes()
Strings.
Map of attribute String keys to
String values (never null)java.lang.Double getDouble(java.lang.String key)
key - the key
null if the key was not found or was
found but was not a floating point numberjava.lang.Float getFloat(java.lang.String key)
key - the key
null if the key was not found or was
found but was not a floating point numberjava.lang.Integer getInteger(java.lang.String key)
key - the key
null if the key was not found or was
found but was not an integerjava.lang.Long getLong(java.lang.String key)
key - the key
null if the key was not found or was
found but was not an integerjava.lang.String getString(java.lang.String key)
key - the key
null if the key was not foundjava.lang.Boolean getBoolean(java.lang.String key)
key - the key
java.lang.String getTextData()
Memento. Each
Memento is allowed only one special text area.
Memento, or
null if the Memento has no text.
void putDouble(java.lang.String key,
double value)
key - the key (must not be null or empty)value - the value
void putFloat(java.lang.String key,
float value)
key - the key (must not be null or empty)value - the value
void putInteger(java.lang.String key,
int value)
key - the key (must not be null or empty)value - the value (may be null or empty)
void putLong(java.lang.String key,
long value)
key - the key (must not be null or empty)value - the value (may be null or empty)
void putString(java.lang.String key,
java.lang.String value)
key - the key (must not be null or empty)value - the value (may be null or empty)
void putBoolean(java.lang.String key,
boolean value)
key - the key (must not be null or empty)value - the value (may be null or empty)void putTextData(java.lang.String text)
Memento's special text area to contain the given data.
If a special text value was previously set, it is replaced with the given
text. Each memento is allowed only one special text value.
text - the text to be placed into the special text area (may be
null or empty)void putMemento(Memento memento)
Memento into the receiver. The name of the receiver
Memento is not changed.
memento - the Memento to be copied (must not be null)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||