Class Node

All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
AbstractLocation, AbstractTemplate, Document, Edge, LscElement, Nail, Query, QueryList

public class Node
extends Element
Nodes are elements that can be placed in a tree structure represented by references to the parent, the first child and left and right siblings.
See Also:
Serialized Form
  • Field Details

    • public Node previous
      The left sibling of this element.
    • public Node next
      The right sibling of this element.
    • first

      public Node first
      First child of this element.
  • Constructor Details

    • Node

      public Node​(Element prototype)
      constructor
      Parameters:
      prototype - - The prototype of the node
  • Method Details

    • getPrevious

      public Node getPrevious()
      Returns the left sibling.
      Returns:
      The previous node
    • getNext

      public Node getNext()
      Returns the right sibling.
      Returns:
      the next node
    • getFirst

      public Node getFirst()
      Returns the first child.
      Returns:
      The first node
    • getLast

      public Node getLast()
      Returns the last child.
      Returns:
      The last node
    • accept

      public void accept​(Visitor visitor) throws Exception
      Description copied from class: Element
      Accept a visitor. This method is specialized in every subclass. Part of the visitor pattern.
      Overrides:
      accept in class Element
      Parameters:
      visitor - - The visitor
      Throws:
      Exception - the visitor threw an exception.
    • insert

      public Node insert​(Node node, Node position)
      Insert a child node. The node is inserted after the given position, or as the first child if the position is null. Fires an insertion event on the child. Returns the node argument.
      Parameters:
      node - - The new node
      position - - The insert position
      Returns:
      The insert node
    • move

      public Node move​(Node child, Node position)
      Move a child node among siblings. The node is moved after the given position, or as the first child if the position is null. Fires a move event on the child node. Returns this node.
      Parameters:
      child - - The child node
      position - - The position
      Returns:
      The moved node
    • remove

      public void remove()
      Remove the node from the tree structure. Removal events are fired after the actual removal. The node does not retain its parent reference, but the sibling references are preserved (thus making it possible to remove elements from within a visitor).
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a deep clone of the node. The sibling references of the clone are set to null.
      Overrides:
      clone in class Element
      Returns:
      The cloned object
      Throws:
      CloneNotSupportedException - an object cannot be cloned.
    • setPrototype

      public void setPrototype​(Element prototype)
      Sets the prototype of this element to the given argument. It also recursively reimports all properties and children by calling importInto(this) (thus resetting the prototype structure throughout the tree).
      Overrides:
      setPrototype in class Element
      Parameters:
      prototype - - The property element
    • getXPathTag

      public String getXPathTag()
      Description copied from class: Element
      Computes the local tag of the XPath address. Needs to be overwritten by concrete instances
      Overrides:
      getXPathTag in class Element
      Returns:
      local address of this element