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

Method test

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

Source from the content-addressed store, hash-verified

124 }
125
126 @Override
127 public boolean test(final QueryContext qc, final InputInfo ii, final long pos)
128 throws QueryException {
129 // atomic evaluation of arguments (faster)
130 if(single) {
131 final Item item = expr.item(qc, info);
132 return item != Empty.VALUE && inRange(item);
133 }
134
135 // pre-evaluate ranges
136 if(expr instanceof Range || expr instanceof RangeSeq) {
137 final Value value = expr.value(qc);
138 final long size = value.size();
139 if(size == 0) return false;
140 if(size == 1) return inRange((Item) value);
141 final RangeSeq rs = (RangeSeq) value;
142 return rs.max() >= min && rs.min() <= max;
143 }
144
145 // iterative evaluation
146 final Iter iter = expr.atomIter(qc, info);
147 for(Item item; (item = qc.next(iter)) != null;) {
148 if(inRange(item)) return true;
149 }
150 return false;
151 }
152
153 /**
154 * Checks if the specified value is within the allowed range.

Callers 1

itemMethod · 0.95

Calls 8

inRangeMethod · 0.95
maxMethod · 0.95
minMethod · 0.95
sizeMethod · 0.65
nextMethod · 0.65
itemMethod · 0.45
valueMethod · 0.45
atomIterMethod · 0.45

Tested by

no test coverage detected