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

Method test

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

Source from the content-addressed store, hash-verified

144 }
145
146 @Override
147 public boolean test(final QueryContext qc, final InputInfo ii, final long pos)
148 throws QueryException {
149 // atomic evaluation of arguments (faster)
150 if(single) {
151 final Item item = expr.item(qc, info);
152 return item != Empty.VALUE && inRange(item);
153 }
154
155 // pre-evaluate ranges
156 if(expr instanceof Range || expr instanceof RangeSeq) {
157 final Value value = expr.value(qc);
158 final long size = value.size();
159 if(size == 0) return false;
160 if(size == 1) return inRange((Item) value);
161 final RangeSeq rs = (RangeSeq) value;
162 return rs.max() >= min && rs.min() <= max;
163 }
164
165 // iterative evaluation
166 final Iter iter = expr.atomIter(qc, info);
167 for(Item item; (item = qc.next(iter)) != null;) {
168 if(inRange(item)) return true;
169 }
170 return false;
171 }
172
173 /**
174 * 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