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

Method coerceTo

basex-core/src/main/java/org/basex/query/value/map/XQMap.java:332–344  ·  view source on GitHub ↗

Converts this map to the given map type. @param mt map type @param qc query context @param ii input info (can be null) @param cc compilation context (null during runtime) @return coerced map @throws QueryException query exception

(final MapType mt, final QueryContext qc, final InputInfo ii,
      final CompileContext cc)

Source from the content-addressed store, hash-verified

330 * @throws QueryException query exception
331 */
332 public final XQMap coerceTo(final MapType mt, final QueryContext qc, final InputInfo ii,
333 final CompileContext cc) throws QueryException {
334
335 final SeqType kt = mt.keyType().seqType(), vt = mt.valueType();
336 final MapBuilder mb = new MapBuilder(structSize());
337 forEach((key, value) -> {
338 qc.checkStop();
339 final Item k = (Item) kt.coerce(key, qc, ii, null, cc);
340 if(mb.contains(k)) throw typeError(this, mt, ii);
341 mb.put(k, vt.coerce(value, qc, ii, null, cc));
342 });
343 return mb.map();
344 }
345
346 /**
347 * Converts this map to the given record type.

Callers 4

optimizeMethod · 0.45
itemMethod · 0.45
coerceMethod · 0.45
castMethod · 0.45

Calls 15

forEachMethod · 0.95
coerceMethod · 0.95
containsMethod · 0.95
putMethod · 0.95
mapMethod · 0.95
getOrNullMethod · 0.95
getMethod · 0.95
seqTypeMethod · 0.95
isOptionalMethod · 0.95
emptyMethod · 0.95
keyTypeMethod · 0.80
seqTypeMethod · 0.65

Tested by

no test coverage detected