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 Details

    • findAttribute

      String findAttribute(String name)
      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 name
      relativeXpath - XPath expression
      arguments - 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

      String getAttribute(String name) throws MetadataException
      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 name
      relativeXpath - XPath expression
      arguments - 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

      List<? extends MetadataNode> getChildren(String relativeXpath, Object... arguments)
      Return a list of all nodes selected by the XPath expression.
      Parameters:
      relativeXpath - XPath to select tags
      arguments - 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

      String getPrefix(String namespaceURI)
      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

      String[] getPrefixes(String namespaceURI)
      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

      String getText(String relativeXpath, Object... arguments) throws MetadataException
      Get the text content of the node addressed by the XPath.
      Parameters:
      relativeXpath - XPath expression that select the node
      arguments - 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

      String getTextOrCDATA(String relativeXpath, Object... arguments) throws MetadataException
      Get the text content of the node addressed by the XPath.
      Parameters:
      relativeXpath - XPath expression that select the node
      arguments - 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

      boolean hasAttribute(String name)
      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 attribute
      relativeXpath - XPath that target the tag
      arguments - 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

      boolean hasNode(String relativeXpath, Object... arguments)
      Check if the node addressed by the XPath exists in the document.
      Parameters:
      relativeXpath - XPath expression where the tag should be located
      arguments - XPath arguments. Uses String.format() to build XPath expression.
      Returns:
      true if the tag is exist
    • evalToBoolean

      Boolean evalToBoolean(String relativeXpath, Object... arguments)
      Evaluate the given XPath expression against the current node and return the result as a Boolean.
      Parameters:
      relativeXpath - The XPath expression
      arguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
      Returns:
      The XPathConstants.BOOLEAN return type
    • evalToNumber

      Number evalToNumber(String relativeXpath, Object... arguments)
      Evaluate the given XPath expression against the current node and return the result as a Number.
      Parameters:
      relativeXpath - The XPath expression
      arguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
      Returns:
      The XPathConstants.NUMBER return type
    • evalToString

      String evalToString(String relativeXpath, Object... arguments)
      Evaluate the given XPath expression against the current node and return the result as a String.
      Parameters:
      relativeXpath - The XPath expression
      arguments - facultative Xpath expression arguments. Uses String.format() to build XPath expression.
      Returns:
      The XPathConstants.STRING return type
    • getEncoding

      String getEncoding()