Class RangeSeq

  • All Implemented Interfaces:
    Iterable<Item>

    public final class RangeSeq
    extends Seq
    Range sequence, containing at least two integers.
    Author:
    BaseX Team 2005-24, BSD License, Christian Gruen
    • Method Detail

      • get

        public static Value get​(long start,
                                long size,
                                boolean ascending)
        Returns a value representation of the specified items.
        Parameters:
        start - start value
        size - size
        ascending - ascending order
        Returns:
        resulting item or sequence
      • write

        public void write​(DataOutput out)
                   throws IOException
        Description copied from class: Value
        Writes the data structure to disk.
        Overrides:
        write in class Value
        Parameters:
        out - data output
        Throws:
        IOException - I/O exception
      • ascending

        public boolean ascending()
        Returns whether the order is ascending or descending.
        Returns:
        order
      • min

        public long min()
        Returns the minimum value, ignoring the order.
        Returns:
        minimum value
      • max

        public long max()
        Returns the maximum value, ignoring the order.
        Returns:
        maximum value
      • test

        public boolean test​(QueryContext qc,
                            InputInfo ii,
                            long pos)
                     throws QueryException
        Description copied from class: Expr
        Computes the effective boolean value for this expression.
        Overrides:
        test in class Seq
        Parameters:
        qc - query context
        ii - input info (can be null); required for those Value instances that have no input info)
        pos - position of context item (if 0, perform EBV test)
        Returns:
        item
        Throws:
        QueryException - query exception
      • toJava

        public Object toJava()
        Description copied from class: Value
        Returns a Java representation of the value.
        Overrides:
        toJava in class Seq
        Returns:
        Java object
      • itemAt

        public Int 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
      • subSeq

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

        public Value insertBefore​(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:
        insertBefore 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
      • cache

        public void cache​(boolean lazy,
                          InputInfo ii)
        Description copied from class: Value
        Caches lazy values.
        Overrides:
        cache in class Seq
        Parameters:
        lazy - lazy caching
        ii - input info (can be null)
      • atomValue

        public Value atomValue​(QueryContext qc,
                               InputInfo ii)
        Description copied from class: Expr
        Evaluates the expression and returns the atomized items.
        Overrides:
        atomValue in class Seq
        Parameters:
        qc - query context
        ii - input info (can be null); required for those Value instances that have no input info)
        Returns:
        atomized item
      • sameType

        public boolean sameType()
        Description copied from class: Value
        Checks if all items of the sequence are of the same type.
        Overrides:
        sameType in class Seq
        Returns:
        result of check
      • materialized

        public boolean materialized​(Predicate<Data> test,
                                    InputInfo ii)
        Description copied from class: Value
        Checks if this value is materialized, i.e., contains no persistent database nodes or function items.
        Overrides:
        materialized in class Seq
        Parameters:
        test - check if a contained node can be adopted unchanged
        ii - input info (can be null)
        Returns:
        result of check
      • optimizePos

        public Expr optimizePos​(CmpV.OpV op,
                                CompileContext cc)
        Description copied from class: Expr
        Optimizes an expression for positional access. Overwritten by Int, Range, RangeSeq}.
        Overrides:
        optimizePos in class Expr
        Parameters:
        op - comparison operator
        cc - compilation context
        Returns:
        boolean result, optimized or original expression
      • refineType

        public void refineType()
        Description copied from class: Value
        Computes a more precise sequence type of this value.
        Overrides:
        refineType in class Value
      • 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
      • toXml

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

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