/**
   * Create a OneStepIterator object.
   *
   * @param compiler A reference to the Compiler that contains the op map.
   * @param opPos The position within the op map, which contains the location path expression for
   *     this itterator.
   * @throws javax.xml.transform.TransformerException
   */
  OneStepIterator(Compiler compiler, int opPos, int analysis)
      throws javax.xml.transform.TransformerException {
    super(compiler, opPos, analysis);
    int firstStepPos = compiler.getFirstChildPos(opPos);

    m_axis = WalkerFactory.getAxisFromStep(compiler, firstStepPos);
  }
 /**
  * Create a new location path iterator.
  *
  * @param compiler The Compiler which is creating this expression.
  * @param opPos The position of this iterator in the
  * @return New location path iterator.
  * @throws javax.xml.transform.TransformerException
  */
 protected LocPathIterator createDTMIterator(Compiler compiler, int opPos)
     throws javax.xml.transform.TransformerException {
   LocPathIterator lpi =
       (LocPathIterator)
           WalkerFactory.newDTMIterator(compiler, opPos, (compiler.getLocationPathDepth() <= 0));
   return lpi;
 }
  /**
   * Create a WalkingIterator iterator, including creation of step walkers from the opcode list, and
   * call back into the Compiler to create predicate expressions.
   *
   * @param compiler The Compiler which is creating this expression.
   * @param opPos The position of this iterator in the opcode list from the compiler.
   * @param shouldLoadWalkers True if walkers should be loaded, or false if this is a derived
   *     iterator and it doesn't wish to load child walkers.
   * @throws javax.xml.transform.TransformerException
   */
  WalkingIterator(Compiler compiler, int opPos, int analysis, boolean shouldLoadWalkers)
      throws javax.xml.transform.TransformerException {
    super(compiler, opPos, analysis, shouldLoadWalkers);

    int firstStepPos = compiler.getFirstChildPos(opPos);

    if (shouldLoadWalkers) {
      m_firstWalker = WalkerFactory.loadWalkers(this, compiler, firstStepPos, 0);
      m_lastUsedWalker = m_firstWalker;
    }
  }
Exemple #4
0
 /**
  * Get the analysis bits for this walker, as defined in the WalkerFactory.
  *
  * @return One of WalkerFactory#BIT_DESCENDANT, etc.
  */
 public int getAnalysisBits() {
   int axis = getAxis();
   int bit = WalkerFactory.getAnalysisBitFromAxes(axis);
   return bit;
 }
  /**
   * Create a LocPathIterator object, including creation of step walkers from the opcode list, and
   * call back into the Compiler to create predicate expressions.
   *
   * @param compiler The Compiler which is creating this expression.
   * @param opPos The position of this iterator in the opcode list from the compiler.
   * @param analysis Analysis bits that give general information about the LocationPath.
   * @throws javax.xml.transform.TransformerException
   */
  MatchPatternIterator(Compiler compiler, int opPos, int analysis)
      throws javax.xml.transform.TransformerException {

    super(compiler, opPos, analysis, false);

    int firstStepPos = OpMap.getFirstChildPos(opPos);

    m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

    boolean fromRoot = false;
    boolean walkBack = false;
    boolean walkDescendants = false;
    boolean walkAttributes = false;

    if (0 != (analysis & (WalkerFactory.BIT_ROOT | WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
      fromRoot = true;

    if (0
        != (analysis
            & (WalkerFactory.BIT_ANCESTOR
                | WalkerFactory.BIT_ANCESTOR_OR_SELF
                | WalkerFactory.BIT_PRECEDING
                | WalkerFactory.BIT_PRECEDING_SIBLING
                | WalkerFactory.BIT_FOLLOWING
                | WalkerFactory.BIT_FOLLOWING_SIBLING
                | WalkerFactory.BIT_PARENT
                | WalkerFactory.BIT_FILTER))) walkBack = true;

    if (0
        != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
                | WalkerFactory.BIT_DESCENDANT
                | WalkerFactory.BIT_CHILD))) walkDescendants = true;

    if (0 != (analysis & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
      walkAttributes = true;

    if (false || DEBUG) {
      System.out.print("analysis: " + Integer.toBinaryString(analysis));
      System.out.println(", " + WalkerFactory.getAnalysisString(analysis));
    }

    if (fromRoot || walkBack) {
      if (walkAttributes) {
        m_superAxis = Axis.ALL;
      } else {
        m_superAxis = Axis.DESCENDANTSFROMROOT;
      }
    } else if (walkDescendants) {
      if (walkAttributes) {
        m_superAxis = Axis.ALLFROMNODE;
      } else {
        m_superAxis = Axis.DESCENDANTORSELF;
      }
    } else {
      m_superAxis = Axis.ALL;
    }
    if (false || DEBUG) {
      System.out.println("axis: " + Axis.getNames(m_superAxis));
    }
  }