Interface XMQNode

All Known Subinterfaces:
XMQAttr, XMQDoc, XMQDtd, XMQElement, XMQEntityDecl

public interface XMQNode
Base of all nodes in the xmq DOM: documents, elements, attributes, text, comments, dtds and so on. The DOM is modelled after libxml2, the nodes are linked with parent/children/next/prev pointers, entity references are kept as nodes, and adding a text node next to another text node merges them. Like XMQNode in xmq.h.
  • Method Summary

    Modifier and Type
    Method
    Description
    Add a child like xmqAddChild.
    Insert a sibling after this node, like xmqAddNextSibling (but without text merging).
    Insert a sibling before this node, like xmqAddPrevSibling (but without text merging).
    Append a child without merging adjacent text nodes.
    Returns a new list with the children of this node.
    Returns the text content of text like nodes (text, cdata, comment, pi).
    doc()
    Returns the document owning this node.
    Returns the first child.
    Returns the full name, ie prefix:name if the node has a namespace with a prefix.
    Returns the last child.
    int
    Returns the source line of the node, like xmqGetLineNumber: elements get the line where their start tag ends, text the line where its first chunk was read, comments, processing instructions and cdata sections the line where they end.
    Returns the name of the node.
    Returns the next sibling.
    int
    Returns the number of children.
    Returns the parent node.
    Returns the previous sibling.
    void
    Replace this node with another node, like xmqReplaceNode.
    void
    setContent(String content)
    Set the content of a text like node.
    void
    setLine(int line)
    Set the source line of the node.
    void
    Set the name of the node.
    Returns the string value of the node, like xmqGetString.
    Returns the type of this node.
    void
    Remove this node from its parent and siblings, like xmqUnlinkNode.
  • Method Details

    • type

      XMQNodeType type()
      Returns the type of this node.
      Returns:
      The node type.
    • name

      String name()
      Returns the name of the node. For an element or attribute this is the local name (without namespace prefix). For a pi it is the target, for an entity reference or declaration it is the entity name.
      Returns:
      The name or null.
    • setName

      void setName(String name)
      Set the name of the node.
      Parameters:
      name - The new name.
    • line

      int line()
      Returns the source line of the node, like xmqGetLineNumber: elements get the line where their start tag ends, text the line where its first chunk was read, comments, processing instructions and cdata sections the line where they end.
      Returns:
      The line, 0 if unknown.
    • setLine

      void setLine(int line)
      Set the source line of the node.
      Parameters:
      line - The line.
    • parent

      XMQNode parent()
      Returns the parent node.
      Returns:
      The parent or null.
    • next

      XMQNode next()
      Returns the next sibling.
      Returns:
      The next sibling or null.
    • prev

      XMQNode prev()
      Returns the previous sibling.
      Returns:
      The previous sibling or null.
    • doc

      XMQDoc doc()
      Returns the document owning this node.
      Returns:
      The document or null.
    • firstChild

      XMQNode firstChild()
      Returns the first child.
      Returns:
      The first child or null.
    • lastChild

      XMQNode lastChild()
      Returns the last child.
      Returns:
      The last child or null.
    • children

      List<XMQNode> children()
      Returns a new list with the children of this node.
      Returns:
      The children, an empty list if none.
    • numChildren

      int numChildren()
      Returns the number of children.
      Returns:
      The number of children.
    • content

      String content()
      Returns the text content of text like nodes (text, cdata, comment, pi). Returns null for other nodes, use textContent() for the concatenated text of an element.
      Returns:
      The content or null.
    • setContent

      void setContent(String content)
      Set the content of a text like node. For an element, all children are replaced with a single text node, like xmqSetNodeContent.
      Parameters:
      content - The new content.
    • textContent

      String textContent()
      Returns the string value of the node, like xmqGetString. For an element this is the concatenation of all descendant text, where entity references contribute nothing (entities are never expanded implicitly) and character references kept as nodes their character.
      Returns:
      The text content, never null.
    • appendRaw

      XMQNode appendRaw(XMQNode child)
      Append a child without merging adjacent text nodes.
      Parameters:
      child - The child to append, it is unlinked first.
      Returns:
      The child.
    • addChild

      XMQNode addChild(XMQNode child)
      Add a child like xmqAddChild. If the child is a text node and the current last child is also a text node, then the text is merged into the existing last child, and the existing node is returned.
      Parameters:
      child - The child to add.
      Returns:
      The node holding the child content.
    • addPrevSibling

      XMQNode addPrevSibling(XMQNode n)
      Insert a sibling before this node, like xmqAddPrevSibling (but without text merging).
      Parameters:
      n - The node to insert.
      Returns:
      The inserted node.
    • addNextSibling

      XMQNode addNextSibling(XMQNode n)
      Insert a sibling after this node, like xmqAddNextSibling (but without text merging).
      Parameters:
      n - The node to insert.
      Returns:
      The inserted node.
    • unlink

      void unlink()
      Remove this node from its parent and siblings, like xmqUnlinkNode.
    • replaceWith

      void replaceWith(XMQNode n)
      Replace this node with another node, like xmqReplaceNode.
      Parameters:
      n - The replacement.
    • fullName

      String fullName()
      Returns the full name, ie prefix:name if the node has a namespace with a prefix.
      Returns:
      The full name.