AttributeAxisIterator.java
01 package net.sourceforge.pmd.lang.ast.xpath.saxon;
02 
03 import net.sf.saxon.om.Navigator;
04 import net.sf.saxon.om.SequenceIterator;
05 import net.sourceforge.pmd.lang.ast.xpath.Attribute;
06 
07 /**
08  * This is an Attribute axis iterator.
09  */
10 public class AttributeAxisIterator extends Navigator.BaseEnumeration {
11 
12     protected final ElementNode startNodeInfo;
13     protected final net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator iterator;
14 
15     /**
16      * Create an iterator over the Attribute axis for the given ElementNode.
17      @see net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator
18      */
19     public AttributeAxisIterator(ElementNode startNodeInfo) {
20   this.startNodeInfo = startNodeInfo;
21   this.iterator = new net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator(startNodeInfo.node);
22     }
23 
24     /**
25      * {@inheritDoc}
26      */
27     public SequenceIterator getAnother() {
28   return new AttributeAxisIterator(startNodeInfo);
29     }
30 
31     /**
32      * {@inheritDoc}
33      */
34     public void advance() {
35   if (this.iterator.hasNext()) {
36       Attribute attribute = this.iterator.next();
37       super.current = new AttributeNode(attribute, super.position());
38   else {
39       super.current = null;
40   }
41     }
42 }