Class Item

All Implemented Interfaces:
Iterable<Item>
Direct Known Subclasses:
ADateDur, ANode, ANum, AStr, Atm, Bin, Bln, Dummy, Empty, FItem, Jav, QNm

public abstract class Item extends Value
Abstract super class for all items.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Details

  • Constructor Details

    • Item

      protected Item(Type type)
      Constructor.
      Parameters:
      type - item type
  • Method Details

    • iter

      public BasicIter<Item> iter()
      Description copied from class: Value
      Returns an iterator.
      Specified by:
      iter in class Value
      Returns:
      iterator
    • item

      public final Item item(QueryContext qc, InputInfo ii)
      Description copied from class: Expr
      Evaluates the expression and returns the resulting item, or Empty.VALUE if the expression yields an empty sequence. If this method is not implemented, Expr.value(QueryContext) must be implemented instead.
      Specified by:
      item in class Expr
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      item or Empty.VALUE
    • itemAt

      public final 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
    • reverse

      public final Item 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
    • ebv

      public Item ebv(QueryContext qc, InputInfo ii)
      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
    • test

      public Item test(QueryContext qc, InputInfo ii) throws QueryException
      Description copied from class: Expr
      Performs a predicate test and returns the item if the test was successful. The returned item is required for full-text scoring.
      Specified by:
      test in class Expr
      Parameters:
      qc - query context
      ii - input info (required for Seq instances, which have no input info)
      Returns:
      item or null
      Throws:
      QueryException - query exception
    • string

      public abstract byte[] string(InputInfo ii) throws QueryException
      Returns a string representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      string value
      Throws:
      QueryException - if the item cannot be atomized (caused by function or streaming items)
    • bool

      public boolean bool(InputInfo ii) throws QueryException
      Returns a boolean representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      boolean value
      Throws:
      QueryException - query exception
    • dec

      public BigDecimal dec(InputInfo ii) throws QueryException
      Returns a decimal representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      decimal value
      Throws:
      QueryException - query exception
    • itr

      public long itr(InputInfo ii) throws QueryException
      Returns an integer (long) representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      long value
      Throws:
      QueryException - query exception
    • flt

      public float flt(InputInfo ii) throws QueryException
      Returns a float representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      float value
      Throws:
      QueryException - query exception
    • dbl

      public double dbl(InputInfo ii) throws QueryException
      Returns a double representation of the value.
      Parameters:
      ii - input info (can be null)
      Returns:
      double value
      Throws:
      QueryException - query exception
    • instanceOf

      public boolean instanceOf(Type tp)
      Checks if this item is instance of the specified type. Overwritten by XQMap and XQArray.
      Parameters:
      tp - type
      Returns:
      result of check
    • comparable

      public boolean comparable(Item item)
      Checks if the items can be compared.
      Parameters:
      item - item to be compared
      Returns:
      result of check
    • eq

      public abstract boolean eq(Item item, Collation coll, StaticContext sc, InputInfo ii) throws QueryException
      Compares the items for equality.
      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
    • equiv

      public final boolean equiv(Item item, Collation coll, InputInfo ii) throws QueryException
      Compares the items for equivalence. As item is equivalent to another if:
      • both numeric values are NaN, or
      • if the items have comparable types and are equal
      Parameters:
      item - item to be compared
      coll - collation (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
      Compares the items for equality.
      Parameters:
      item - item to be compared
      ii - input info (can be null)
      Returns:
      result of check
      Throws:
      QueryException - query exception
    • diff

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

      public BufferInput input(InputInfo ii) throws QueryException
      Returns an input stream.
      Parameters:
      ii - input info (can be null)
      Returns:
      input stream
      Throws:
      QueryException - query exception
    • subsequence

      public Value subsequence(long start, long length, QueryContext qc)
      Description copied from class: Value
      Returns a subsequence of this value with the given start and length. The following properties must hold:
      • start >= 0,
      • length >= 0,
      • length <= size() - start
      Specified by:
      subsequence in class Value
      Parameters:
      start - starting position
      length - number of items
      qc - query context
      Returns:
      sub sequence
    • cache

      public void cache(boolean lazy, InputInfo ii) throws QueryException
      Caches lazy values. Overwritten by Lazy, XQMap and XQArray.
      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
      Evaluates the expression and returns the atomized items. Overwritten by XQArray, FuncItem and ANode.
      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
    • atomItem

      public Item atomItem(QueryContext qc, InputInfo ii) throws QueryException
      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 Expr
      Parameters:
      qc - query context
      ii - input info (only required by Seq instances, which have no input info)
      Returns:
      item or Empty.VALUE
      Throws:
      QueryException - query exception
    • atomSize

      public long atomSize()
      Computes the number of atomized items. Overwritten by XQArray.
      Specified by:
      atomSize in class Value
      Returns:
      atomized item
    • materialize

      public Item materialize(QueryContext qc, boolean copy)
      Returns a materialized, context-independent version of this 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
    • seqType

      public SeqType seqType()
      Description copied from class: Expr
      Returns the static type of the resulting value.
      Specified by:
      seqType in class Expr
      Returns:
      result of check
    • size

      public long size()
      Description copied from class: Expr
      Returns the result size, or -1 if the size is unknown.
      Specified by:
      size in class Expr
      Returns:
      result of check
    • refineType

      public void refineType(Expr expr)
      Description copied from class: Expr
      Refines the expression type.
      Specified by:
      refineType in class Expr
      Parameters:
      expr - original expression
    • ddo

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

      public final boolean persistent()
      Indicates if this item references a persistent database.
      Returns:
      result of check
    • score

      public double score()
      Returns a score value. Overwritten by FTNode.
      Returns:
      score value
    • hash

      public int hash(InputInfo ii) throws QueryException
      Description copied from class: Value
      Returns a hash code for this value.
      Specified by:
      hash in class Value
      Parameters:
      ii - input info
      Returns:
      hash code
      Throws:
      QueryException - if atomization can't be applied (e.g. function item)
    • xdmInfo

      public byte[] xdmInfo()
      Returns data model info. Overwritten by QNm, DBNode, FTxt and FDoc.
      Returns:
      type string
    • typeId

      public Type.ID typeId()
      Returns a type id. Overwritten by DBNode and FDoc.
      Returns:
      type string
    • 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 ExprInfo
      Returns:
      result of check
    • plan

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