Search in sources :

Example 1 with AbstractAxis

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

the class FMSE method markOutOfOrder.

/**
 * Mark children out of order.
 *
 * @param rtx {@link XdmNodeReadTrx} reference
 * @param inOrder {@link Map} to put all children out of order
 */
private void markOutOfOrder(final XdmNodeReadTrx rtx, final Map<Long, Boolean> inOrder) {
    for (final AbstractAxis axis = new ChildAxis(rtx); axis.hasNext(); ) {
        axis.next();
        inOrder.put(axis.getTrx().getNodeKey(), false);
    }
}
Also used : ChildAxis(org.sirix.axis.ChildAxis) AbstractAxis(org.sirix.axis.AbstractAxis)

Example 2 with AbstractAxis

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

the class XPathParser method parseReverceAxis.

/**
 * Parses the the rule ReverceAxis according to the following production rule: [33] ReverseAxis
 * ::= <"parent" "::"> | <"ancestor" "::"> | <"preceding-sibling" "::">|<"preceding"
 * "::">|<"ancestor-or-self" "::"> .
 *
 * @return axis
 */
private AbstractAxis parseReverceAxis() {
    AbstractAxis axis;
    if (is("parent", true)) {
        axis = new ParentAxis(getTransaction());
    } else if (is("ancestor", true)) {
        axis = new AncestorAxis(getTransaction());
    } else if (is("ancestor-or-self", true)) {
        axis = new AncestorAxis(getTransaction(), IncludeSelf.YES);
    } else if (is("preceding", true)) {
        axis = new PrecedingAxis(getTransaction());
    } else {
        consume("preceding-sibling", true);
        axis = new PrecedingSiblingAxis(getTransaction());
    }
    consume(TokenType.COLON, true);
    consume(TokenType.COLON, true);
    return axis;
}
Also used : AncestorAxis(org.sirix.axis.AncestorAxis) PrecedingAxis(org.sirix.axis.PrecedingAxis) PrecedingSiblingAxis(org.sirix.axis.PrecedingSiblingAxis) AbstractAxis(org.sirix.axis.AbstractAxis) ParentAxis(org.sirix.axis.ParentAxis)

Example 3 with AbstractAxis

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

the class XPathParser method parseReverceStep.

/**
 * Parses the the rule ReverceStep according to the following production rule:
 * <p>
 * [32] ReverseStep ::= (ReverseAxis NodeTest) | AbbrevReverseStep .
 * </p>
 */
private void parseReverceStep() {
    AbstractAxis axis;
    if (mToken.getType() == TokenType.PARENT) {
        axis = parseAbbrevReverseStep();
        mPipeBuilder.addStep(axis);
    } else {
        axis = parseReverceAxis();
        final Filter filter = parseNodeTest(axis.getClass() == AttributeAxis.class);
        mPipeBuilder.addStep(axis, filter);
    }
}
Also used : ItemFilter(org.sirix.axis.filter.ItemFilter) AttributeFilter(org.sirix.axis.filter.AttributeFilter) NameFilter(org.sirix.axis.filter.NameFilter) TypeFilter(org.sirix.axis.filter.TypeFilter) NestedFilter(org.sirix.axis.filter.NestedFilter) DocumentRootNodeFilter(org.sirix.axis.filter.DocumentRootNodeFilter) CommentFilter(org.sirix.axis.filter.CommentFilter) WildcardFilter(org.sirix.axis.filter.WildcardFilter) PIFilter(org.sirix.axis.filter.PIFilter) SchemaElementFilter(org.sirix.service.xml.xpath.filter.SchemaElementFilter) Filter(org.sirix.api.Filter) SchemaAttributeFilter(org.sirix.service.xml.xpath.filter.SchemaAttributeFilter) TextFilter(org.sirix.axis.filter.TextFilter) ElementFilter(org.sirix.axis.filter.ElementFilter) NodeFilter(org.sirix.axis.filter.NodeFilter) AbstractAxis(org.sirix.axis.AbstractAxis) AttributeAxis(org.sirix.axis.AttributeAxis)

Example 4 with AbstractAxis

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

the class MultipleCommitTest method testAttributeRemove.

@Test
public void testAttributeRemove() throws SirixException {
    DocumentCreater.create(holder.getWriter());
    holder.getWriter().commit();
    holder.getWriter().moveToDocumentRoot();
    final AbstractAxis postorderAxis = new PostOrderAxis(holder.getWriter());
    while (postorderAxis.hasNext()) {
        postorderAxis.next();
        if (holder.getWriter().getKind() == Kind.ELEMENT && holder.getWriter().getAttributeCount() > 0) {
            for (int i = 0, attrCount = holder.getWriter().getAttributeCount(); i < attrCount; i++) {
                holder.getWriter().moveToAttribute(i);
                holder.getWriter().remove();
            }
        }
    }
    holder.getWriter().commit();
    holder.getWriter().moveToDocumentRoot();
    int attrTouch = 0;
    final Axis descAxis = new DescendantAxis(holder.getWriter());
    while (descAxis.hasNext()) {
        descAxis.next();
        if (holder.getWriter().getKind() == Kind.ELEMENT) {
            for (int i = 0, attrCount = holder.getWriter().getAttributeCount(); i < attrCount; i++) {
                if (holder.getWriter().moveToAttribute(i).hasMoved()) {
                    attrTouch++;
                } else {
                    throw new IllegalStateException("Should never occur!");
                }
            }
        }
    }
    assertEquals(0, attrTouch);
}
Also used : PostOrderAxis(org.sirix.axis.PostOrderAxis) AbstractAxis(org.sirix.axis.AbstractAxis) DescendantAxis(org.sirix.axis.DescendantAxis) Axis(org.sirix.api.Axis) PostOrderAxis(org.sirix.axis.PostOrderAxis) DescendantAxis(org.sirix.axis.DescendantAxis) AbstractAxis(org.sirix.axis.AbstractAxis) Test(org.junit.Test)

Example 5 with AbstractAxis

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

the class ExpressionSingleTest method testAdd.

@Test
public void testAdd() throws SirixException {
    // Verify.
    final ExpressionSingle builder = new ExpressionSingle();
    // test one axis
    AbstractAxis self = new SelfAxis(holder.getReader());
    builder.add(self);
    assertEquals(builder.getExpr(), self);
    // test 2 axis
    AbstractAxis axis1 = new SelfAxis(holder.getReader());
    AbstractAxis axis2 = new SelfAxis(holder.getReader());
    builder.add(axis1);
    builder.add(axis2);
    assertTrue(builder.getExpr() instanceof NestedAxis);
}
Also used : SelfAxis(org.sirix.axis.SelfAxis) AbstractAxis(org.sirix.axis.AbstractAxis) NestedAxis(org.sirix.axis.NestedAxis) Test(org.junit.Test)

Aggregations

AbstractAxis (org.sirix.axis.AbstractAxis)7 Test (org.junit.Test)2 Filter (org.sirix.api.Filter)2 AttributeAxis (org.sirix.axis.AttributeAxis)2 ChildAxis (org.sirix.axis.ChildAxis)2 PostOrderAxis (org.sirix.axis.PostOrderAxis)2 AttributeFilter (org.sirix.axis.filter.AttributeFilter)2 CommentFilter (org.sirix.axis.filter.CommentFilter)2 DocumentRootNodeFilter (org.sirix.axis.filter.DocumentRootNodeFilter)2 ElementFilter (org.sirix.axis.filter.ElementFilter)2 ItemFilter (org.sirix.axis.filter.ItemFilter)2 NameFilter (org.sirix.axis.filter.NameFilter)2 NestedFilter (org.sirix.axis.filter.NestedFilter)2 NodeFilter (org.sirix.axis.filter.NodeFilter)2 PIFilter (org.sirix.axis.filter.PIFilter)2 TextFilter (org.sirix.axis.filter.TextFilter)2 TypeFilter (org.sirix.axis.filter.TypeFilter)2 WildcardFilter (org.sirix.axis.filter.WildcardFilter)2 SchemaAttributeFilter (org.sirix.service.xml.xpath.filter.SchemaAttributeFilter)2 SchemaElementFilter (org.sirix.service.xml.xpath.filter.SchemaElementFilter)2