Interface MetadataNode
public interface MetadataNode
The MetadataNodes represents a node in an XML-based metadata-document. In contrast to the W3C
DOM-API it allows for easy and convenient use by providing easy to use methods for access,
navigation, evaluation and conversion.
-
Method Summary
Modifier and TypeMethodDescriptionevalToBoolean
(String relativeXpath, Object... arguments) Evaluate the given XPath expression against the current node and return the result as a Boolean.evalToNumber
(String relativeXpath, Object... arguments) Evaluate the given XPath expression against the current node and return the result as a Number.evalToString
(String relativeXpath, Object... arguments) Evaluate the given XPath expression against the current node and return the result as a String.findAttribute
(String name) returns the attribute value of the current node or null if the attribute does not existfindAttribute
(String name, String relativeXpath, Object... arguments) Returns the attribute value of the node pointed by given XPath expression or null if the attribute does not existgetAttribute
(String name) returns the attribute value of the current nodegetAttribute
(String name, String relativeXpath, Object... arguments) Returns the attribute value of the node pointed by given XPath expressionString[]
getCDATA()
int
List
<? extends MetadataNode> Return a list of all child nodes.List
<? extends MetadataNode> getChildren
(String relativeXpath, Object... arguments) Return a list of all nodes selected by the XPath expression.Return the meta-data document to which this node belongs.getName()
Get the prefix of a namespace identified by its URI.String[]
getPrefixes
(String namespaceURI) Get all bound prefixes of a namespace identified by its URI.getText()
Get the text content of the node addressed by the XPath.getTextOrCDATA
(String relativeXpath, Object... arguments) Get the text content of the node addressed by the XPath.boolean
hasAttribute
(String name) Check whether current tag contains the attribute with the given name.boolean
hasAttribute
(String name, String relativeXpath, Object... arguments) Check whether the node addressed by the XPath contains the attribute with the given name.boolean
Check if the node addressed by the XPath exists in the document.
-
Method Details
-
findAttribute
returns the attribute value of the current node or null if the attribute does not exist- Parameters:
name
- attribute name- Returns:
- attribute value or null if no attribute
-
findAttribute
String findAttribute(String name, String relativeXpath, Object... arguments) throws MetadataException Returns the attribute value of the node pointed by given XPath expression or null if the attribute does not exist- Parameters:
name
- attribute namerelativeXpath
- XPath expressionarguments
- optional XPath expression arguments. Uses String.format() to build XPath expression.- Returns:
- the attribute value or null if the attribute does not exist
- Throws:
MetadataException
- targeted node does not exist or XPath expression is invalid
-
getAttribute
returns the attribute value of the current node- Parameters:
name
- attribute name- Returns:
- attribute value
- Throws:
MetadataException
- If the attribute does not exist
-
getAttribute
String getAttribute(String name, String relativeXpath, Object... arguments) throws MetadataException Returns the attribute value of the node pointed by given XPath expression- Parameters:
name
- attribute namerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- attribute value
- Throws:
MetadataException
- Attribute does not exist, targetted node or XPath expression is invalid
-
getAttributeNames
String[] getAttributeNames()- Returns:
- all attribute names of current node
-
getCDATA
String getCDATA()- Returns:
- The CDATA content of the current node, "" if none
-
getChildCount
int getChildCount()- Returns:
- The number of child for the current tag
-
getChildren
List<? extends MetadataNode> getChildren()Return a list of all child nodes.- Returns:
- The list
-
getChildren
Return a list of all nodes selected by the XPath expression.- Parameters:
relativeXpath
- XPath to select tagsarguments
- XPath arguments- Returns:
- The list
-
getDocument
Metadata getDocument()Return the meta-data document to which this node belongs. -
getLocation
String getLocation()- Returns:
- An XPath expression representing the current tag location in the document. If you are in the root node and run gotoTag() giving this XPath expression, you will return to the current node.
-
getName
String getName()- Returns:
- the current tag name
-
getInnerDocument
MetadataNode getInnerDocument()- Returns:
- Another node instance in which the current node becomes the root element of the new document, and it contains all inner elements as in the previous document.
-
getInnerText
String getInnerText()- Returns:
- The text representation of the inner nodes of the current node. The current node is used as as the root element of inner tags.
-
getPrefix
Get the prefix of a namespace identified by its URI.- Parameters:
namespaceURI
- The URI of the namespace- Returns:
- the prefix or "" if not found ("" is the default prefix - see
javadoc
)
-
getPrefixes
Get all bound prefixes of a namespace identified by its URI.- Parameters:
namespaceURI
- The URI of the namespace- Returns:
- a list of prefixes or an empty array.
-
getText
String getText()- Returns:
- The text content of the current node, "" if none
-
getText
Get the text content of the node addressed by the XPath.- Parameters:
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- the text of "" if none
- Throws:
MetadataException
- If the XPath expression is not valid or if the node does not exist
-
getTextOrCDATA
String getTextOrCDATA()- Returns:
- The text content of the current node, if none tries to get the CDATA content, if none returns ""
-
getTextOrCDATA
Get the text content of the node addressed by the XPath.- Parameters:
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The text content of the current node, if none tries to get the CDATA content, if none returns ""
- Throws:
MetadataException
- If the XPath expression is not valid or if the node does not exist
-
hasAttribute
Check whether current tag contains the attribute with the given name.- Parameters:
name
- Attribute name- Returns:
- true if the attribute is in current tag
-
hasAttribute
boolean hasAttribute(String name, String relativeXpath, Object... arguments) throws MetadataException Check whether the node addressed by the XPath contains the attribute with the given name.- Parameters:
name
- the name of the attributerelativeXpath
- XPath that target the tagarguments
- optional arguments of xpath expression. Uses String.format() to build XPath expression.- Returns:
- true if the tag exist with this attribute name
- Throws:
MetadataException
- If the targetted node does not exist or if xpath expression is not valid
-
hasNode
Check if the node addressed by the XPath exists in the document.- Parameters:
relativeXpath
- XPath expression where the tag should be locatedarguments
- XPath arguments. Uses String.format() to build XPath expression.- Returns:
- true if the tag is exist
-
evalToBoolean
Evaluate the given XPath expression against the current node and return the result as a Boolean.- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.BOOLEAN
return type
-
evalToNumber
Evaluate the given XPath expression against the current node and return the result as a Number.- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.NUMBER
return type
-
evalToString
Evaluate the given XPath expression against the current node and return the result as a String.- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.STRING
return type
-
getEncoding
String getEncoding()
-