
com.ibm.commons.xml.NodeListIterator Maven / Gradle / Ivy
The newest version!
/*
* © Copyright IBM Corp. 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.ibm.commons.xml;
import java.util.Iterator;
import java.util.NoSuchElementException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* A JAVA2 collection iterator on DOM nodes.
*/
public class NodeListIterator implements Iterator {
private NodeList list;
private Filter filter;
private int length;
private int current;
public static interface Filter {
public boolean accept( Node node );
}
public static Filter ELEMENT_FILTER = new Filter() {
public boolean accept( Node node ) {
return node.getNodeType()==Node.ELEMENT_NODE;
}
};
public NodeListIterator(NodeList list, Filter filter) {
this.list = list;
this.filter = filter;
this.length = list.getLength();
if(filter!=null) {
this.current = Integer.MAX_VALUE;
for( int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy