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

Method test

basex-core/src/main/java/org/basex/query/expr/ParseExpr.java:109–131  ·  view source on GitHub ↗
(final QueryContext qc, final InputInfo ii, final long pos)

Source from the content-addressed store, hash-verified

107 }
108
109 @Override
110 public boolean test(final QueryContext qc, final InputInfo ii, final long pos)
111 throws QueryException {
112 // single item
113 if(seqType().zeroOrOne()) return item(qc, info).test(qc, info, pos);
114 // empty sequence?
115 final Iter iter = iter(qc);
116 final Item item1 = iter.next();
117 if(item1 == null) return false;
118 // sequence starting with node?
119 if(item1 instanceof GNode) return true;
120 // single item?
121 Item item2 = iter.next();
122 if(item2 == null) return item1.test(qc, info, pos);
123 // positional sequence?
124 if(pos == 0 || !(item1 instanceof ANum)) throw testError(item1.append(item2, qc), false, info);
125 if(item1.test(qc, info, pos)) return true;
126 do {
127 if(!(item2 instanceof ANum)) throw testError(item1.append(item2, qc), true, info);
128 if(item2.test(qc, info, pos)) return true;
129 } while((item2 = iter.next()) != null);
130 return false;
131 }
132
133 @Override
134 public final SeqType seqType() {

Callers

nothing calls this directly

Calls 9

seqTypeMethod · 0.95
itemMethod · 0.95
iterMethod · 0.95
nextMethod · 0.95
testMethod · 0.95
zeroOrOneMethod · 0.80
testErrorMethod · 0.80
testMethod · 0.65
appendMethod · 0.65

Tested by

no test coverage detected