/** * Returns a readable representation of this node. * * @param data data reference * @return completions */ public byte[] token(final Data data) { switch (kind) { case Data.ELEM: return data.elemNames.key(name); case Data.ATTR: return Token.concat(ATT, data.attrNames.key(name)); case Data.TEXT: return TEXT; case Data.COMM: return COMMENT; case Data.PI: return PI; default: return Token.EMPTY; } }
/** * Returns atomic text node merging operations if necessary for the given node PRE and its right * neighbor PRE+1. * * @param a node PRE value * @param d target data reference * @return list of text merging operations */ private AtomicUpdateList necessaryMerges(final int a, final Data d) { final AtomicUpdateList mergeTwoNodes = new AtomicUpdateList(d); final int s = d.meta.size; final int b = a + 1; // don't leave table if (a >= s || b >= s || a < 0 || b < 0) return mergeTwoNodes; // only merge texts if (d.kind(a) != Data.TEXT || d.kind(b) != Data.TEXT) return mergeTwoNodes; // only merge neighboring texts if (d.parent(a, Data.TEXT) != d.parent(b, Data.TEXT)) return mergeTwoNodes; mergeTwoNodes.addDelete(b); mergeTwoNodes.addUpdateValue(a, Data.TEXT, Token.concat(d.text(a, true), d.text(b, true))); return mergeTwoNodes; }