use of org.sirix.axis.PrecedingAxis in project sirix by sirixdb.
the class ExpressionSingle method isDupOrd.
/**
* Determines for a given string representation of an axis, whether this axis leads to duplicates
* in the result sequence or not. Furthermore it determines the new state for the order state that
* specifies, if the result sequence is in document order. This method is implemented according to
* the automata in [Hidders, J., Michiels, P., "Avoiding Unnecessary Ordering Operations in
* XPath", 2003]
*
* @param ax name of the current axis
* @return true, if expression is still duplicate free
*/
public boolean isDupOrd(final Axis ax) {
Axis axis = ax;
while (axis instanceof FilterAxis) {
axis = ((FilterAxis) axis).getAxis();
}
if (axis instanceof UnionAxis) {
mOrd = mOrd.updateOrdUnion();
mDup = mDup.updateUnion();
} else if (axis instanceof ChildAxis) {
mOrd = mOrd.updateOrdChild();
mDup = mDup.updateDupChild();
} else if (axis instanceof ParentAxis) {
mOrd = mOrd.updateOrdParent();
mDup = mDup.updateDupParent();
} else if (axis instanceof DescendantAxis) {
mOrd = mOrd.updateOrdDesc();
mDup = mDup.updateDupDesc();
} else if (axis instanceof AncestorAxis) {
mOrd = mOrd.updateOrdAncestor();
mDup = mDup.updateDupAncestor();
} else if (axis instanceof FollowingAxis || axis instanceof PrecedingAxis) {
mOrd = mOrd.updateOrdFollPre();
mDup = mDup.updateDupFollPre();
} else if (axis instanceof FollowingSiblingAxis || axis instanceof PrecedingSiblingAxis) {
mOrd = mOrd.updateOrdFollPreSib();
mDup = mDup.updateDupFollPreSib();
}
return !DupState.nodup;
}
use of org.sirix.axis.PrecedingAxis in project sirix by sirixdb.
the class DBNode method isFollowingOf.
@Override
public boolean isFollowingOf(final Node<?> other) {
if (other instanceof DBNode) {
final DBNode node = (DBNode) other;
moveRtx();
if (mKind != org.sirix.node.Kind.ATTRIBUTE && mKind != org.sirix.node.Kind.NAMESPACE) {
if (mDeweyID.isPresent()) {
return mDeweyID.get().isFollowingOf(node.mDeweyID.get());
} else {
for (final Axis axis = new PrecedingAxis(mRtx); axis.hasNext(); ) {
axis.next();
if (mRtx.getNodeKey() == node.getNodeKey()) {
return true;
}
}
}
}
}
return false;
}
use of org.sirix.axis.PrecedingAxis 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;
}
Aggregations