KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > io > AttributeNameIterator


1 package com.thoughtworks.xstream.io;
2
3 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
4
5 import java.util.Iterator JavaDoc;
6
7 /**
8  * Provide an iterator over the attribute names of the current node of a reader.
9  *
10  * @author Joe Walnes
11  */

12 public class AttributeNameIterator implements Iterator JavaDoc {
13
14     private int current;
15     private final int count;
16     private final HierarchicalStreamReader reader;
17
18     public AttributeNameIterator(HierarchicalStreamReader reader) {
19         this.reader = reader;
20         count = reader.getAttributeCount();
21     }
22
23     public boolean hasNext() {
24         return current < count;
25     }
26
27     public Object JavaDoc next() {
28         return reader.getAttributeName(current++);
29     }
30
31     public void remove() {
32         throw new UnsupportedOperationException JavaDoc();
33     }
34
35 }
36
Popular Tags