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

Method item

basex-core/src/main/java/org/basex/query/expr/Unary.java:57–77  ·  view source on GitHub ↗
(final QueryContext qc, final InputInfo ii)

Source from the content-addressed store, hash-verified

55 }
56
57 @Override
58 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
59 final Item item = expr.atomItem(qc, info);
60 if(item == Empty.VALUE) return Empty.VALUE;
61
62 final Type type = item.type;
63 if(type.isUntyped()) {
64 final double d = item.dbl(info);
65 return Dbl.get(minus ? -d : d);
66 }
67 if(!type.isNumber()) throw numberError(this, item);
68
69 if(!minus) return item;
70 if(type == BasicType.DOUBLE) return Dbl.get(-item.dbl(info));
71 if(type == BasicType.FLOAT) return Flt.get(-item.flt(info));
72 if(type == BasicType.DECIMAL) return Dec.get(item.dec(info).negate());
73 // default: integer
74 final long l = item.itr(info);
75 if(l == Long.MIN_VALUE) throw RANGE_X.get(info, item);
76 return Itr.get(-l);
77 }
78
79 @Override
80 public Expr copy(final CompileContext cc, final IntObjectMap<Var> vm) {

Callers

nothing calls this directly

Calls 13

isUntypedMethod · 0.95
dblMethod · 0.95
getMethod · 0.95
isNumberMethod · 0.95
getMethod · 0.95
fltMethod · 0.95
getMethod · 0.95
decMethod · 0.95
itrMethod · 0.95
getMethod · 0.95
numberErrorMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected