Example #1
0
  /** Reset for new run. */
  public void reset() {
    releaseDTMXRTreeFrags();
    // These couldn't be disposed of earlier (see comments in release()); zap them now.
    if (m_rtfdtm_stack != null)
      for (java.util.Enumeration e = m_rtfdtm_stack.elements(); e.hasMoreElements(); )
        m_dtmManager.release((DTM) e.nextElement(), true);

    m_rtfdtm_stack = null; // drop our references too
    m_which_rtfdtm = -1;

    if (m_global_rtfdtm != null) m_dtmManager.release(m_global_rtfdtm, true);
    m_global_rtfdtm = null;

    m_dtmManager =
        DTMManager.newInstance(org.apache.xpath.objects.XMLStringFactoryImpl.getFactory());

    m_saxLocations.removeAllElements();
    m_axesIteratorStack.removeAllElements();
    m_contextNodeLists.removeAllElements();
    m_currentExpressionNodes.removeAllElements();
    m_currentNodes.removeAllElements();
    m_iteratorRoots.RemoveAllNoClear();
    m_predicatePos.removeAllElements();
    m_predicateRoots.RemoveAllNoClear();
    m_prefixResolvers.removeAllElements();

    m_prefixResolvers.push(null);
    m_currentNodes.push(DTM.NULL);
    m_currentExpressionNodes.push(DTM.NULL);
    m_saxLocations.push(null);
  }
Example #2
0
  /**
   * Release a DTM either to a lru pool, or completely remove reference. DTMs without system IDs are
   * always hard deleted. State: experimental.
   *
   * @param dtm The DTM to be released.
   * @param shouldHardDelete True if the DTM should be removed no matter what.
   * @return true if the DTM was removed, false if it was put back in a lru pool.
   */
  public boolean release(DTM dtm, boolean shouldHardDelete) {
    // %REVIEW% If it's a DTM which may contain multiple Result Tree
    // Fragments, we can't discard it unless we know not only that it
    // is empty, but that the XPathContext itself is going away. So do
    // _not_ accept the request. (May want to do it as part of
    // reset(), though.)
    if (m_rtfdtm_stack != null && m_rtfdtm_stack.contains(dtm)) {
      return false;
    }

    return m_dtmManager.release(dtm, shouldHardDelete);
  }