com.microsoft.tfs.core.memento
Interface Memento

All Known Implementing Classes:
XMLMemento

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.

Since:
TEE-SDK-10.1
Thread-safety:
thread-safe

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

createChild

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.

Parameters:
name - the name of the child Memento (must not be null or empty)
Returns:
the new child Memento created in this memento

getChild

Memento getChild(java.lang.String name)
Returns a child with the given name. The order in which children are stored is not specified, so this method may return a child with the given name at any position in the child collection. To access multiple children with the same name, use getChildren(String).

Parameters:
name - the name of the child Memento to get (must not be null or empty)
Returns:
the first child with the given name

getChildren

Memento[] getChildren(java.lang.String name)
Returns all children with the given name.

Parameters:
name - the name of the child Mementos to get (must not be null or empty)
Returns:
an array of children with the given name, never null but may be empty

getAllChildren

Memento[] getAllChildren()
Gets all the children.

Returns:
an array of all children, never null but may be empty

removeChildren

Memento[] removeChildren(java.lang.String name)
Removes all children with the given name.

Parameters:
name - the name of the children to remove (must not be null or empty)
Returns:
the children that were removed, never null but may be empty

removeChild

boolean removeChild(Memento memento)
Removes the given child. The memento is matched to this memento's children by object equality.

Parameters:
memento - the child to remove (must not be null)
Returns:
true if the memento was a child (and was removed), false if the memento was not a child

getName

java.lang.String getName()
Returns:
this Memento's name (never null or empty)

getAllAttributes

java.util.Map getAllAttributes()
Gets a map of attribute keys to values. All keys and values are Strings.

Returns:
the Map of attribute String keys to String values (never null)

getDouble

java.lang.Double getDouble(java.lang.String key)
Gets the double floating point value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found or was found but was not a floating point number

getFloat

java.lang.Float getFloat(java.lang.String key)
Gets the floating point value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found or was found but was not a floating point number

getInteger

java.lang.Integer getInteger(java.lang.String key)
Gets the integer value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found or was found but was not an integer

getLong

java.lang.Long getLong(java.lang.String key)
Gets the long integer value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found or was found but was not an integer

getString

java.lang.String getString(java.lang.String key)
Gets the string value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found

getBoolean

java.lang.Boolean getBoolean(java.lang.String key)
Gets the Boolean value of the given key.

Parameters:
key - the key
Returns:
the value, or null if the key was not found

getTextData

java.lang.String getTextData()
Gets the data from the special text area of the Memento. Each Memento is allowed only one special text area.

Returns:
the contents of the special text area of the Memento, or null if the Memento has no text.

putDouble

void putDouble(java.lang.String key,
               double value)
Sets the value of the given key to the given double floating point number.

Parameters:
key - the key (must not be null or empty)
value - the value

putFloat

void putFloat(java.lang.String key,
              float value)
Sets the value of the given key to the given floating point number.

Parameters:
key - the key (must not be null or empty)
value - the value

putInteger

void putInteger(java.lang.String key,
                int value)
Sets the value of the given key to the given integer.

Parameters:
key - the key (must not be null or empty)
value - the value (may be null or empty)

putLong

void putLong(java.lang.String key,
             long value)
Sets the value of the given key to the given long integer.

Parameters:
key - the key (must not be null or empty)
value - the value (may be null or empty)

putString

void putString(java.lang.String key,
               java.lang.String value)
Sets the value of the given key to the given string.

Parameters:
key - the key (must not be null or empty)
value - the value (may be null or empty)

putBoolean

void putBoolean(java.lang.String key,
                boolean value)
Sets the value of the given key to the given boolean value.

Parameters:
key - the key (must not be null or empty)
value - the value (may be null or empty)

putTextData

void putTextData(java.lang.String text)
Sets the 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.

Parameters:
text - the text to be placed into the special text area (may be null or empty)

putMemento

void putMemento(Memento memento)
Copy the special text, attributes, and children from the given Memento into the receiver. The name of the receiver Memento is not changed.

Parameters:
memento - the Memento to be copied (must not be null)


© 2015 Microsoft. All rights reserved.