Package org.basex.query.value.array
Class XQArray
- All Implemented Interfaces:
Iterable<Item>,XQFunction,XQFunctionExpr
An array storing
Values.- Author:
- BaseX Team 2005-21, BSD License, Leo Woerteler
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract longReturns the number of elements in this array.final ItematomItem(QueryContext qc, InputInfo ii) Evaluates the expression and returns the resulting, atomized item, orEmpty.VALUEif the expression yields an empty sequence.final longatomSize()Computes the number of atomized items.final ValueatomValue(QueryContext qc, InputInfo ii) Evaluates the expression and returns the atomized items.final voidCaches lazy values.abstract XQArrayConcatenates this array with another one.abstract XQArrayPrepends an element to the front of this array.final booleanPerforms a deep comparison of two items.final StringReturns a string description of the expression.static XQArrayempty()The empty array.static XQArrayCreates an array containing the given elements.abstract Valueget(long index) Gets the element at the given position in this array.final ValueGets a value from this item.abstract Valuehead()First element of this array, equivalent toarray.get(0).abstract XQArrayinit()Initial segment of this array, i.e.abstract XQArrayinsertBefore(long pos, Value value, QueryContext qc) Inserts the given element at the given position into this array.booleaninstanceOf(Type tp) Checks if this item is instance of the specified type.abstract booleanChecks if this array is empty.abstract ListIterator<Value>iterator(long start) Iterator over the members of this array.abstract Valuelast()Last element of this array, equivalent toarray.get(array.arraySize() - 1).materialize(QueryContext qc, boolean copy) Returns a materialized, context-independent version of this item.members()Iterator over the members of this array.final QNmparamName(int pos) Name of the parameter at the given position.final voidCreates a query plan.voidplan(QueryString qs) Creates a query string.abstract XQArrayReturns a copy of this array where the entry at the given position is replaced by the given value.abstract XQArrayremove(long pos, QueryContext qc) Removes the element at the given position in this array.abstract XQArrayReturns an array with the same elements as this one, but their order reversed.static XQArrayCreates a singleton array containing the given element.abstract XQArrayAppends an element to the back of this array.final voidstring(boolean indent, TokenBuilder tb, int level, InputInfo ii) Returns a string representation of the item.abstract XQArraysubArray(long pos, long len, QueryContext qc) Extracts a contiguous part of this array.abstract XQArraytail()Tail segment of this array, i.e.final Object[]toJava()Returns a Java representation of the value.Methods inherited from class org.basex.query.value.item.XQData
arity, coerceTo, equals, funcName, inline, invokeInternal, stackFrameSize, vacuousBodyMethods inherited from class org.basex.query.value.item.FItem
annotations, eq, funcType, refineType, sameKey, stringMethods inherited from class org.basex.query.value.item.Item
bool, comparable, dbl, ddo, dec, diff, ebv, equiv, flt, hash, input, item, itemAt, iter, itr, persistent, reverse, score, seqType, size, subsequence, test, typeId, xdmInfoMethods inherited from class org.basex.query.value.Value
accept, checkUp, compile, copy, count, exprSize, has, inline, inlineable, isEmpty, isItem, iter, iterator, materialize, serialize, serialize, serialize, valueMethods inherited from class org.basex.query.expr.Expr
arg, args, atomIter, data, data, hasFreeVars, indexAccessible, isSimple, markTailCalls, mergeEbv, optimize, simplifyFor, typeCheck, uses, vacuous, visitAllMethods inherited from class org.basex.query.expr.ExprInfo
toErrorString, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.basex.query.func.XQFunction
invoke, invokeTail
-
Method Details
-
empty
The empty array. Running time: O(1) and no allocation- Returns:
- (unique) instance of an empty array
-
singleton
Creates a singleton array containing the given element.- Parameters:
elem- the contained element- Returns:
- the singleton array
-
from
Creates an array containing the given elements.- Parameters:
values- elements- Returns:
- the resulting array
-
cons
Prepends an element to the front of this array. Running time: O(1)*- Parameters:
elem- element to prepend- Returns:
- resulting array
-
snoc
Appends an element to the back of this array. Running time: O(1)*- Parameters:
elem- element to append- Returns:
- resulting array
-
get
Gets the element at the given position in this array. Running time: O(log n)- Parameters:
index- index of the element to get- Returns:
- the corresponding element
-
put
Returns a copy of this array where the entry at the given position is replaced by the given value.- Parameters:
pos- position of the entry to replacevalue- value to put into this array- Returns:
- resulting array
-
arraySize
public abstract long arraySize()Returns the number of elements in this array. Running time: O(1)- Returns:
- number of elements
-
concat
Concatenates this array with another one. Running time: O(log (min { this.arraySize(), other.arraySize() }))- Parameters:
other- array to append to the end of this array- Returns:
- resulting array
-
head
First element of this array, equivalent toarray.get(0). Running time: O(1)- Returns:
- the first element
-
last
Last element of this array, equivalent toarray.get(array.arraySize() - 1). Running time: O(1)- Returns:
- last element
-
init
Initial segment of this array, i.e. an array containing all elements of this array (in the same order), except for the last one. Running time: O(1)*- Returns:
- initial segment
-
tail
Tail segment of this array, i.e. an array containing all elements of this array (in the same order), except for the first one. Running time: O(1)*- Returns:
- tail segment
-
subArray
Extracts a contiguous part of this array.- Parameters:
pos- position of first elementlen- number of elementsqc- query context- Returns:
- the sub-array
-
reverseArray
Returns an array with the same elements as this one, but their order reversed. Running time: O(n)- Parameters:
qc- query context- Returns:
- reversed version of this array
-
isEmptyArray
public abstract boolean isEmptyArray()Checks if this array is empty. Running time: O(1)- Returns:
trueif the array is empty,falseotherwise
-
insertBefore
Inserts the given element at the given position into this array. Running time: O(log n)- Parameters:
pos- insertion position, must be between0andarraySize()value- element to insertqc- query context- Returns:
- resulting array
-
remove
Removes the element at the given position in this array. Running time: O(log n)- Parameters:
pos- deletion position, must be between0andarraySize() - 1qc- query context- Returns:
- resulting array
-
cache
Description copied from class:Item- Overrides:
cachein classItem- Parameters:
lazy- lazy cachingii- input info- Throws:
QueryException- query exception
-
iterator
Iterator over the members of this array.- Parameters:
start- starting position (i.e. the position initially returned byListIterator.nextIndex())- Returns:
- array over the array members
-
members
Iterator over the members of this array.- Returns:
- array over the array members
-
get
Description copied from class:XQDataGets a value from this item.- Specified by:
getin classXQData- Parameters:
key- key to look for (must not benull)ii- input info- Returns:
- bound value if found, the empty sequence
()otherwise - Throws:
QueryException- query exception
-
paramName
Description copied from interface:XQFunctionExprName of the parameter at the given position.- Parameters:
pos- position of the parameter- Returns:
- name of the parameter
-
atomValue
Description copied from class:ItemEvaluates the expression and returns the atomized items. Overwritten byXQArray,FuncItemandANode.- Overrides:
atomValuein classItem- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- atomized item
- Throws:
QueryException- query exception
-
atomItem
Description copied from class:ItemEvaluates the expression and returns the resulting, atomized item, orEmpty.VALUEif the expression yields an empty sequence. Overwritten byXQArray,FuncItemandANode.- Overrides:
atomItemin classItem- Parameters:
qc- query contextii- input info (only required bySeqinstances, which have no input info)- Returns:
- item or
Empty.VALUE - Throws:
QueryException- query exception
-
atomSize
public final long atomSize()Description copied from class:ItemComputes the number of atomized items. Overwritten byXQArray. -
string
public final void string(boolean indent, TokenBuilder tb, int level, InputInfo ii) throws QueryException Description copied from class:XQDataReturns a string representation of the item.- Specified by:
stringin classXQData- Parameters:
indent- indent outputtb- token builderlevel- current levelii- input info- Throws:
QueryException- query exception
-
materialize
Description copied from class:ItemReturns a materialized, context-independent version of this item.- Overrides:
materializein classItem- Parameters:
qc- query context (ifnull, process cannot be interrupted)copy- create full copy- Returns:
- item copy, or
null) if the item cannot be materialized
-
instanceOf
Description copied from class:Item- Overrides:
instanceOfin classItem- Parameters:
tp- type- Returns:
- result of check
-
deep
Description copied from class:FItemPerforms a deep comparison of two items.- Specified by:
deepin classFItem- Parameters:
item- item to be comparedcoll- collation (can benull)ii- input info- Returns:
- result of check
- Throws:
QueryException- query exception
-
toJava
Description copied from class:ValueReturns a Java representation of the value.- Specified by:
toJavain classValue- Returns:
- Java object
- Throws:
QueryException- query exception
-
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 classItem- Returns:
- result of check
-
plan
Description copied from class:ExprInfoCreates a query plan. -
plan
Description copied from class:ExprInfoCreates a query string.
-