| Constructor and Description |
|---|
XMLMemento(org.w3c.dom.Document document,
org.w3c.dom.Element element)
Creates a memento for the specified document and element.
|
| Modifier and Type | Method and Description |
|---|---|
IMemento |
copyChild(IMemento child)
Create a copy of the child node and append it to this node.
|
IMemento |
createChild(java.lang.String type)
Creates a new child of this memento with the given type.
|
IMemento |
createChild(java.lang.String type,
java.lang.String id)
Creates a new child of this memento with the given type and id.
|
static XMLMemento |
createReadRoot(java.io.Reader reader)
Creates a
Document from the Reader
and returns a memento on the first Element for reading
the document. |
static XMLMemento |
createReadRoot(java.io.Reader reader,
java.lang.String baseDir)
Creates a
Document from the Reader
and returns a memento on the first Element for reading
the document. |
static XMLMemento |
createWriteRoot(java.lang.String type)
Returns a root memento for writing a document.
|
java.lang.String[] |
getAttributeKeys()
Returns an array of all the attribute keys of the memento.
|
java.lang.Boolean |
getBoolean(java.lang.String key)
Returns the boolean value of the given key.
|
IMemento |
getChild(java.lang.String type)
Returns the first child with the given type id.
|
IMemento[] |
getChildren()
Returns all children of this node.
|
IMemento[] |
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.
|
java.lang.String |
getType()
Returns the type for this memento.
|
void |
putBoolean(java.lang.String key,
boolean value)
Sets the value of the given key to the given boolean value.
|
void |
putFloat(java.lang.String key,
float f)
Sets the value of the given key to the given floating point number.
|
void |
putInteger(java.lang.String key,
int n)
Sets the value of the given key to the given integer.
|
void |
putMemento(IMemento 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.
|
void |
save(java.io.Writer writer)
Saves this memento's document current values to the
specified writer.
|
java.lang.String |
toString() |
public XMLMemento(org.w3c.dom.Document document,
org.w3c.dom.Element element)
Clients should use createReadRoot and
createWriteRoot to create the initial
memento on a document.
document - the document for the mementoelement - the element node for the mementopublic static XMLMemento createReadRoot(java.io.Reader reader) throws WorkbenchException
Document from the Reader
and returns a memento on the first Element for reading
the document.
Same as calling createReadRoot(reader, null)
reader - the Reader used to create the memento's documentElement for reading the documentWorkbenchException - if IO problems, invalid format, or no element.public static XMLMemento createReadRoot(java.io.Reader reader, java.lang.String baseDir) throws WorkbenchException
Document from the Reader
and returns a memento on the first Element for reading
the document.reader - the Reader used to create the memento's documentbaseDir - the directory used to resolve relative file names
in the XML document. This directory must exist and include the
trailing separator. The directory format, including the separators,
must be valid for the platform. Can be null if not
needed.Element for reading the documentWorkbenchException - if IO problems, invalid format, or no element.public static XMLMemento createWriteRoot(java.lang.String type) throws org.w3c.dom.DOMException
type - the element node type to create on the documentorg.w3c.dom.DOMExceptionpublic IMemento createChild(java.lang.String type) throws org.w3c.dom.DOMException
The getChild and getChildren methods are used
to retrieve children of a given type.
createChild in interface IMementotype - the typeorg.w3c.dom.DOMException - if the child cannot be createdgetChild(java.lang.String),
getChildren()public IMemento createChild(java.lang.String type, java.lang.String id) throws org.w3c.dom.DOMException
TAG_ID) and can be retrieved using getId.
The getChild and getChildren methods are used
to retrieve children of a given type.
createChild in interface IMementotype - the typeid - the child idorg.w3c.dom.DOMException - if the child cannot be createdgetID()public IMemento copyChild(IMemento child) throws org.w3c.dom.DOMException
child - org.w3c.dom.DOMException - if the child cannot be createdpublic IMemento getChild(java.lang.String type)
IMementopublic IMemento[] getChildren()
IMementogetChildren in interface IMementonull. If there are no children, an array of length
zero will be returned.public IMemento[] getChildren(java.lang.String type)
IMementogetChildren in interface IMementotype - the type idnull. If there are no keys, an array of length zero
will be returned.public java.lang.Float getFloat(java.lang.String key)
IMementopublic java.lang.String getType()
IMementogetType in interface IMementoIMemento.createChild(java.lang.String),
IMemento.createChild(java.lang.String,java.lang.String)public java.lang.String getID()
IMementogetID in interface IMementonull if noneIMemento.createChild(java.lang.String,java.lang.String)public java.lang.Integer getInteger(java.lang.String key)
IMementogetInteger in interface IMementokey - the keynull if the key was not found or was found
but was not an integerpublic java.lang.String getString(java.lang.String key)
IMementopublic java.lang.Boolean getBoolean(java.lang.String key)
IMementogetBoolean in interface IMementokey - the keynull if the key was not foundpublic java.lang.String getTextData()
throws org.w3c.dom.DOMException
getTextData in interface IMementonull if
the memento has no Text node.org.w3c.dom.DOMException - if the text node is too bigpublic java.lang.String[] getAttributeKeys()
IMementonull. If there are no keys, an array of length zero will
be returned.getAttributeKeys in interface IMementopublic void putFloat(java.lang.String key,
float f)
throws org.w3c.dom.DOMException
public void putInteger(java.lang.String key,
int n)
throws org.w3c.dom.DOMException
putInteger in interface IMementokey - the keyn - the valueorg.w3c.dom.DOMException - if the attribute cannot be setpublic void putMemento(IMemento memento) throws org.w3c.dom.DOMException
memento to the
receiver.putMemento in interface IMementomemento - the IMemento to be copied.org.w3c.dom.DOMException - if the attributes or children cannot be copied to this node.public void putString(java.lang.String key,
java.lang.String value)
throws org.w3c.dom.DOMException
public void putBoolean(java.lang.String key,
boolean value)
throws org.w3c.dom.DOMException
putBoolean in interface IMementokey - the keyvalue - the valueorg.w3c.dom.DOMException - if the attribute cannot be setpublic void putTextData(java.lang.String data)
throws org.w3c.dom.DOMException
putTextData in interface IMementodata - the data to be placed on the Text nodeorg.w3c.dom.DOMException - if the text node cannot be created under this node.public void save(java.io.Writer writer)
throws java.io.IOException
writer - the writer used to save the memento's documentjava.io.IOException - if there is a problem serializing the document to the stream.public java.lang.String toString()
toString in class java.lang.Object
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.