src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java

Print this page




  37 import org.w3c.dom.NamedNodeMap;
  38 import org.w3c.dom.Node;
  39 
  40 /**
  41  * This is a subtype of NodeSetData that represents a dereferenced
  42  * same-document URI as the root of a subdocument. The main reason is
  43  * for efficiency and performance, as some transforms can operate
  44  * directly on the subdocument and there is no need to convert it
  45  * first to an XPath node-set.
  46  */
  47 public class DOMSubTreeData implements NodeSetData {
  48 
  49     private boolean excludeComments;
  50     private Node root;
  51 
  52     public DOMSubTreeData(Node root, boolean excludeComments) {
  53         this.root = root;
  54         this.excludeComments = excludeComments;
  55     }
  56 
  57     public Iterator iterator() {
  58         return new DelayedNodeIterator(root, excludeComments);
  59     }
  60 
  61     public Node getRoot() {
  62         return root;
  63     }
  64 
  65     public boolean excludeComments() {
  66         return excludeComments;
  67     }
  68 
  69     /**
  70      * This is an Iterator that contains a backing node-set that is
  71      * not populated until the caller first attempts to advance the iterator.
  72      */
  73     static class DelayedNodeIterator implements Iterator<Node> {
  74         private Node root;
  75         private List<Node> nodeSet;
  76         private ListIterator<Node> li;
  77         private boolean withComments;




  37 import org.w3c.dom.NamedNodeMap;
  38 import org.w3c.dom.Node;
  39 
  40 /**
  41  * This is a subtype of NodeSetData that represents a dereferenced
  42  * same-document URI as the root of a subdocument. The main reason is
  43  * for efficiency and performance, as some transforms can operate
  44  * directly on the subdocument and there is no need to convert it
  45  * first to an XPath node-set.
  46  */
  47 public class DOMSubTreeData implements NodeSetData {
  48 
  49     private boolean excludeComments;
  50     private Node root;
  51 
  52     public DOMSubTreeData(Node root, boolean excludeComments) {
  53         this.root = root;
  54         this.excludeComments = excludeComments;
  55     }
  56 
  57     public Iterator<Node> iterator() {
  58         return new DelayedNodeIterator(root, excludeComments);
  59     }
  60 
  61     public Node getRoot() {
  62         return root;
  63     }
  64 
  65     public boolean excludeComments() {
  66         return excludeComments;
  67     }
  68 
  69     /**
  70      * This is an Iterator that contains a backing node-set that is
  71      * not populated until the caller first attempts to advance the iterator.
  72      */
  73     static class DelayedNodeIterator implements Iterator<Node> {
  74         private Node root;
  75         private List<Node> nodeSet;
  76         private ListIterator<Node> li;
  77         private boolean withComments;