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);
}
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations