|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.microsoft.tfs.core.memento.XMLMemento
public class XMLMemento
XMLMemento
is an implementation of Memento
which serializes
its data to/from XML streams. The default encoding for these streams is
DEFAULT_ENCODING
if null
is specified for
read(InputStream, String)
or write(OutputStream, String)
.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_ENCODING
The encoding used for read(InputStream, String) and
write(OutputStream, String) when null is specified
for the encoding parameter. |
Constructor Summary | |
---|---|
XMLMemento(java.lang.String name)
Creates an XMLMemento with the given name and an empty set of
attributes and children. |
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 data)
Sets the Memento 's special text area to contain the given data. |
static XMLMemento |
read(java.io.InputStream inputStream,
java.lang.String encoding)
Reads an XMLMemento from the next XML element in the given given
InputStream in the encoding specified as
DEFAULT_ENCODING . |
boolean |
removeChild(Memento memento)
Removes the given child. |
Memento[] |
removeChildren(java.lang.String name)
Removes all children with the given name. |
void |
write(java.io.OutputStream outputStream,
java.lang.String encoding)
Writes this XMLMemento as an XML element (with child elements for
child Memento s) to the specified OutputStream . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_ENCODING
read(InputStream, String)
and
write(OutputStream, String)
when null
is specified
for the encoding parameter.
"UTF-8"
Constructor Detail |
---|
public XMLMemento(java.lang.String name)
XMLMemento
with the given name and an empty set of
attributes and children.
name
- the name (must not be null
or empty)Method Detail |
---|
public static XMLMemento read(java.io.InputStream inputStream, java.lang.String encoding) throws MementoException
XMLMemento
from the next XML element in the given given
InputStream
in the encoding specified as
DEFAULT_ENCODING
.
inputStream
- the InputStream
read to read the XMLMemento
from
(must not be null
)encoding
- the encoding to use when reading the InputStream
,
null
to use the default encoding (
DEFAULT_ENCODING
)
MementoException
- if an error prevented the creation of the Memento.public void write(java.io.OutputStream outputStream, java.lang.String encoding) throws MementoException
XMLMemento
as an XML element (with child elements for
child Memento
s) to the specified OutputStream
.
outputStream
- the output stream to write the document toencoding
- the encoding to use when writing the OutputStream
,
null
to use the default encoding (
DEFAULT_ENCODING
).
MementoException
- if there is a problem serializing the document to the stream.public java.lang.String getName()
getName
in interface Memento
Memento
's name (never null
or empty)public 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 Memento.getChild(String)
and Memento.getChildren(String)
methods to retrieve children by name.
createChild
in interface Memento
name
- the name of the child Memento
(must not be
null
or empty)
Memento
created in this mementopublic Memento getChild(java.lang.String name)
Memento.getChildren(String)
.
getChild
in interface Memento
name
- the name of the child Memento
to get (must not be
null
or empty)
public Memento[] getChildren(java.lang.String name)
getChildren
in interface Memento
name
- the name of the child Memento
s to get (must not be
null
or empty)
public Memento[] getAllChildren()
getAllChildren
in interface Memento
public Memento[] removeChildren(java.lang.String name)
removeChildren
in interface Memento
name
- the name of the children to remove (must not be null
or empty)
public boolean removeChild(Memento memento)
removeChild
in interface Memento
memento
- the child to remove (must not be null
)
public java.util.Map getAllAttributes()
String
s.
getAllAttributes
in interface Memento
Map
of attribute String
keys to
String
values (never null
)public java.lang.Double getDouble(java.lang.String key)
getDouble
in interface Memento
key
- the key
null
if the key was not found or was
found but was not a floating point numberpublic java.lang.Float getFloat(java.lang.String key)
getFloat
in interface Memento
key
- the key
null
if the key was not found or was
found but was not a floating point numberpublic java.lang.Integer getInteger(java.lang.String key)
getInteger
in interface Memento
key
- the key
null
if the key was not found or was
found but was not an integerpublic java.lang.Long getLong(java.lang.String key)
getLong
in interface Memento
key
- the key
null
if the key was not found or was
found but was not an integerpublic java.lang.String getString(java.lang.String key)
getString
in interface Memento
key
- the key
null
if the key was not foundpublic java.lang.Boolean getBoolean(java.lang.String key)
getBoolean
in interface Memento
key
- the key
public java.lang.String getTextData()
Memento
. Each
Memento
is allowed only one special text area.
getTextData
in interface Memento
Memento
, or
null
if the Memento
has no text.public void putDouble(java.lang.String key, double value)
putDouble
in interface Memento
key
- the key (must not be null
or empty)value
- the valuepublic void putFloat(java.lang.String key, float value)
putFloat
in interface Memento
key
- the key (must not be null
or empty)value
- the valuepublic void putInteger(java.lang.String key, int value)
putInteger
in interface Memento
key
- the key (must not be null
or empty)value
- the value (may be null
or empty)public void putLong(java.lang.String key, long value)
putLong
in interface Memento
key
- the key (must not be null
or empty)value
- the value (may be null
or empty)public void putString(java.lang.String key, java.lang.String value)
putString
in interface Memento
key
- the key (must not be null
or empty)value
- the value (may be null
or empty)public void putBoolean(java.lang.String key, boolean value)
putBoolean
in interface Memento
key
- the key (must not be null
or empty)value
- the value (may be null
or empty)public void putTextData(java.lang.String data)
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.
putTextData
in interface Memento
data
- the text to be placed into the special text area (may be
null
or empty)public void putMemento(Memento memento)
Memento
into the receiver. The name of the receiver
Memento
is not changed.
putMemento
in interface Memento
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 |