예제 #1
0
 public DTMAxisIterator getChildren(final int node) {
   if (_enhancedDOM != null) {
     return _enhancedDOM.getChildren(node);
   } else {
     DTMAxisIterator iterator = _dom.getChildren(node);
     return iterator.setStartNode(node);
   }
 }
예제 #2
0
  public String getCounter() {
    int result;
    if (_value != Integer.MIN_VALUE) {
      // See Errata E24
      if (_value == 0) return "0";
      else if (Double.isNaN(_value)) return "NaN";
      else if (_value < 0 && Double.isInfinite(_value)) return "-Infinity";
      else if (Double.isInfinite(_value)) return "Infinity";
      else result = (int) _value;
    } else {
      int next = _node;
      result = 0;
      boolean matchesCount = matchesCount(next);

      if (!matchesCount) {
        while ((next = _document.getParent(next)) > END) {
          if (matchesCount(next)) {
            break; // found target
          }
          if (matchesFrom(next)) {
            next = END;
            break; // no target found
          }
        }
      }

      if (next != END) {
        int from = next;

        if (!matchesCount && _hasFrom) {
          // Target found, but need to check if ancestor matches from
          while ((from = _document.getParent(from)) > END) {
            if (matchesFrom(from)) {
              break; // found from
            }
          }
        }

        // Have we found ancestor matching from?
        if (from != END) {
          _countSiblings.setStartNode(next);
          do {
            if (matchesCount(next)) result++;
          } while ((next = _countSiblings.next()) != END);

          return formatNumbers(result);
        }
      }

      // If no target found then pass the empty list
      return formatNumbers(EmptyArray);
    }
    return formatNumbers(result);
  }
예제 #3
0
  /**
   * Get a cloned iterator.
   *
   * @return A new iterator that can be used without mutating this one.
   * @throws CloneNotSupportedException
   */
  public Object clone() throws CloneNotSupportedException {
    // Do not access the location path itterator during this operation!

    OneStepIterator clone = (OneStepIterator) super.clone();

    if (m_iterator != null) {
      clone.m_iterator = m_iterator.cloneIterator();
    }
    return clone;
  }
예제 #4
0
 public DTMAxisIterator cloneIterator() {
   try {
     final DupFilterIterator clone = (DupFilterIterator) super.clone();
     clone._nodes = (IntegerArray) _nodes.clone();
     clone._source = _source.cloneIterator();
     clone._isRestartable = false;
     return clone.reset();
   } catch (CloneNotSupportedException e) {
     BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR, e.toString());
     return null;
   }
 }
예제 #5
0
  /**
   * Set the start node for this iterator
   *
   * @param node The start node
   * @return A reference to this node iterator
   */
  public DTMAxisIterator setStartNode(int node) {
    if (_isRestartable) {
      // KeyIndex iterators are always relative to the root node, so there
      // is never any point in re-reading the iterator (and we SHOULD NOT).
      if (_source instanceof KeyIndex && _startNode == DTMDefaultBase.ROOTNODE) {
        return this;
      }

      if (node != _startNode) {
        _source.setStartNode(_startNode = node);

        _nodes.clear();
        while ((node = _source.next()) != END) {
          _nodes.add(node);
        }
        _nodes.sort();
        _nodesSize = _nodes.cardinality();
        _current = 0;
        _lastNext = END;
        resetPosition();
      }
    }
    return this;
  }
예제 #6
0
 /**
  * Initialize the context values for this expression after it is cloned.
  *
  * @param context The XPath runtime context for this transformation.
  */
 public void setRoot(int context, Object environment) {
   super.setRoot(context, environment);
   if (m_axis > -1) m_iterator = m_cdtm.getAxisIterator(m_axis);
   m_iterator.setStartNode(m_context);
 }
예제 #7
0
  /** Reset the iterator. */
  public void reset() {

    super.reset();
    if (null != m_iterator) m_iterator.reset();
  }
예제 #8
0
 /**
  * Tells if this is a reverse axes. Overrides AxesWalker#isReverseAxes.
  *
  * @return true for this class.
  */
 public boolean isReverseAxes() {
   return m_iterator.isReverse();
 }
예제 #9
0
 /** Get the next node via getFirstAttribute && getNextAttribute. */
 protected int getNextNode() {
   return m_lastFetched = m_iterator.next();
 }
예제 #10
0
 public void setRestartable(boolean isRestartable) {
   _isRestartable = isRestartable;
   _source.setRestartable(isRestartable);
 }