View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.ast.xpath.saxon;
5   
6   import net.sf.saxon.om.Navigator;
7   import net.sf.saxon.om.SequenceIterator;
8   import net.sourceforge.pmd.lang.ast.xpath.Attribute;
9   
10  /**
11   * This is an Attribute axis iterator.
12   */
13  public class AttributeAxisIterator extends Navigator.BaseEnumeration {
14  
15      protected final ElementNode startNodeInfo;
16      protected final net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator iterator;
17  
18      /**
19       * Create an iterator over the Attribute axis for the given ElementNode.
20       * @see net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator
21       */
22      public AttributeAxisIterator(ElementNode startNodeInfo) {
23  	this.startNodeInfo = startNodeInfo;
24  	this.iterator = new net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator(startNodeInfo.node);
25      }
26  
27      /**
28       * {@inheritDoc}
29       */
30      public SequenceIterator getAnother() {
31  	return new AttributeAxisIterator(startNodeInfo);
32      }
33  
34      /**
35       * {@inheritDoc}
36       */
37      public void advance() {
38  	if (this.iterator.hasNext()) {
39  	    Attribute attribute = this.iterator.next();
40  	    super.current = new AttributeNode(attribute, super.position());
41  	} else {
42  	    super.current = null;
43  	}
44      }
45  }