use of org.sirix.exception.SirixException in project sirix by sirixdb.
the class DBNode method setName.
@Override
public void setName(final QNm name) throws OperationNotSupportedException, DocumentException {
if (mIsWtx) {
moveRtx();
final XdmNodeWriteTrx wtx = (XdmNodeWriteTrx) mRtx;
if (wtx.isNameNode()) {
try {
wtx.setName(name);
} catch (final SirixException e) {
throw new DocumentException(e);
}
} else {
throw new DocumentException("Node has no name!");
}
} else {
final XdmNodeWriteTrx wtx = getWtx();
try {
wtx.setName(name);
} catch (final SirixException e) {
wtx.rollback();
wtx.close();
throw new DocumentException(e);
}
}
}
use of org.sirix.exception.SirixException in project sirix by sirixdb.
the class SubtreeBuilder method text.
@Override
public void text(final Atomic content) throws DocumentException {
try {
processText(content.stringValue());
mSubtreeProcessor.notifyText(new DBNode(mWtx, mCollection));
} catch (final SirixException e) {
throw new DocumentException(e.getCause());
}
}
use of org.sirix.exception.SirixException in project sirix by sirixdb.
the class NodeWrapper method expandString.
/**
* Filter text nodes.
*
* @return concatenated String of text node values
*/
private String expandString() {
final FastStringBuffer fsb = new FastStringBuffer(FastStringBuffer.SMALL);
try {
final NodeReadTrx rtx = createRtxAndMove();
final FilterAxis axis = new FilterAxis(new DescendantAxis(rtx), new TextFilter(rtx));
while (axis.hasNext()) {
axis.next();
fsb.append(rtx.getValue());
}
rtx.close();
} catch (final SirixException exc) {
LOGGER.error(exc.toString());
}
return fsb.condense().toString();
}
use of org.sirix.exception.SirixException in project sirix by sirixdb.
the class NodeWrapper method getDeclaredNamespaces.
@Override
public int[] getDeclaredNamespaces(final int[] buffer) {
int[] retVal = null;
if (mNodeKind == Kind.ELEMENT) {
try {
final NodeReadTrx rtx = createRtxAndMove();
final int count = rtx.getNamespaceCount();
if (count == 0) {
retVal = EMPTY_NAMESPACE_LIST;
} else {
retVal = (buffer == null || count > buffer.length ? new int[count] : buffer);
final NamePool pool = getNamePool();
int n = 0;
try {
for (int i = 0; i < count; i++) {
rtx.moveTo(i);
final String prefix = getPrefix();
final String uri = getURI();
rtx.moveTo(mKey);
retVal[n++] = pool.allocateNamespaceCode(prefix, uri);
}
rtx.close();
} catch (final SirixException exc) {
LOGGER.error(exc.toString());
}
/*
* If the supplied array is larger than required, then the first
* unused entry will be set to -1.
*/
if (count < retVal.length) {
retVal[count] = -1;
}
}
} catch (final SirixException e) {
throw new IllegalStateException(e.getCause());
}
}
return retVal;
}
use of org.sirix.exception.SirixException in project sirix by sirixdb.
the class NodeWrapper method hasChildNodes.
@Override
public boolean hasChildNodes() {
boolean hasChildNodes = false;
try {
final NodeReadTrx rtx = createRtxAndMove();
if (rtx.getChildCount() > 0) {
hasChildNodes = true;
}
rtx.close();
} catch (final SirixException exc) {
LOGGER.error(exc.toString());
}
return hasChildNodes;
}
Aggregations