Search in sources :

Example 26 with StructNode

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());
}
Also used : StructNode(org.sirix.node.interfaces.StructNode)

Example 27 with StructNode

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();
}
Also used : StructNode(org.sirix.node.interfaces.StructNode)

Example 28 with StructNode

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());
}
Also used : StructNode(org.sirix.node.interfaces.StructNode)

Example 29 with StructNode

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);
    }
}
Also used : StructNode(org.sirix.node.interfaces.StructNode)

Example 30 with StructNode

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();
    }
}
Also used : PageKind(org.sirix.page.PageKind) Kind(org.sirix.node.Kind) SirixDeweyID(org.sirix.node.SirixDeweyID) ElementNode(org.sirix.node.ElementNode) SirixUsageException(org.sirix.exception.SirixUsageException) StructNode(org.sirix.node.interfaces.StructNode)

Aggregations

StructNode (org.sirix.node.interfaces.StructNode)41 SirixDeweyID (org.sirix.node.SirixDeweyID)12 SirixUsageException (org.sirix.exception.SirixUsageException)11 ElementNode (org.sirix.node.ElementNode)10 TextNode (org.sirix.node.TextNode)8 ImmutableNode (org.sirix.node.interfaces.immutable.ImmutableNode)8 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)8 CommentNode (org.sirix.node.CommentNode)6 PINode (org.sirix.node.PINode)6 AttributeNode (org.sirix.node.AttributeNode)5 Kind (org.sirix.node.Kind)5 NamespaceNode (org.sirix.node.NamespaceNode)5 NameNode (org.sirix.node.interfaces.NameNode)5 Node (org.sirix.node.interfaces.Node)5 ValueNode (org.sirix.node.interfaces.ValueNode)5 PageKind (org.sirix.page.PageKind)5 Optional (java.util.Optional)3 PostOrderAxis (org.sirix.axis.PostOrderAxis)3 Axis (org.sirix.api.Axis)2 DescendantAxis (org.sirix.axis.DescendantAxis)2