01: package persistence.antlr.collections.impl;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.jGuru.com
05: * Software rights: http://www.antlr.org/license.html
06: *
07: */
08:
09: import persistence.antlr.collections.impl.Vector;
10: import persistence.antlr.collections.ASTEnumeration;
11: import persistence.antlr.collections.AST;
12:
13: import java.util.NoSuchElementException;
14:
15: public class ASTEnumerator implements
16: persistence.antlr.collections.ASTEnumeration {
17: /** The list of root nodes for subtrees that match */
18: VectorEnumerator nodes;
19: int i = 0;
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("ASTEnumerator");
37: }
38: }
39: }
|