Nuxeo Enterprise Platform 5.4

org.nuxeo.common.persistence
Interface Memento

All Known Implementing Classes:
XMLMemento

public interface Memento

Interface to a memento used for saving the important state of an object in a form that can be persisted in the file system.

Mementos were designed with the following requirements in mind:

  1. Certain objects need to be saved and restored across platform sessions.
  2. When an object is restored, an appropriate class for an object might not be available. It must be possible to skip an object in this case.
  3. When an object is restored, the appropriate class for the object may be different from the one when the object was originally saved. If so, the new class should still be able to read the old form of the data.

Mementos meet these requirements by providing support for storing a mapping of arbitrary string keys to primitive values, and by allowing mementos to have other mementos as children (arranged into a tree). A robust external storage format based on XML is used.

The key for an attribute may be any alpha numeric value. However, the value of TAG_ID is reserved for internal use.

This interface is not intended to be implemented or extended by clients.


Field Summary
static java.lang.String TAG_ID
          Special reserved key used to store the memento id (value "org.eclipse.ui.id").
 
Method Summary
 Memento createChild(java.lang.String type)
          Creates a new child of this memento with the given type.
 Memento createChild(java.lang.String type, java.lang.String id)
          Creates a new child of this memento with the given type and id.
 java.lang.Boolean getBoolean(java.lang.String key)
          Returns the boolean value of the given key.
 Memento getChild(java.lang.String type)
          Returns the first child with the given type id.
 Memento[] getChildren(java.lang.String type)
          Returns all children with the given type id.
 java.lang.Float getFloat(java.lang.String key)
          Returns the floating point value of the given key.
 java.lang.String getID()
          Returns the id for this memento.
 java.lang.Integer getInteger(java.lang.String key)
          Returns the integer value of the given key.
 java.lang.String getString(java.lang.String key)
          Returns the string value of the given key.
 java.lang.String getTextData()
          Returns the data of the Text node of the memento.
 void putBoolean(java.lang.String key, boolean value)
          Sets the value of the given key to the given boolean.
 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 putMemento(Memento memento)
          Copy the attributes and children from memento to 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 data)
          Sets the memento's Text node to contain the given data.
 

Field Detail

TAG_ID

static final java.lang.String TAG_ID
Special reserved key used to store the memento id (value "org.eclipse.ui.id").

See Also:
getID(), Constant Field Values
Method Detail

createChild

Memento createChild(java.lang.String type)
Creates a new child of this memento with the given type.

The getChild and getChildren methods are used to retrieve children of a given type.

Parameters:
type - the type
Returns:
a new child memento
See Also:
getChild(java.lang.String), getChildren(java.lang.String)

createChild

Memento createChild(java.lang.String type,
                    java.lang.String id)
Creates a new child of this memento with the given type and id. The id is stored in the child memento (using a special reserved key, TAG_ID) and can be retrieved using getId.

The getChild and getChildren methods are used to retrieve children of a given type.

Parameters:
type - the type
id - the child id
Returns:
a new child memento with the given type and id
See Also:
getID()

getChild

Memento getChild(java.lang.String type)
Returns the first child with the given type id.

Parameters:
type - the type id
Returns:
the first child with the given type

getChildren

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

Parameters:
type - the type id
Returns:
an array of children with the given type

getFloat

java.lang.Float getFloat(java.lang.String key)
Returns 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

getID

java.lang.String getID()
Returns the id for this memento.

Returns:
the memento id, or null if none
See Also:
createChild(String, String)

getInteger

java.lang.Integer getInteger(java.lang.String key)
Returns 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

getBoolean

java.lang.Boolean getBoolean(java.lang.String key)
Returns the boolean 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)
Returns the string 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()
Returns the data of the Text node of the memento. Each memento is allowed only one Text node.

Returns:
the data of the Text node of the memento, or null if the memento has no Text node.
Since:
2.0

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
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
value - the value

putMemento

void putMemento(Memento memento)
Copy the attributes and children from memento to the receiver.

Parameters:
memento - the Memento to be copied.

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
value - the value

putBoolean

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

Parameters:
key - the key
value - the value

putTextData

void putTextData(java.lang.String data)
Sets the memento's Text node to contain the given data. Creates the Text node if none exists. If a Text node does exist, it's current contents are replaced. Each memento is allowed only one text node.

Parameters:
data - the data to be placed on the Text node
Since:
2.0

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.