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

Method item

basex-core/src/main/java/org/basex/query/expr/constr/CMap.java:149–178  ·  view source on GitHub ↗
(final QueryContext qc, final InputInfo ii)

Source from the content-addressed store, hash-verified

147 }
148
149 @Override
150 public XQMap item(final QueryContext qc, final InputInfo ii) throws QueryException {
151 final int el = exprs.length;
152 final MapBuilder mb = new MapBuilder(el >>> 1);
153 final QueryBiConsumer<Item, Value> add = (key, value) -> {
154 if(mb.contains(key)) throw MAPDUPLKEY_X.get(info, key);
155 mb.put(key, value);
156 };
157 for(int e = 0; e < el; e += 2) {
158 if(exprs[e + 1] != Empty.UNDEFINED) {
159 add.accept(toAtomItem(exprs[e], qc), exprs[e + 1].value(qc));
160 } else {
161 final Iter iter = exprs[e].iter(qc);
162 for(Item item; (item = qc.next(iter)) != null;) {
163 Item it;
164 if(item instanceof final JNode jnode) {
165 if(jnode.isRoot()) {
166 it = (Item) jnode.value;
167 } else {
168 it = XQMap.get(jnode.key, jnode.value);
169 }
170 } else {
171 it = item;
172 }
173 toMap(it).forEach(add);
174 }
175 }
176 }
177 return mb.map(this);
178 }
179
180 @Override
181 public long structSize() {

Callers

nothing calls this directly

Calls 13

containsMethod · 0.95
putMethod · 0.95
getMethod · 0.95
mapMethod · 0.95
toAtomItemMethod · 0.80
isRootMethod · 0.80
getMethod · 0.65
acceptMethod · 0.65
iterMethod · 0.65
nextMethod · 0.65
valueMethod · 0.45
forEachMethod · 0.45

Tested by

no test coverage detected