use of org.sirix.node.interfaces.StructNode in project sirix by sirixdb.
the class XdmNodeReadTrxImpl method moveToFirstChild.
@Override
public Move<? extends XdmNodeReadTrx> moveToFirstChild() {
assertNotClosed();
final StructNode node = getStructuralNode();
if (!node.hasFirstChild()) {
return Move.notMoved();
}
return moveTo(node.getFirstChildKey());
}
use of org.sirix.node.interfaces.StructNode in project sirix by sirixdb.
the class XdmNodeReadTrxImpl method moveToNext.
@Override
public Move<? extends XdmNodeReadTrx> moveToNext() {
assertNotClosed();
final StructNode node = getStructuralNode();
if (node.hasRightSibling()) {
// Right sibling node.
return moveTo(node.getRightSiblingKey());
}
// Next following node.
return moveToNextFollowing();
}
use of org.sirix.node.interfaces.StructNode in project sirix by sirixdb.
the class XdmNodeReadTrxImpl method moveToRightSibling.
@Override
public Move<? extends XdmNodeReadTrx> moveToRightSibling() {
assertNotClosed();
final StructNode node = getStructuralNode();
if (!node.hasRightSibling()) {
return Move.notMoved();
}
return moveTo(node.getRightSiblingKey());
}
use of org.sirix.node.interfaces.StructNode in project sirix by sirixdb.
the class XdmNodeWriterTrxImpl method setRemoveDescendants.
/**
* Set new descendant count of ancestor after a remove-operation.
*
* @param startNode the node which has been removed
*/
private void setRemoveDescendants(final ImmutableNode startNode) {
assert startNode != null;
if (startNode instanceof StructNode) {
final StructNode node = ((StructNode) getCurrentNode());
node.setDescendantCount(node.getDescendantCount() - ((StructNode) startNode).getDescendantCount() - 1);
}
}
use of org.sirix.node.interfaces.StructNode in project sirix by sirixdb.
the class XdmNodeWriterTrxImpl method insertElementAsFirstChild.
@Override
public XdmNodeWriteTrx insertElementAsFirstChild(final QNm name) throws SirixException {
if (!XMLToken.isValidQName(checkNotNull(name))) {
throw new IllegalArgumentException("The QName is not valid!");
}
acquireLock();
try {
final Kind kind = mNodeReader.getCurrentNode().getKind();
if (kind == Kind.ELEMENT || kind == Kind.DOCUMENT) {
checkAccessAndCommit();
final long parentKey = mNodeReader.getCurrentNode().getNodeKey();
final long leftSibKey = Fixed.NULL_NODE_KEY.getStandardProperty();
final long rightSibKey = ((StructNode) mNodeReader.getCurrentNode()).getFirstChildKey();
final long pathNodeKey = mBuildPathSummary ? mPathSummaryWriter.getPathNodeKey(name, Kind.ELEMENT) : 0;
final Optional<SirixDeweyID> id = newFirstChildID();
final ElementNode node = mNodeFactory.createElementNode(parentKey, leftSibKey, rightSibKey, 0, name, pathNodeKey, id);
mNodeReader.setCurrentNode(node);
adaptForInsert(node, InsertPos.ASFIRSTCHILD, PageKind.RECORDPAGE);
mNodeReader.setCurrentNode(node);
adaptHashesWithAdd();
return this;
} else {
throw new SirixUsageException("Insert is not allowed if current node is not an ElementNode!");
}
} finally {
unLock();
}
}
Aggregations