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

Method toXml

basex-core/src/main/java/org/basex/core/users/User.java:130–152  ·  view source on GitHub ↗

Returns user information as XML. @param qc query context (null if element will only be created for serialization) @param ii input info (can be null) @return user element @throws QueryException query exception

(final QueryContext qc, final InputInfo ii)

Source from the content-addressed store, hash-verified

128 * @throws QueryException query exception
129 */
130 public synchronized FNode toXml(final QueryContext qc, final InputInfo ii) throws QueryException {
131 final FBuilder user = FElem.build(Q_USER).attr(Q_NAME, name).attr(Q_PERMISSION, permission);
132 passwords.forEach((key, value) -> {
133 final FBuilder pw = FElem.build(Q_PASSWORD).attr(Q_ALGORITHM, key);
134 value.forEach((k, v) -> {
135 if(!v.isEmpty()) pw.node(FElem.build(new QNm(k.toString())).text(v));
136 });
137 user.node(pw.finish());
138 });
139 patterns.forEach((key, value) -> user.node(FElem.build(Q_DATABASE).attr(Q_PATTERN, key).
140 attr(Q_PERMISSION, value).finish()));
141 if(info != null) {
142 if(qc != null) {
143 // create copy of the info node if query context is available
144 user.node(info.materialize(n -> false, ii, qc));
145 } else {
146 // otherwise, referenced original info node and invalidate parent reference
147 user.node(info);
148 info.parent(null);
149 }
150 }
151 return user.finish();
152 }
153
154 /**
155 * Sets the username.

Callers 2

valueMethod · 0.95
writeMethod · 0.45

Calls 11

buildMethod · 0.95
nodeMethod · 0.95
finishMethod · 0.95
toStringMethod · 0.65
attrMethod · 0.45
forEachMethod · 0.45
isEmptyMethod · 0.45
textMethod · 0.45
finishMethod · 0.45
materializeMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected