use of org.exist.util.XMLString in project exist by eXist-db.
the class Indexer method endCDATA.
@Override
public void endCDATA() {
if (!stack.isEmpty()) {
final ElementImpl last = stack.peek();
if (charBuf != null && charBuf.length() > 0) {
final CDATASectionImpl cdata = new CDATASectionImpl(charBuf);
cdata.setOwnerDocument(document);
last.appendChildInternal(prevNode, cdata);
if (!validate) {
broker.storeNode(transaction, cdata, currentPath, indexSpec);
if (indexListener != null) {
indexListener.characters(transaction, cdata, currentPath);
}
}
setPrevious(cdata);
if (!nodeContentStack.isEmpty()) {
for (final XMLString next : nodeContentStack) {
next.append(charBuf);
}
}
charBuf.reset();
}
}
inCDATASection = false;
}
use of org.exist.util.XMLString in project exist by eXist-db.
the class Indexer method endElement.
@Override
public void endElement(final String namespace, final String name, final String qname) {
final ElementImpl last = stack.peek();
processText(last, ProcessTextParent.ELEMENT_END);
stack.pop();
XMLString elemContent = null;
try {
if (!validate && RangeIndexSpec.hasQNameOrValueIndex(last.getIndexType())) {
elemContent = nodeContentStack.pop();
}
if (validate) {
if (childCnt != null) {
setChildCount(last);
}
} else {
final String content = elemContent == null ? null : elemContent.toString();
broker.endElement(last, currentPath, content);
if (childCnt == null && last.getChildCount() > 0 || (childCnt != null && childCnt[last.getPosition()] != last.getChildCount())) {
broker.updateNode(transaction, last, false);
}
if (indexListener != null) {
indexListener.endElement(transaction, last, currentPath);
}
}
currentPath.removeLastNode();
setPrevious(last);
level--;
} finally {
if (elemContent != null) {
elemContent.reset();
}
}
}
use of org.exist.util.XMLString in project exist by eXist-db.
the class AttrImpl method deserialize.
public static StoredNode deserialize(final byte[] data, final int start, final int len, final DocumentImpl doc, final boolean pooled) {
int pos = start;
final byte idSizeType = (byte) (data[pos] & 0x3);
final boolean hasNamespace = (data[pos] & 0x10) == 0x10;
final int attrType = (data[pos] & 0x4) >> 0x2;
pos += StoredNode.LENGTH_SIGNATURE_LENGTH;
final int dlnLen = ByteConversion.byteToShort(data, pos);
pos += NodeId.LENGTH_NODE_ID_UNITS;
final NodeId dln = doc.getBrokerPool().getNodeFactory().createFromData(dlnLen, data, pos);
pos += dln.size();
final short id = (short) Signatures.read(idSizeType, data, pos);
pos += Signatures.getLength(idSizeType);
final String name = doc.getBrokerPool().getSymbols().getName(id);
if (name == null) {
throw new RuntimeException("no symbol for id " + id);
}
short nsId = 0;
String prefix = null;
if (hasNamespace) {
nsId = ByteConversion.byteToShort(data, pos);
pos += LENGTH_NS_ID;
int prefixLen = ByteConversion.byteToShort(data, pos);
pos += LENGTH_PREFIX_LENGTH;
if (prefixLen > 0) {
prefix = UTF8.decode(data, pos, prefixLen).toString();
}
pos += prefixLen;
}
final String namespace = nsId == 0 ? "" : doc.getBrokerPool().getSymbols().getNamespace(nsId);
final XMLString value = UTF8.decode(data, pos, len - (pos - start));
// OK : we have the necessary material to build the attribute
final AttrImpl attr;
if (pooled) {
attr = (AttrImpl) NodePool.getInstance().borrowNode(Node.ATTRIBUTE_NODE);
} else {
attr = new AttrImpl();
}
attr.setNodeName(doc.getBrokerPool().getSymbols().getQName(Node.ATTRIBUTE_NODE, namespace, name, prefix));
if (attr.value != null) {
attr.value.reset();
}
attr.value = value;
attr.setNodeId(dln);
attr.setType(attrType);
return attr;
}
use of org.exist.util.XMLString in project exist by eXist-db.
the class DocumentImpl method createCDATASection.
@Override
public CDATASection createCDATASection(final String data) throws DOMException {
final CDATASectionImpl cdataSection = new CDATASectionImpl(new XMLString(data.toCharArray()));
cdataSection.setOwnerDocument(this);
return cdataSection;
}
use of org.exist.util.XMLString in project exist by eXist-db.
the class AttrImpl method setValue.
@Override
public void setValue(final String value) throws DOMException {
if (this.value != null) {
this.value.reset();
this.value.append(value);
} else {
this.value = new XMLString(value.toCharArray());
}
}
Aggregations