KickJava   Java API By Example, From Geeks To Geeks.

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


1 package 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/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/collections/impl/ASTEnumerator.java#4 $
8  */

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