本文整理匯總了Java中org.w3c.dom.traversal.NodeIterator.detach方法的典型用法代碼示例。如果您正苦於以下問題:Java NodeIterator.detach方法的具體用法?Java NodeIterator.detach怎麽用?Java NodeIterator.detach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.traversal.NodeIterator
的用法示例。
在下文中一共展示了NodeIterator.detach方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: outputDebug
import org.w3c.dom.traversal.NodeIterator; //導入方法依賴的package包/類
/**
* Outputs information on the matches for debug purposes.
*
* @param matchSet The set of matching Nodes.
* @param doc The first document being differenced
*/
private static void outputDebug(final NodePairs matchSet,
final Document doc) {
if (DiffFactory.isDebug()) {
NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(
doc.getDocumentElement(), NodeFilter.SHOW_ALL, null, false);
Node n;
while ((n = ni.nextNode()) != null) {
System.err.print(DOMOps.getNodeAsString(n));
if (matchSet.isMatched(n)) {
System.err.println(" matches "
+ DOMOps.getNodeAsString(matchSet.getPartner(n)));
} else {
System.err.println(" unmatched");
}
}
ni.detach();
System.err.println();
}
}
示例2: initialiseAndOrderNodes
import org.w3c.dom.traversal.NodeIterator; //導入方法依賴的package包/類
/**
* Returns a list of Nodes sorted according to their depths.
*
* Does *NOT* include root or documentElement
*
* TreeSet is sorted in reverse order of depth according to
* NodeInfoComparator.
*
* @param doc The document to be initialised and ordered.
* @return A depth-ordered list of the nodes in the doc.
*/
private static List<NodeDepth> initialiseAndOrderNodes(
final Document doc) {
NodeIterator ni = ((DocumentTraversal) doc).createNodeIterator(
doc, NodeFilter.SHOW_ALL, null, false);
List<NodeDepth> depthSorted = new ArrayList<NodeDepth>();
Node n;
while ((n = ni.nextNode()) != null) {
if (!(NodeOps.checkIfSameNode(doc, n)
|| NodeOps.checkIfSameNode(doc.getDocumentElement(), n)
|| n.getNodeType() == Node.DOCUMENT_TYPE_NODE)) {
depthSorted.add(new NodeDepth(n));
}
}
ni.detach();
Collections.sort(depthSorted, new NodeDepthComparator());
return depthSorted;
}
示例3: getLength
import org.w3c.dom.traversal.NodeIterator; //導入方法依賴的package包/類
public int getLength()
{
int retval = 0;
NodeIterator iter = createIterator();
while (iter.nextNode() != null)
{
retval++;
}
iter.detach();
return retval;
}
示例4: getLength
import org.w3c.dom.traversal.NodeIterator; //導入方法依賴的package包/類
public int getLength()
{
int retval = 0;
NodeIterator iter = createIterator();
while (iter.nextNode() != null)
{
retval++;
}
iter.detach();
return retval;
}