MCPcopy Create free account
hub / github.com/BaseXdb/basex / value

Method value

basex-core/src/main/java/org/basex/query/func/fn/FnSlice.java:23–37  ·  view source on GitHub ↗
(final QueryContext qc)

Source from the content-addressed store, hash-verified

21 */
22public class FnSlice extends StandardFunc {
23 @Override
24 public Value value(final QueryContext qc) throws QueryException {
25 Value input = arg(0).value(qc);
26
27 final Slice slice = slice(input.size(), qc);
28 if(slice.length == 0) return Empty.VALUE;
29 if(slice.reverse) input = input.reverse(qc);
30 if(slice.step == 1) return input.subsequence(slice.start - 1, slice.length, qc);
31
32 final ValueBuilder vb = new ValueBuilder(qc);
33 for(long i = slice.start; i <= slice.end; i += slice.step) {
34 vb.add(input.itemAt(i - 1));
35 }
36 return vb.value();
37 }
38
39 @Override
40 protected Expr opt(final CompileContext cc) throws QueryException {

Callers

nothing calls this directly

Calls 8

sliceMethod · 0.95
reverseMethod · 0.95
subsequenceMethod · 0.95
addMethod · 0.95
itemAtMethod · 0.95
valueMethod · 0.95
sizeMethod · 0.65
argMethod · 0.45

Tested by

no test coverage detected