Search in sources :

Example 6 with PostOrderAxis

use of org.sirix.axis.PostOrderAxis in project sirix by sirixdb.

the class FMSE method getLabels.

/**
 * Creates a flat list of all nodes by doing an in-order-traversal. NOTE: Since this is not a
 * binary tree, we use post-order-traversal (wrong in paper). For each node type (element,
 * attribute, text, comment, ...) there is a separate list.
 *
 * @param rtx {@link XdmNodeReadTrx} reference
 * @param visitor {@link LabelFMSEVisitor} used to save node type/list
 */
private void getLabels(final XdmNodeReadTrx rtx, final LabelFMSEVisitor visitor) {
    assert rtx != null;
    assert visitor != null;
    final long nodeKey = rtx.getNodeKey();
    for (final AbstractAxis axis = new PostOrderAxis(rtx); axis.hasNext(); ) {
        axis.next();
        if (axis.getTrx().getNodeKey() == nodeKey) {
            break;
        }
        axis.getTrx().acceptVisitor(visitor);
    }
    rtx.acceptVisitor(visitor);
}
Also used : PostOrderAxis(org.sirix.axis.PostOrderAxis) AbstractAxis(org.sirix.axis.AbstractAxis)

Aggregations

PostOrderAxis (org.sirix.axis.PostOrderAxis)6 Axis (org.sirix.api.Axis)4 DescendantAxis (org.sirix.axis.DescendantAxis)4 AbstractAxis (org.sirix.axis.AbstractAxis)3 LevelOrderAxis (org.sirix.axis.LevelOrderAxis)3 ElementNode (org.sirix.node.ElementNode)3 ChildAxis (org.sirix.axis.ChildAxis)2 StructNode (org.sirix.node.interfaces.StructNode)2 UnorderedKeyValuePage (org.sirix.page.UnorderedKeyValuePage)2 Test (org.junit.Test)1 FilterAxis (org.sirix.axis.filter.FilterAxis)1 NameFilter (org.sirix.axis.filter.NameFilter)1 PathKindFilter (org.sirix.axis.filter.PathKindFilter)1 VisitorDescendantAxis (org.sirix.axis.visitor.VisitorDescendantAxis)1 SirixUsageException (org.sirix.exception.SirixUsageException)1 ImmutableNode (org.sirix.node.interfaces.immutable.ImmutableNode)1