Class DBNodes

All Implemented Interfaces:
Iterable<Item>

public final class DBNodes extends DBNodeSeq
This class stores database nodes in an ascending order. Instances of this class will be returned by the method QueryProcessor.cache(int) method. They are used in the GUI and in the Context class to reference currently opened, marked, and copied database nodes.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • DBNodes

      public DBNodes(Data data, int... pres)
      Constructor, specifying a database and pre values.
      Parameters:
      data - data reference
      pres - pre values
    • DBNodes

      public DBNodes(Data data, boolean all, int... pres)
      Constructor, specifying a database, pre values and full-text positions.
      Parameters:
      all - pre values reference all documents of the database
      data - data reference
      pres - pre values
  • Method Details

    • ftpos

      public DBNodes ftpos(FTPosData ft)
      Assigns full-text position data.
      Parameters:
      ft - full-text positions
      Returns:
      self reference
    • ftpos

      public FTPosData ftpos()
      Returns full-text position data.
      Returns:
      position data
    • discardDocs

      public DBNodes discardDocs()
      Returns null if the pre values reference all documents of the database.
      Returns:
      self reference or null
    • contains

      public boolean contains(int pre)
      Checks if the specified node is contained in the array.
      Parameters:
      pre - pre value
      Returns:
      true if the node was found
    • find

      public int find(int pre)
      Returns the position of the specified node or the negative value - 1 of the position where it should have been found.
      Parameters:
      pre - pre value
      Returns:
      position, or -1
    • toggle

      public void toggle(int pre)
      Adds or removes the specified pre node.
      Parameters:
      pre - pre value
    • union

      public void union(int[] pre)
      Merges the specified array with the existing pre nodes.
      Parameters:
      pre - pre value
    • sorted

      public int sorted(int index)
      Returns a sorted pre value.
      Parameters:
      index - index of pre value
      Returns:
      pre value
    • itemAt

      public DBNode itemAt(long pos)
      Description copied from class: Value
      Returns the item at the given position in the value. The specified value must be lie within the valid bounds.
      Overrides:
      itemAt in class DBNodeSeq
      Parameters:
      pos - position
      Returns:
      item
    • equals

      public boolean equals(Object obj)
      Description copied from class: Expr
      This function is e.g. called by:
      Overrides:
      equals in class DBNodeSeq
    • cache

      public final void cache(boolean lazy, InputInfo ii)
      Description copied from class: Value
      Caches lazy values.
      Specified by:
      cache in class Value
      Parameters:
      lazy - lazy caching
      ii - input info
    • atomSize

      public final long atomSize()
      Description copied from class: Value
      Computes the number of atomized items.
      Specified by:
      atomSize in class Value
      Returns:
      atomized item
    • insert

      public final Value insert(long pos, Item item, QueryContext qc)
      Inserts an item at the given position into this sequence and returns the resulting sequence. Because this function will mostly be invoked recursively, the standard implementation will be called, because its runtime outweighs the possibly higher memory consumption.
      Specified by:
      insert in class Seq
      Parameters:
      pos - position at which the item should be inserted, must be between 0 and Seq.size
      item - item to insert
      qc - query context
      Returns:
      resulting value
    • remove

      public final Value remove(long pos, QueryContext qc)
      Removes the item at the given position in this sequence and returns the resulting sequence. Because this function will mostly be invoked recursively, the standard implementation will be called, because its runtime outweighs the possibly higher memory consumption.
      Specified by:
      remove in class Seq
      Parameters:
      pos - position of the item to remove, must be between 0 and Seq.size - 1
      qc - query context
      Returns:
      resulting sequence