Package org.basex.query.value.seq
Class Seq
java.lang.Object
org.basex.query.expr.ExprInfo
org.basex.query.expr.Expr
org.basex.query.value.Value
org.basex.query.value.seq.Seq
- Direct Known Subclasses:
BlnSeq,BytSeq,DblSeq,DBNodeSeq,DecSeq,FltSeq,IntSeq,ItemSeq,RangeSeq,SingletonSeq,StrSeq,SubSeq,TreeSeq
Sequence, containing at least two items.
- Author:
- BaseX Team 2005-21, BSD License, Christian Gruen
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ValuecopyInsert(long pos, Value value, QueryContext qc) Helper forinsertBefore(long, Value, QueryContext)that copies all items into aTreeSeq.booleanddo()Indicates if this expression returns nodes in document order without duplicates.Returns a string description of the expression.booleanThis function is e.g.static ValueTries to create a typed sequence with the items of the specified values.final intReturns a hash code for this value.static intinitialCapacity(long size) Returns an initial array capacity for the expected result size.abstract Valueinsert(long pos, Item item, QueryContext qc) Inserts an item at the given position into this sequence and returns the resulting sequence.final ValueinsertBefore(long pos, Value value, QueryContext qc) Inserts a value at the given position into this sequence and returns the resulting sequence.final Itemitem(QueryContext qc, InputInfo ii) Evaluates the expression and returns the resulting item, orEmpty.VALUEif the expression yields an empty sequence.iter()Returns an iterator.voidCreates a query plan.voidplan(QueryString qs) Creates a query string.final voidrefineType(Expr expr) Refines the expression type.abstract Valueremove(long pos, QueryContext qc) Removes the item at the given position in this sequence and returns the resulting sequence.final SeqTypeseqType()Returns the static type of the resulting value.final longsize()Returns the result size, or-1if the size is unknown.protected SeqsubSeq(long offset, long length, QueryContext qc) Returns a sub sequence of this value with the given start and length.final Valuesubsequence(long start, long length, QueryContext qc) Returns a subsequence of this value with the given start and length.final Itemtest(QueryContext qc, InputInfo ii) Performs a predicate test and returns the item if the test was successful.final StringReturns a string representation of the expression that can be embedded in error messages.toJava()Returns a Java representation of the value.Methods inherited from class org.basex.query.value.Value
accept, atomSize, cache, checkUp, compile, copy, count, exprSize, has, inline, inlineable, isEmpty, isItem, itemAt, iter, iterator, materialize, reverse, serialize, serialize, serialize, valueMethods inherited from class org.basex.query.expr.Expr
arg, args, atomItem, atomIter, atomValue, data, data, ebv, funcType, hasFreeVars, indexAccessible, isSimple, markTailCalls, mergeEbv, optimize, simplifyFor, typeCheck, uses, vacuous, visitAllMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
size
protected long sizeLength.
-
-
Constructor Details
-
Seq
Constructor, specifying a type.- Parameters:
size- sizetype- exact type,item()*otherwise
-
-
Method Details
-
toJava
Description copied from class:ValueReturns a Java representation of the value.- Specified by:
toJavain classValue- Returns:
- Java object
- Throws:
QueryException- query exception
-
size
public final long size()Description copied from class:ExprReturns the result size, or-1if the size is unknown. -
item
Description copied from class:ExprEvaluates the expression and returns the resulting item, orEmpty.VALUEif the expression yields an empty sequence. If this method is not implemented,Expr.value(QueryContext)must be implemented instead.- Specified by:
itemin classExpr- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- item or
Empty.VALUE - Throws:
QueryException- query exception
-
test
Description copied from class:ExprPerforms a predicate test and returns the item if the test was successful. The returned item is required for full-text scoring.- Specified by:
testin classExpr- Parameters:
qc- query contextii- input info (required forSeqinstances, which have no input info)- Returns:
- item or
null - Throws:
QueryException- query exception
-
iter
Description copied from class:ValueReturns an iterator. -
ddo
public boolean ddo()Description copied from class:ExprIndicates if this expression returns nodes in document order without duplicates. -
subsequence
Description copied from class:ValueReturns 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:
subsequencein classValue- Parameters:
start- starting positionlength- number of itemsqc- query context- Returns:
- sub sequence
-
subSeq
Returns a sub sequence of this value with the given start and length.- Parameters:
offset- offset (ge 0)length- number of items (1 lt length lt size())qc- query context- Returns:
- sub sequence
-
insertBefore
Inserts a value at the given position into this sequence and returns the resulting sequence.- Parameters:
pos- position at which the value should be inserted, must be between 0 andsizevalue- value to insertqc- query context- Returns:
- resulting value
-
insert
Inserts an item at the given position into this sequence and returns the resulting sequence.- Parameters:
pos- position at which the item should be inserted, must be between 0 andsizeitem- item to insertqc- query context- Returns:
- resulting value
-
copyInsert
Helper forinsertBefore(long, Value, QueryContext)that copies all items into aTreeSeq.- Parameters:
pos- position at which the value should be inserted, must be between 0 andsizevalue- value to insertqc- query context- Returns:
- resulting value
-
remove
Removes the item at the given position in this sequence and returns the resulting sequence.- Parameters:
pos- position of the item to remove, must be between 0 andsize- 1qc- query context- Returns:
- resulting sequence
-
refineType
Description copied from class:ExprRefines the expression type.- Specified by:
refineTypein classExpr- Parameters:
expr- original expression
-
hash
Description copied from class:ValueReturns a hash code for this value.- Specified by:
hashin classValue- Parameters:
ii- input info- Returns:
- hash code
- Throws:
QueryException- if atomization can't be applied (e.g. function item)
-
seqType
Description copied from class:ExprReturns the static type of the resulting value. -
equals
Description copied from class:ExprThis function is e.g. called by:If.optimize(CompileContext),Switch.optimize(CompileContext),Typeswitch.optimize(CompileContext), in order to discard identical expressions.CmpR.mergeEbv(Expr, boolean, CompileContext)orCmpSR.mergeEbv(Expr, boolean, CompileContext), in order to merge expressions with identical input.CmpG.optimize(CompileContext)orCmpV.optimize(CompileContext), in order to pre-evaluate equality tests.CmpG.optimize(CompileContext)orPos.get(Expr, CmpV.OpV, InputInfo, CompileContext), in order to compare the start and end value.PathCache, in order to find identical root values at runtime.
-
description
Description copied from class:ExprInfoReturns a string description of the expression. This method is only called by error messages. Contrary to theExprInfo.toString()method, arguments are not included in the output.- Overrides:
descriptionin classExprInfo- Returns:
- result of check
-
plan
Description copied from class:ExprInfoCreates a query plan. -
toErrorString
Description copied from class:ExprInfoReturns a string representation of the expression that can be embedded in error messages. Defaults toExprInfo.toString().- Overrides:
toErrorStringin classExprInfo- Returns:
- class name
-
plan
Description copied from class:ExprInfoCreates a query string. -
get
Tries to create a typed sequence with the items of the specified values.- Parameters:
size- size of resulting sequencevalues- valuestype- type- Returns:
- value, or
nullif sequence could not be created - Throws:
QueryException- query exception
-
initialCapacity
Returns an initial array capacity for the expected result size. Throws an exception if the requested size will take too much memory.- Parameters:
size- expected result size- Returns:
- capacity
- Throws:
QueryException- query exception
-