Search in sources :

Example 1 with ImmutableAttribute

use of org.sirix.node.immutable.ImmutableAttribute in project sirix by sirixdb.

the class XdmNodeWriterTrxImpl method adaptSubtreeForMove.

/**
 * Adapt subtree regarding the index-structures.
 *
 * @param toMove node which is moved (either before the move, or after the move)
 * @param type the type of change (either deleted from the old position or inserted into the new
 *        position)
 * @throws SirixIOException if an I/O exception occurs
 */
private void adaptSubtreeForMove(final Node node, final ChangeType type) throws SirixIOException {
    assert type != null;
    final long beforeNodeKey = getNode().getNodeKey();
    moveTo(node.getNodeKey());
    final Axis axis = new DescendantAxis(this, IncludeSelf.YES);
    while (axis.hasNext()) {
        axis.next();
        for (int i = 0, attCount = getAttributeCount(); i < attCount; i++) {
            moveToAttribute(i);
            final ImmutableAttribute att = (ImmutableAttribute) getNode();
            mIndexController.notifyChange(type, att, att.getPathNodeKey());
            moveToParent();
        }
        for (int i = 0, nspCount = getNamespaceCount(); i < nspCount; i++) {
            moveToAttribute(i);
            final ImmutableNamespace nsp = (ImmutableNamespace) getNode();
            mIndexController.notifyChange(type, nsp, nsp.getPathNodeKey());
            moveToParent();
        }
        long pathNodeKey = -1;
        if (getNode() instanceof ValueNode && getNode().getParentKey() != Fixed.DOCUMENT_NODE_KEY.getStandardProperty()) {
            final long nodeKey = getNode().getNodeKey();
            pathNodeKey = moveToParent().get().getNameNode().getPathNodeKey();
            moveTo(nodeKey);
        } else if (getNode() instanceof NameNode) {
            pathNodeKey = getNameNode().getPathNodeKey();
        }
        mIndexController.notifyChange(type, getNode(), pathNodeKey);
    }
    moveTo(beforeNodeKey);
}
Also used : NameNode(org.sirix.node.interfaces.NameNode) ValueNode(org.sirix.node.interfaces.ValueNode) ImmutableNamespace(org.sirix.node.immutable.ImmutableNamespace) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) LevelOrderAxis(org.sirix.axis.LevelOrderAxis) PostOrderAxis(org.sirix.axis.PostOrderAxis) DescendantAxis(org.sirix.axis.DescendantAxis) ImmutableAttribute(org.sirix.node.immutable.ImmutableAttribute)

Aggregations

Axis (org.sirix.api.Axis)1 DescendantAxis (org.sirix.axis.DescendantAxis)1 LevelOrderAxis (org.sirix.axis.LevelOrderAxis)1 PostOrderAxis (org.sirix.axis.PostOrderAxis)1 ImmutableAttribute (org.sirix.node.immutable.ImmutableAttribute)1 ImmutableNamespace (org.sirix.node.immutable.ImmutableNamespace)1 NameNode (org.sirix.node.interfaces.NameNode)1 ValueNode (org.sirix.node.interfaces.ValueNode)1