Interface XMPNode

All Superinterfaces:
Iterable<XMPNode>
All Known Subinterfaces:
XMPArray, XMPMetadata, XMPQualifiers, XMPSimple, XMPStruct

public interface XMPNode extends Iterable<XMPNode>
The basic node class. Every node in the XMP tree is of this type. It is iterable, so the tree can be iterated without knowing the exact type upfront. In case of a struct it will iterate the child nodes, in case of an array, it will iterate the array items and in the case of a simple property (leaf node) it will return null or a qualifier, if it has any.
  • Method Details

    • iterator

      Iterator<XMPNode> iterator()
      An unmodifiable Iterator that iterates over the child elements of this node. If the node has no child elements, an empty iterator is returned. An eventual existing Qualifier Struct will not be visited by this iterator.
      Specified by:
      iterator in interface Iterable<XMPNode>
    • accept

      void accept(XMPNodeVisitor visitor)
      Executes the provided visitor
      Parameters:
      visitor - the Visitor to execute
    • accessQualifiers

      XMPQualifiers accessQualifiers()
      Get a qualifier "facade" for this Node that allows management of qualifiers. Qualifiers are not part of the list of children of the node and can only be accessed through this helper object. Qualifier can be added to any node in the tree except XMPMetadata and Qualifiers itself.
      Returns:
      the XMPQualifier facade or null if no qualifiers can be added to this node.
    • getName

      String getName()
      Returns the name of this node or null if it has no name
      Returns:
      the name of this node or null if it has no name
    • getParent

      XMPNode getParent()
      gets the parent of this node.
      Returns:
      returns the parent of this node or null if it has none (example: root element)
    • getNamespace

      String getNamespace()
      returns the namespace URI of this node
      Returns:
      the namespace URI or null, if this node is not qualified
    • adaptTo

      <AdapterType> AdapterType adaptTo(Class<AdapterType> type)
      Save Cast to the type that is passed. If the node is not of this type it will return null.
      Parameters:
      type - The class type this object should be casted to
      Returns:
      the object casted to the desired type or null if the cast fails
    • copyReplace

      void copyReplace(XMPNode copyFrom)
      Overwrites the current node with a deep copy of node which is provided as input. The node from which copying is done should not be null and it should be of same type as this node.
      Parameters:
      copyFrom - XMPNode which has to be copied
      Throws:
      IllegalArgumentException - If node sent as parameter to this method is null.
      IllegalStateException - If this metadata tree is invalid.
    • isArrayItem

      boolean isArrayItem()
      Checks if the node's parent is of type XMPArray.
      Returns:
      True if it is, false otherwise.
    • hasQualifiers

      boolean hasQualifiers()
      Checks if the node has qualifiers attached.
      Returns:
      True if it has, false otherwise.
    • size

      int size()
      Determine the number of node children. For arrays, its the number of elements; for language alternatives the number of languages; for structs, the number of fields and for simple properties it is always zero.
      Returns:
      Returns the number of node children.
    • getXMPPath

      XMPPath getXMPPath()
      Return the path of this XMPNode
      Returns:
      the path of this XMPNode
    • get

      XMPNode get(XMPPath path)
      Return the node of the given path, relative to this node.
      Parameters:
      path - the path to the desired node relative to this node
      Returns:
      the node at the path position or null if it could not be found
    • remove

      XMPNode remove(XMPPath path) throws XMPException
      Remove a node at a given path, relative to this node
      Parameters:
      path - the path to the node that shall be deleted
      Returns:
      the removed node or null, if nothing is removed
      Throws:
      XMPException - throws in case the remove path points to an xml:lang qualifier of a Language Alternative
    • getSimple

      XMPSimple getSimple(XMPPath path)
      Returns a simple property from the given path, relative to this node.
      Parameters:
      path - the path to the simple property, relative to this node.
      Returns:
      the desired simple property or null if there was none (or the type is different)
    • getStruct

      XMPStruct getStruct(XMPPath path)
      Returns a struct property from the given path, relative to this node.
      Parameters:
      path - the path to the struct property, relative to this node.
      Returns:
      the desired struct property or null if there was none (or the type is different)
    • getArray

      XMPArray getArray(XMPPath path)
      Returns an array from the given path, relative to this node.
      Parameters:
      path - the path to the array, relative to this node.
      Returns:
      the desired array or null if there was none (or the type is different)
    • getLanguageAlternative

      XMPLanguageAlternative getLanguageAlternative(XMPPath path)
      Returns a language Alternative from the given path, relative to this node.
      Parameters:
      path - the path to the langAlt, relative to this node.
      Returns:
      the desired langAlt or null if there was none (or the type is different)
    • dump

      String dump()
      returns a human readable version of this node tree (recursive)
      Returns:
      returns a human readable version of this node tree (recursive)