KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > collections > impl > ASTEnumerator


1 package persistence.antlr.collections.impl;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

8
9 import persistence.antlr.collections.impl.Vector;
10 import persistence.antlr.collections.ASTEnumeration;
11 import persistence.antlr.collections.AST;
12
13 import java.util.NoSuchElementException JavaDoc;
14
15 public class ASTEnumerator implements persistence.antlr.collections.ASTEnumeration {
16     /** The list of root nodes for subtrees that match */
17     VectorEnumerator nodes;
18     int i = 0;
19
20
21     public ASTEnumerator(Vector v) {
22         nodes = new VectorEnumerator(v);
23     }
24
25     public boolean hasMoreNodes() {
26         synchronized (nodes) {
27             return i <= nodes.vector.lastElement;
28         }
29     }
30
31     public persistence.antlr.collections.AST nextNode() {
32         synchronized (nodes) {
33             if (i <= nodes.vector.lastElement) {
34                 return (AST)nodes.vector.data[i++];
35             }
36             throw new NoSuchElementException JavaDoc("ASTEnumerator");
37         }
38     }
39 }
40
Popular Tags