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

Method atom

basex-core/src/main/java/org/basex/data/Data.java:230–263  ·  view source on GitHub ↗

Returns an atomized content for any node kind. The atomized value can be an attribute value or XML content. @param pre PRE value @return atomized value

(final int pre)

Source from the content-addressed store, hash-verified

228 * @return atomized value
229 */
230 public final byte[] atom(final int pre) {
231 return switch(kind(pre)) {
232 case TEXT, COMM ->
233 text(pre, true);
234 case ATTR ->
235 text(pre, false);
236 case PI -> {
237 final byte[] txt = text(pre, true);
238 final int i = indexOf(txt, ' ');
239 yield i == -1 ? EMPTY : substring(txt, i + 1);
240 }
241 default -> {
242 // create atomized text node
243 TokenBuilder tb = null;
244 byte[] t = EMPTY;
245 int p = pre;
246 final int s = p + size(p, kind(p));
247 while(p < s) {
248 final int k = kind(p);
249 if(k == TEXT) {
250 final byte[] txt = text(p, true);
251 if(t == EMPTY) {
252 t = txt;
253 } else {
254 if(tb == null) tb = new TokenBuilder().add(t);
255 tb.add(txt);
256 }
257 }
258 p += attSize(p, k);
259 }
260 yield tb == null ? t : tb.finish();
261 }
262 };
263 }
264
265 /**
266 * Returns the common default namespace of all documents of the database.

Callers 11

insertTextAsOnly1Method · 0.95
insertTextAsOnly2Method · 0.95
insertTextAsOnly3Method · 0.95
updateMethod · 0.95
nodeMethod · 0.95
getValueMethod · 0.95
sortMethod · 0.95
DialogEditMethod · 0.95

Calls 9

kindMethod · 0.95
textMethod · 0.95
sizeMethod · 0.95
addMethod · 0.95
attSizeMethod · 0.95
finishMethod · 0.95
addMethod · 0.65
indexOfMethod · 0.45
substringMethod · 0.45

Tested by 6

insertTextAsOnly1Method · 0.76
insertTextAsOnly2Method · 0.76
insertTextAsOnly3Method · 0.76