All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sirix.index.IndexBuilder Maven / Gradle / Ivy

package org.sirix.index;

import java.util.Set;
import org.sirix.api.json.JsonNodeReadOnlyTrx;
import org.sirix.api.visitor.JsonNodeVisitor;
import org.sirix.api.visitor.XmlNodeVisitor;
import org.sirix.api.xml.XmlNodeReadOnlyTrx;
import org.sirix.axis.DescendantAxis;
import org.sirix.axis.NonStructuralWrapperAxis;

/**
 * Build an index by traversing the current revision.
 *
 * @author Johannes Lichtenberger
 *
 */
public final class IndexBuilder {

  /**
   * Build the index.
   *
   * @param rtx the current {@link XmlNodeReadOnlyTrx}
   * @param builders the index builders
   */
  public static void build(final XmlNodeReadOnlyTrx rtx, final Set builders) {
    final long nodeKey = rtx.getNodeKey();
    rtx.moveToDocumentRoot();

    for (@SuppressWarnings("unused")
    final long key : new NonStructuralWrapperAxis(new DescendantAxis(rtx))) {
      for (final XmlNodeVisitor builder : builders) {
        rtx.acceptVisitor(builder);
      }
    }
    rtx.moveTo(nodeKey);
  }

  /**
   * Build the index.
   *
   * @param rtx the current {@link XmlNodeReadOnlyTrx}
   * @param builders the index builders
   */
  public static void build(final JsonNodeReadOnlyTrx rtx, final Set builders) {
    final long nodeKey = rtx.getNodeKey();
    rtx.moveToDocumentRoot();

    for (@SuppressWarnings("unused")
    final long key : new DescendantAxis(rtx)) {
      for (final JsonNodeVisitor builder : builders) {
        rtx.acceptVisitor(builder);
      }
    }
    rtx.moveTo(nodeKey);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy