⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nodesetdtm.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    {      m_next--;      return this.elementAt(m_next);    }    else      return DTM.NULL;  }  /**   * Detaches the iterator from the set which it iterated over, releasing   * any computational resources and placing the iterator in the INVALID   * state. After<code>detach</code> has been invoked, calls to   * <code>nextNode</code> or<code>previousNode</code> will raise the   * exception INVALID_STATE_ERR.   * <p>   * This operation is a no-op in NodeSetDTM, and will not cause    * INVALID_STATE_ERR to be raised by later operations.   * </p>   */  public void detach(){}    /**   * Specify if it's OK for detach to release the iterator for reuse.   *    * @param allowRelease true if it is OK for detach to release this iterator    * for pooling.   */  public void allowDetachToRelease(boolean allowRelease)  {    // no action for right now.  }  /**   * Tells if this NodeSetDTM is "fresh", in other words, if   * the first nextNode() that is called will return the   * first node in the set.   *   * @return true if nextNode() would return the first node in the set,   * false if it would return a later one.   */  public boolean isFresh()  {    return (m_next == 0);  }  /**   * If an index is requested, NodeSetDTM will call this method   * to run the iterator to the index.  By default this sets   * m_next to the index.  If the index argument is -1, this   * signals that the iterator should be run to the end.   *   * @param index Position to advance (or retreat) to, with   * 0 requesting the reset ("fresh") position and -1 (or indeed   * any out-of-bounds value) requesting the final position.   * @throws RuntimeException thrown if this NodeSetDTM is not   * one of the types which supports indexing/counting.   */  public void runTo(int index)  {    if (!m_cacheNodes)      throw new RuntimeException(        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_CANNOT_INDEX, null)); //"This NodeSetDTM can not do indexing or counting functions!");    if ((index >= 0) && (m_next < m_firstFree))      m_next = index;    else      m_next = m_firstFree - 1;  }  /**   * Returns the <code>index</code>th item in the collection. If   * <code>index</code> is greater than or equal to the number of nodes in   * the list, this returns <code>null</code>.   *    * TODO: What happens if index is out of range?   *    * @param index Index into the collection.   * @return The node at the <code>index</code>th position in the   *   <code>NodeList</code>, or <code>null</code> if that is not a valid   *   index.   */  public int item(int index)  {    runTo(index);    return this.elementAt(index);  }  /**   * The number of nodes in the list. The range of valid child node indices is   * 0 to <code>length-1</code> inclusive. Note that this operation requires   * finding all the matching nodes, which may defeat attempts to defer   * that work.   *   * @return integer indicating how many nodes are represented by this list.   */  public int getLength()  {    runTo(-1);    return this.size();  }  /**   * Add a node to the NodeSetDTM. Not all types of NodeSetDTMs support this   * operation   *   * @param n Node to be added   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public void addNode(int n)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    this.addElement(n);  }  /**   * Insert a node at a given position.   *   * @param n Node to be added   * @param pos Offset at which the node is to be inserted,   * with 0 being the first position.   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public void insertNode(int n, int pos)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    insertElementAt(n, pos);  }  /**   * Remove a node.   *   * @param n Node to be added   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public void removeNode(int n)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    this.removeElement(n);  }  // %TBD%//  /**//   * Copy NodeList members into this nodelist, adding in//   * document order.  If a node is null, don't add it.//   *//   * @param nodelist List of nodes which should now be referenced by//   * this NodeSetDTM.//   * @throws RuntimeException thrown if this NodeSetDTM is not of //   * a mutable type.//   *///  public void addNodes(NodeList nodelist)//  {////    if (!m_mutable)//      throw new RuntimeException("This NodeSetDTM is not mutable!");////    if (null != nodelist)  // defensive to fix a bug that Sanjiva reported.//    {//      int nChildren = nodelist.getLength();////      for (int i = 0; i < nChildren; i++)//      {//        int obj = nodelist.item(i);////        if (null != obj)//        {//          addElement(obj);//        }//      }//    }////    // checkDups();//  }  // %TBD%//  /**//   * <p>Copy NodeList members into this nodelist, adding in//   * document order.  Only genuine node references will be copied;//   * nulls appearing in the source NodeSetDTM will//   * not be added to this one. </p>//   * //   * <p> In case you're wondering why this function is needed: NodeSetDTM//   * implements both DTMIterator and NodeList. If this method isn't//   * provided, Java can't decide which of those to use when addNodes()//   * is invoked. Providing the more-explicit match avoids that//   * ambiguity.)</p>//   *//   * @param ns NodeSetDTM whose members should be merged into this NodeSetDTM.//   * @throws RuntimeException thrown if this NodeSetDTM is not of //   * a mutable type.//   *///  public void addNodes(NodeSetDTM ns)//  {////    if (!m_mutable)//      throw new RuntimeException("This NodeSetDTM is not mutable!");////    addNodes((DTMIterator) ns);//  }  /**   * Copy NodeList members into this nodelist, adding in   * document order.  Null references are not added.   *   * @param iterator DTMIterator which yields the nodes to be added.   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public void addNodes(DTMIterator iterator)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    if (null != iterator)  // defensive to fix a bug that Sanjiva reported.    {      int obj;      while (DTM.NULL != (obj = iterator.nextNode()))      {        addElement(obj);      }    }    // checkDups();  }  // %TBD%//  /**//   * Copy NodeList members into this nodelist, adding in//   * document order.  If a node is null, don't add it.//   *//   * @param nodelist List of nodes to be added//   * @param support The XPath runtime context.//   * @throws RuntimeException thrown if this NodeSetDTM is not of //   * a mutable type.//   *///  public void addNodesInDocOrder(NodeList nodelist, XPathContext support)//  {////    if (!m_mutable)//      throw new RuntimeException("This NodeSetDTM is not mutable!");////    int nChildren = nodelist.getLength();////    for (int i = 0; i < nChildren; i++)//    {//      int node = nodelist.item(i);////      if (null != node)//      {//        addNodeInDocOrder(node, support);//      }//    }//  }  /**   * Copy NodeList members into this nodelist, adding in   * document order.  If a node is null, don't add it.   *   * @param iterator DTMIterator which yields the nodes to be added.   * @param support The XPath runtime context.   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public void addNodesInDocOrder(DTMIterator iterator, XPathContext support)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    int node;    while (DTM.NULL != (node = iterator.nextNode()))    {      addNodeInDocOrder(node, support);    }  }  // %TBD%//  /**//   * Add the node list to this node set in document order.//   *//   * @param start index.//   * @param end index.//   * @param testIndex index.//   * @param nodelist The nodelist to add.//   * @param support The XPath runtime context.//   *//   * @return false always.//   * @throws RuntimeException thrown if this NodeSetDTM is not of //   * a mutable type.//   *///  private boolean addNodesInDocOrder(int start, int end, int testIndex,//                                     NodeList nodelist, XPathContext support)//  {////    if (!m_mutable)//      throw new RuntimeException("This NodeSetDTM is not mutable!");////    boolean foundit = false;//    int i;//    int node = nodelist.item(testIndex);////    for (i = end; i >= start; i--)//    {//      int child = elementAt(i);////      if (child == node)//      {//        i = -2;  // Duplicate, suppress insert////        break;//      }////      if (!support.getDOMHelper().isNodeAfter(node, child))//      {//        insertElementAt(node, i + 1);////        testIndex--;////        if (testIndex > 0)//        {//          boolean foundPrev = addNodesInDocOrder(0, i, testIndex, nodelist,//                                                 support);////          if (!foundPrev)//          {//            addNodesInDocOrder(i, size() - 1, testIndex, nodelist, support);//          }//        }////        break;//      }//    }////    if (i == -1)//    {//      insertElementAt(node, 0);//    }////    return foundit;//  }  /**   * Add the node into a vector of nodes where it should occur in   * document order.   * @param node The node to be added.   * @param test true if we should test for doc order   * @param support The XPath runtime context.   * @return insertIndex.   * @throws RuntimeException thrown if this NodeSetDTM is not of    * a mutable type.   */  public int addNodeInDocOrder(int node, boolean test, XPathContext support)  {    if (!m_mutable)      throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_NODESETDTM_NOT_MUTABLE, null)); //"This NodeSetDTM is not mutable!");    int insertIndex = -1;    if (test)    {      // This needs to do a binary search, but a binary search       // is somewhat tough because the sequence test involves       // two nodes.      int size = size(), i;      for (i = size - 1; i >= 0; i--)      {        int child = elementAt(i);        if (child == node)        {          i = -2;  // Duplicate, suppress insert          break;        }        DTM dtm = support.getDTM(node);        if (!dtm.isNodeAfter(node, child))        {          break;        }      }      if (i != -2)      {        insertIndex = i + 1;        insertElementAt(node, insertIndex);      }    }    else    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -