use of org.sirix.api.Axis in project sirix by sirixdb.
the class FMSE method firstFMESStep.
/**
* First step of the edit script algorithm. Combines the update, insert, align and move phases.
*
* @param wtx {@link XdmNodeWriteTrx} implementation reference on old revisionso
* @param pRtxn {@link XdmNodeReadTrx} implementation reference o new revision
*/
private void firstFMESStep(final XdmNodeWriteTrx wtx, final XdmNodeReadTrx rtx) {
assert wtx != null;
assert rtx != null;
wtx.moveTo(mOldStartKey);
rtx.moveTo(mNewStartKey);
// 2. Iterate over new shreddered file
for (final Axis axis = new LevelOrderAxis.Builder(rtx).includeSelf().includeNonStructuralNodes().build(); axis.hasNext(); ) {
axis.next();
final long nodeKey = axis.getTrx().getNodeKey();
doFirstFSMEStep(wtx, rtx);
axis.getTrx().moveTo(nodeKey);
}
}
use of org.sirix.api.Axis in project sirix by sirixdb.
the class DocumentWrapper method selectID.
@Override
public NodeInfo selectID(final String ID, final boolean getParent) {
try {
final NodeReadTrx rtx = mSession.beginNodeReadTrx();
final Axis axis = new DescendantAxis(rtx, IncludeSelf.YES);
while (axis.hasNext()) {
if (rtx.getKind() == Kind.ELEMENT) {
final int attCount = rtx.getAttributeCount();
if (attCount > 0) {
final long nodeKey = rtx.getNodeKey();
for (int index = 0; index < attCount; index++) {
rtx.moveToAttribute(index);
if ("xml:id".equalsIgnoreCase(rtx.getName().getLocalName()) && ID.equals(rtx.getValue())) {
if (getParent) {
rtx.moveToParent();
}
return new NodeWrapper(this, rtx.getNodeKey());
}
rtx.moveTo(nodeKey);
}
}
}
axis.next();
}
rtx.close();
} catch (final SirixException e) {
LOGWRAPPER.error(e.getMessage(), e);
}
return null;
}
use of org.sirix.api.Axis in project sirix by sirixdb.
the class DBNode method isPrecedingOf.
@Override
public boolean isPrecedingOf(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().isPrecedingOf(node.mDeweyID.get());
} else {
for (final Axis axis = new FollowingAxis(mRtx); axis.hasNext(); ) {
axis.next();
if (mRtx.getNodeKey() == node.getNodeKey()) {
return true;
}
}
}
}
}
return false;
}
use of org.sirix.api.Axis 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.api.Axis in project sirix by sirixdb.
the class DBNode method isDescendantOf.
@Override
public boolean isDescendantOf(final Node<?> other) {
moveRtx();
boolean retVal = false;
if (other instanceof DBNode) {
final DBNode node = (DBNode) other;
assert node.getNodeClassID() == this.getNodeClassID();
moveRtx();
if (mKind != org.sirix.node.Kind.ATTRIBUTE && mKind != org.sirix.node.Kind.NAMESPACE) {
if (mDeweyID.isPresent()) {
return mDeweyID.get().isDescendantOf(node.mDeweyID.get());
} else {
for (final Axis axis = new AncestorAxis(mRtx); axis.hasNext(); ) {
axis.next();
if (node.getUnderlyingNode().getNodeKey() == mRtx.getNodeKey()) {
retVal = true;
}
}
}
}
}
return retVal;
}
Aggregations