Class SingletonSeq

All Implemented Interfaces:
Iterable<Item>

public final class SingletonSeq extends Seq
Sequence of a single item.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Method Details

    • ebv

      public Item ebv(QueryContext qc, InputInfo ii) throws QueryException
      Description copied from class: Expr

      Checks if the effective boolean value can be computed for this expression:

      • If it yields an empty sequence, Bln.FALSE will be returned.
      • If it yields a single item, this item will be returned.
      • If it yields nodes, the first node will be returned.
      • Otherwise, an error will be raised.

      A single numeric item may later be evaluated as positional predicate.

      Specified by:
      ebv in class Expr
      Parameters:
      qc - query context
      ii - input info (required for Seq instances, which have no input info)
      Returns:
      item
      Throws:
      QueryException - query exception
    • cache

      public void cache(boolean lazy, InputInfo ii) throws QueryException
      Description copied from class: Value
      Caches lazy values.
      Specified by:
      cache in class Value
      Parameters:
      lazy - lazy caching
      ii - input info
      Throws:
      QueryException - query exception
    • atomValue

      public Value atomValue(QueryContext qc, InputInfo ii) throws QueryException
      Description copied from class: Expr
      Evaluates the expression and returns the atomized items.
      Specified by:
      atomValue in class Expr
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      atomized item
      Throws:
      QueryException - query exception
    • atomSize

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

      protected Seq subSeq(long offset, long length, QueryContext qc)
      Description copied from class: Seq
      Returns a sub sequence of this value with the given start and length.
      Overrides:
      subSeq in class Seq
      Parameters:
      offset - offset (ge 0)
      length - number of items (1 lt length lt size())
      qc - query context
      Returns:
      sub sequence
    • insert

      public Value insert(long pos, Item item, QueryContext qc)
      Description copied from class: Seq
      Inserts an item at the given position into this sequence and returns the resulting sequence.
      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 Value remove(long pos, QueryContext qc)
      Description copied from class: Seq
      Removes the item at the given position in this sequence and returns the resulting sequence.
      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
    • reverse

      public Value reverse(QueryContext qc)
      Description copied from class: Value
      Returns all items of this value in reverse order.
      Specified by:
      reverse in class Value
      Parameters:
      qc - query context
      Returns:
      items in reverse order
    • itemAt

      public Item 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.
      Specified by:
      itemAt in class Value
      Parameters:
      pos - position
      Returns:
      item
    • simplifyFor

      public Expr simplifyFor(CompileContext.Simplify mode, CompileContext cc) throws QueryException
      Description copied from class: Expr
      This function is called at compile time for expressions whose operands might be simplified.
      Overrides:
      simplifyFor in class Expr
      Parameters:
      mode - mode of simplification
      cc - compilation context
      Returns:
      simplified or original expression
      Throws:
      QueryException - query exception
      See Also:
    • description

      public String description()
      Description copied from class: ExprInfo
      Returns a string description of the expression. This method is only called by error messages. Contrary to the ExprInfo.toString() method, arguments are not included in the output.
      Overrides:
      description in class Seq
      Returns:
      result of check
    • plan

      public void plan(QueryPlan plan)
      Description copied from class: ExprInfo
      Creates a query plan.
      Overrides:
      plan in class Seq
      Parameters:
      plan - expression plan
    • plan

      public void plan(QueryString qs)
      Description copied from class: ExprInfo
      Creates a query string.
      Overrides:
      plan in class Seq
      Parameters:
      qs - query string builder
    • singleItem

      public boolean singleItem()
      Indicates if the sequence is based on a single item.
      Returns:
      result of check
    • get

      public static Value get(Value value, long count)
      Creates a singleton sequence with the specified value.
      Parameters:
      value - value
      count - number of repetitions
      Returns:
      value