Class ANode

All Implemented Interfaces:
Iterable<Item>
Direct Known Subclasses:
DBNode, FNode

public abstract class ANode extends Item
Abstract node type.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Details

    • id

      public final int id
      Unique node id. ID can get negative, as subtraction of ids is used for all comparisons.
  • Method Details

    • bool

      public final boolean bool(InputInfo ii)
      Description copied from class: Item
      Returns a boolean representation of the value.
      Overrides:
      bool in class Item
      Parameters:
      ii - input info (can be null)
      Returns:
      boolean value
    • string

      public final byte[] string(InputInfo ii)
      Description copied from class: Item
      Returns a string representation of the value.
      Specified by:
      string in class Item
      Parameters:
      ii - input info (can be null)
      Returns:
      string value
    • string

      public abstract byte[] string()
      Returns the string value.
      Returns:
      string value
    • comparable

      public final boolean comparable(Item item)
      Description copied from class: Item
      Checks if the items can be compared.
      Overrides:
      comparable in class Item
      Parameters:
      item - item to be compared
      Returns:
      result of check
    • eq

      public final boolean eq(Item item, Collation coll, StaticContext sc, InputInfo ii) throws QueryException
      Description copied from class: Item
      Compares the items for equality.
      Specified by:
      eq in class Item
      Parameters:
      item - item to be compared
      coll - collation (can be null)
      sc - static context; required for comparing items of type xs:QName (can be null)
      ii - input info (can be null)
      Returns:
      result of check
      Throws:
      QueryException - query exception
    • sameKey

      public boolean sameKey(Item item, InputInfo ii) throws QueryException
      Description copied from class: Item
      Compares the items for equality.
      Overrides:
      sameKey in class Item
      Parameters:
      item - item to be compared
      ii - input info (can be null)
      Returns:
      result of check
      Throws:
      QueryException - query exception
    • diff

      public final int diff(Item item, Collation coll, InputInfo ii) throws QueryException
      Description copied from class: Item
      Returns the difference between the current and the specified item. This function is overwritten by the corresponding implementations.
      Overrides:
      diff in class Item
      Parameters:
      item - item to be compared
      coll - collation (can be null)
      ii - input info (can be null)
      Returns:
      difference
      Throws:
      QueryException - query exception
    • atomValue

      public final Item atomValue(QueryContext qc, InputInfo ii)
      Description copied from class: Item
      Evaluates the expression and returns the atomized items. Overwritten by XQArray, FuncItem and ANode.
      Overrides:
      atomValue in class Item
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      atomized item
    • atomItem

      public final Item atomItem(QueryContext qc, InputInfo ii)
      Description copied from class: Item
      Evaluates the expression and returns the resulting, atomized item, or Empty.VALUE if the expression yields an empty sequence. Overwritten by XQArray, FuncItem and ANode.
      Overrides:
      atomItem in class Item
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      item or Empty.VALUE
    • atomItem

      public Item atomItem()
      Returns an atomic item.
      Returns:
      item
    • ddo

      public boolean ddo()
      Description copied from class: Expr
      Indicates if this expression returns nodes in document order without duplicates.
      Overrides:
      ddo in class Item
      Returns:
      result of check
    • materialize

      public abstract ANode materialize(QueryContext qc, boolean copy)
      Description copied from class: Item
      Returns a materialized, context-independent version of this item.
      Overrides:
      materialize in class Item
      Parameters:
      qc - query context (if null, process cannot be interrupted)
      copy - create full copy
      Returns:
      item copy, or null) if the item cannot be materialized
    • copy

      public final DBNode copy(QueryContext qc)
      Creates a database node copy from this node.
      Parameters:
      qc - query context
      Returns:
      database node
    • copy

      public final DBNode copy(MainOptions options, QueryContext qc)
      Creates a database node copy from this node.
      Parameters:
      options - main options
      qc - query context (can be null; if supplied, allows interruption of process)
      Returns:
      database node
    • finish

      public abstract ANode finish()
      Returns a finalized node instance. This method is called when iterating through node results: If a single node instances is recycled, it needs to be duplicated in the final step.
      Returns:
      node
    • name

      public byte[] name()
      Returns the name (optional prefix, local name) of an attribute, element or processing instruction. This function is possibly evaluated faster than qname(), as no QNm instance may need to be created.
      Returns:
      name, or null if node has no name
    • qname

      public QNm qname()
      Returns the QName (optional prefix, local name) of an attribute, element or processing instruction.
      Returns:
      name, or null if node has no QName
    • optimize

      public ANode optimize()
      Minimizes the memory consumption of the node.
      Returns:
      self reference
    • namespaces

      public Atts namespaces()
      Returns all namespaces defined for the nodes. Overwritten by FElem and DBNode.
      Returns:
      namespace array or null
    • nsScope

      public final Atts nsScope(StaticContext sc)
      Returns a copy of the namespace hierarchy.
      Parameters:
      sc - static context (can be null)
      Returns:
      namespaces
    • uri

      public final byte[] uri(byte[] pref)
      Recursively finds the uri for the specified prefix.
      Parameters:
      pref - prefix
      Returns:
      uri or null
    • baseURI

      public byte[] baseURI()
      Returns the base URI of the node.
      Returns:
      base URI
    • is

      public abstract boolean is(ANode node)
      Checks if two nodes are identical.
      Parameters:
      node - node to be compared
      Returns:
      result of check
    • diff

      public abstract int diff(ANode node)
      Checks the document order of two nodes.
      Parameters:
      node - node to be compared
      Returns:
      0 if the nodes are identical, or 1/-1 if the node appears after/before the argument
    • root

      public final ANode root()
      Returns the root of a node (the topmost ancestor without parent node).
      Returns:
      root node
    • parent

      public abstract ANode parent()
      Returns the parent node.
      Returns:
      parent node or null
    • parent

      public abstract void parent(FNode par)
      Sets the parent node.
      Parameters:
      par - parent node
    • hasChildren

      public abstract boolean hasChildren()
      Indicates if the node has children.
      Returns:
      result of test
    • attribute

      public byte[] attribute(byte[] name)
      Returns the value of the specified attribute.
      Parameters:
      name - attribute to be found
      Returns:
      attribute value or null
    • attribute

      public byte[] attribute(QNm name)
      Returns the value of the specified attribute.
      Parameters:
      name - attribute to be found
      Returns:
      attribute value or null
    • ancestorIter

      public BasicNodeIter ancestorIter()
      Returns a light-weight, low-level ancestor axis iterator. Before nodes are added to the result, they must be finalized via finish(). Overwritten by DBNode.ancestorIter().
      Returns:
      iterator
    • ancestorOrSelfIter

      public BasicNodeIter ancestorOrSelfIter()
      Returns a light-weight ancestor-or-self axis iterator. Before nodes are added to the result, they must be finalized via finish(). Overwritten by DBNode.ancestorOrSelfIter().
      Returns:
      iterator
    • attributeIter

      public abstract BasicNodeIter attributeIter()
      Returns a light-weight, low-level attribute axis iterator with Iter.size() and Iter.get(long) implemented. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • childIter

      public abstract BasicNodeIter childIter()
      Returns a light-weight, low-level child axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • descendantIter

      public abstract BasicNodeIter descendantIter()
      Returns a light-weight, low-level descendant axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • descendantOrSelfIter

      public abstract BasicNodeIter descendantOrSelfIter()
      Returns a light-weight, low-level descendant-or-self axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • followingIter

      public BasicNodeIter followingIter()
      Returns a light-weight, low-level following axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • followingSiblingIter

      public BasicNodeIter followingSiblingIter()
      Returns a light-weight, low-level following-sibling axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • parentIter

      public final BasicNodeIter parentIter()
      Returns a light-weight, low-level parent axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • precedingIter

      public final BasicNodeIter precedingIter()
      Returns a light-weight, low-level preceding axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • precedingSiblingIter

      public final BasicNodeIter precedingSiblingIter()
      Returns a light-weight, low-level preceding-sibling axis iterator. Before nodes are added to the result, they must be finalized via finish().
      Returns:
      iterator
    • selfIter

      public final BasicNodeIter selfIter()
      Returns a self axis iterator.
      Returns:
      iterator
    • kind

      public int kind()
      Returns a database kind for the specified node type.
      Returns:
      node kind
    • kind

      public static int kind(NodeType type)
      Returns a database kind for the specified node type.
      Parameters:
      type - node type
      Returns:
      node kind, or -1 if no corresponding database kind exists
    • type

      public static NodeType type(int k)
      Returns a node type for the specified database kind.
      Parameters:
      k - database kind
      Returns:
      node type
    • toJava

      public abstract BXNode toJava()
      Description copied from class: Value
      Returns a Java representation of the value.
      Specified by:
      toJava in class Value
      Returns:
      Java object
    • nodeType

      public final NodeType nodeType()
      Returns this Node's node type.
      Returns:
      node type