public interface MutableMetadataNode extends MetadataNode
Modifier and Type | Method and Description |
---|---|
MutableMetadataNode |
add(Document doc)
Inserts another
Document instance under the current tag |
MutableMetadataNode |
add(Element tag)
Inserts a
Element instance and its hierarchy under the current tag |
MutableMetadataNode |
add(Metadata metadata)
Insert another
Metadata tree into the hierarchy under the current tag |
MutableMetadataNode |
addAttribute(String name,
Object value)
Create a new attribute for the current node.
|
MutableMetadataNode |
addAttributeInDefaultNamespace(String name,
String value)
Create a new attribute for the current node.
|
MutableMetadataNode |
addCDATA(String data)
Add a data node under the current node, and jump to the parent node.
|
MutableMetadataNode |
addDocument(MetadataNode tag)
Inserts another
MutableMetadataNode instance under the current tag. |
MutableMetadataNode |
addNamespace(String prefix,
String namespaceURI)
Add a namespace to the document
|
MutableMetadataNode |
addNode(MetadataNode tag)
Inserts another
MutableMetadataNode tag hierarchy under the current tag. |
MutableMetadataNode |
addNode(String name)
Create a tag under the current location and use it as the current node
|
MutableMetadataNode |
addText(String text)
Add a text node under the current node, and jump to the parent node.
|
MutableMetadataNode |
addText(Text text)
Add a text note to the current tag
|
MutableMetadataNode |
clone() |
MutableMetadataNode |
createNamespaceContext()
Create a wrapper node which allows a new mapping of namespace prefixes to be used to navigate
and query nodes without changing the base document.
|
MutableMetadataNode |
delete()
Delete current tag and its children.
|
MutableMetadataNode |
deleteAttribute(String name)
Delete an attribute of the current node.
|
MutableMetadataNode |
deleteAttributeIfExists(String name)
Delete an attribute of the current node, if it exists
|
MutableMetadataNode |
deleteAttributes()
Delete all existing attributes of current node
|
MutableMetadataNode |
deleteChildren()
Delete all existing elements of this node
|
MutableMetadataNode |
deletePrefixes()
Remove any prefix and name-spaces contained in the tag name, children and attributes, thus
changing name-space and tag name.
|
List<MutableMetadataNode> |
getChildren()
Return a list of all child nodes.
|
List<MutableMetadataNode> |
getChildren(String relativeXpath,
Object... arguments)
Return a list of all nodes selected by the XPath expression.
|
MutableMetadataNode |
getInnerDocument() |
MutableMetadataNode |
gotoChild()
Go to the only child element of the current node.
|
MutableMetadataNode |
gotoChild(int i)
Go to the Nth child of the curent node.
|
MutableMetadataNode |
gotoChild(String nodeName)
Go to the child found with given node name
|
MutableMetadataNode |
gotoFirstChild()
Go to the first child element of the current node.
|
MutableMetadataNode |
gotoFirstChild(String name)
Go to the first child with the given name
|
MutableMetadataNode |
gotoLastChild()
Go to the last child element of the current node.
|
MutableMetadataNode |
gotoLastChild(String name)
Go to the last child with the given name
|
MutableMetadataNode |
gotoParent()
Go to parent tag.
|
MutableMetadataNode |
gotoRoot()
Go to document root tag
|
MutableMetadataNode |
gotoTag(String relativeXpath,
Object... arguments)
Go to a specific node
|
MutableMetadataNode |
renameTo(String newTagName)
Replace current element name by another name
|
MutableMetadataNode |
setAttribute(String name,
String value)
Sets the new value on an existing attribute, and remains on the current tag.
|
MutableMetadataNode |
setAttribute(String name,
String value,
String relativeXpath,
Object... arguments)
Sets the new value on a targeted node's attribute, and remains on the current tag.
|
MutableMetadataNode |
setAttributeIfExist(String name,
String value)
Sets the new value on an attribute, and remains on the current tag.
|
MutableMetadataNode |
setAttributeIfExist(String name,
String value,
String relativeXpath,
Object... arguments)
Sets the new value on a targeted node's attribute, and remains on the current tag.
|
MutableMetadataNode |
setCDATA(String data)
Set the cdata in the current node.
|
MutableMetadataNode |
setText(String text)
Set the text in the current node.
|
MutableMetadataNode |
setText(String text,
String relativeXpath,
Object... arguments)
Set the text in the targeted node.
|
MutableMetadataNode |
setTextIfExist(String text,
String relativeXpath,
Object... arguments)
Set the text in the targeted node.
|
evalToBoolean, evalToNode, evalToNodeSet, evalToNumber, evalToString, findAttribute, findAttribute, getAttribute, getAttribute, getAttributeNames, getCDATA, getChildCount, getDocument, getElement, getEncoding, getInnerText, getLocation, getName, getPrefix, getPrefixes, getText, getText, getTextOrCDATA, getTextOrCDATA, hasAttribute, hasAttribute, hasNode
MutableMetadataNode addAttribute(String name, Object value)
Example:
addDefaultNamespace("http://foo").addNode("foo").addAttribute("bar", "baz");
yields
<foo xmlns="http://foo" bar="baz"/>
name
- Name of the attribute to addvalue
- value of the attribute to add. If the value isn't a string, it is converted into
one using Object.toString()
. If the value is null
, the attribute
is omitted.MutableMetadataNode addAttributeInDefaultNamespace(String name, String value)
Example:
addDefaultNamespace("http://foo").addNode("foo").addAttribute("bar",
"baz");
yields
<foo xmlns="http://foo" xmlns:ns0="http://foo" ns0:bar="baz"/>
name
- Name of the attribute to addvalue
- value of the attribute to addMutableMetadataNode addCDATA(String data)
addTag("name").addCDATA("Bob")addTag("sex").addCDATA("M")addTag("age").addCDATA("30")
<name><![CDATA[Bob]]></name><sex><![CDATA[M]]></sex><age><![CDATA[30]]></
age>
data
- the data to addMutableMetadataNode addDocument(MetadataNode tag)
MutableMetadataNode
instance under the current tag. The whole document
will be inserted.tag
- The MutableMetadataNode
instance to insertMutableMetadataNode add(Document doc)
Document
instance under the current tagdoc
- The Document
instance to insertMutableMetadataNode addNamespace(String prefix, String namespaceURI)
prefix
- The prefix of the namespacenamespaceURI
- The URI of the namespaceMutableMetadataNode addNode(MetadataNode tag)
MutableMetadataNode
tag hierarchy under the current tag. Only the
current tag of the given document will be inserted with its hierarchy, not the whole document.tag
- The MutableMetadataNode
current tag hierarchy to insertMutableMetadataNode add(Element tag)
Element
instance and its hierarchy under the current tagtag
- The Element
instance to insertMutableMetadataNode add(Metadata metadata)
Metadata
tree into the hierarchy under the current tagmetadata
- the metadata tree to addMutableMetadataNode addNode(String name)
name
- Name of the element to addMutableMetadataNode addText(String text)
addTag("name").addText("Bob")addTag("sex").addText("M")addTag("age").addText("30")
<name>Bob</name><sex>M</sex><age>30</age>
text
- the text to addMutableMetadataNode addText(Text text)
text
- The node to insertMutableMetadataNode delete() throws MetadataException
MetadataException
- if the current node is the root nodeMutableMetadataNode deleteAttribute(String name) throws MetadataException
name
- attribute nameMetadataException
- if the attribute does not existMutableMetadataNode deleteAttributeIfExists(String name)
name
- attribute nameMutableMetadataNode deleteAttributes()
MutableMetadataNode deleteChildren()
MutableMetadataNode deletePrefixes()
MutableMetadataNode clone()
MutableMetadataNode gotoChild() throws MetadataException
gotoChild
in interface MetadataNode
MetadataException
- If the current node has several childs or no child at allMutableMetadataNode gotoChild(int i) throws MetadataException
gotoChild
in interface MetadataNode
i
- index of the child, from 1 to child element numberMetadataException
- If the child node does not existMutableMetadataNode gotoChild(String nodeName) throws MetadataException
gotoChild
in interface MetadataNode
nodeName
- name of the child to find.MetadataException
- If the element with this name has not been found or if there are too
many elementsMutableMetadataNode gotoFirstChild() throws MetadataException
gotoFirstChild
in interface MetadataNode
MetadataException
- If the current node has no child at allMutableMetadataNode gotoFirstChild(String name) throws MetadataException
gotoFirstChild
in interface MetadataNode
name
- Name of the child to go atMetadataException
- If the current node has no child at allMutableMetadataNode gotoLastChild() throws MetadataException
gotoLastChild
in interface MetadataNode
MetadataException
- If the current node has no child at allMutableMetadataNode gotoLastChild(String name) throws MetadataException
gotoLastChild
in interface MetadataNode
name
- Name of the child to go atMetadataException
- If the current node has no child at allMutableMetadataNode gotoParent()
gotoParent
in interface MetadataNode
MutableMetadataNode gotoRoot()
gotoRoot
in interface MetadataNode
MutableMetadataNode gotoTag(String relativeXpath, Object... arguments) throws MetadataException
gotoTag
in interface MetadataNode
relativeXpath
- XPath expressionarguments
- to be replaced in XPath expression before compiling. Uses String.format() to
build XPath expression.MetadataException
- if the node does not exist or if the XPath expression is invalidMutableMetadataNode renameTo(String newTagName)
newTagName
- New name of the tagMutableMetadataNode setAttribute(String name, String value) throws MetadataException
name
- attribute namevalue
- new attribute'svalueMetadataException
- If the attribute does not existMutableMetadataNode setAttribute(String name, String value, String relativeXpath, Object... arguments) throws MetadataException
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- optional XPath expression arguments. Uses String.format() to build XPath
expression.MetadataException
- Attribute does not exist, targeted node does not exit, or XPath
expression is invalidMutableMetadataNode setAttributeIfExist(String name, String value)
name
- attribute namevalue
- new attribute valueMutableMetadataNode setAttributeIfExist(String name, String value, String relativeXpath, Object... arguments) throws MetadataException
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- optional XPath expression arguments. Uses String.format() to build XPath
expression.MetadataException
- XPath expression is invalid or targeted node does not existMutableMetadataNode setCDATA(String data)
gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
data
- text to put under this node in a CDATA sectionMutableMetadataNode setText(String text)
gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
text
- text to put under this nodeMutableMetadataNode setText(String text, String relativeXpath, Object... arguments) throws MetadataException
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- optional XPath expression arguments. Uses String.format() to build XPath
expression.MetadataException
- If the XPath expression is invalid or if the node does not existMutableMetadataNode setTextIfExist(String text, String relativeXpath, Object... arguments) throws MetadataException
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- optional XPath expression arguments. Uses String.format() to build XPath
expression.MetadataException
- If the XPath expression is invalidMutableMetadataNode getInnerDocument()
getInnerDocument
in interface MetadataNode
List<MutableMetadataNode> getChildren()
getChildren
in interface MetadataNode
List<MutableMetadataNode> getChildren(String relativeXpath, Object... arguments)
getChildren
in interface MetadataNode
relativeXpath
- XPath to select tagsarguments
- XPath argumentsMutableMetadataNode createNamespaceContext()
createNamespaceContext
in interface MetadataNode
MetadataException
- If the namespace handling has been disabled on the Metadata
containing this node.Copyright © 2024 levigo holding gmbh. All rights reserved.