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

Method pos

basex-core/src/main/java/org/basex/query/expr/Range.java:154–168  ·  view source on GitHub ↗

Returns a static positional value for the specified expression. @param expr expression @return positional value or Double#NaN

(final Expr expr)

Source from the content-addressed store, hash-verified

152 * @return positional value or {@code Double#NaN}
153 */
154 private static double pos(final Expr expr) {
155 if(expr instanceof final Itr itr) return itr.itr();
156 if(Function.LAST.is(expr)) return LAST;
157 if(expr instanceof final Arith arth && Function.LAST.is(expr.arg(0))) {
158 final double l = expr.arg(1) instanceof final Itr itr ? itr.itr() : 0;
159 if(l != 0) return switch(arth.calc) {
160 case ADD -> LAST + l;
161 case SUBTRACT -> LAST - l;
162 case MULTIPLY -> LAST * l;
163 case DIVIDE -> LAST / l;
164 default -> Double.NaN;
165 };
166 }
167 return Double.NaN;
168 }
169
170 @Override
171 public boolean equals(final Object obj) {

Callers 1

optimizePosMethod · 0.95

Calls 3

isMethod · 0.65
itrMethod · 0.45
argMethod · 0.45

Tested by

no test coverage detected