package
gve.calc.formula;
import
java.util.*;
Somt elementen van een door komma's gescheiden lijst op.
public
class
CommaEnumerator
implements
Enumeration {
private
Part
nextPart;
public
CommaEnumerator
(
Part
p) { nextPart = p; }
public
boolean
hasMoreElements() {
if
(nextPart == null)
return
false;
if
((nextPart
instanceof
Identifier
) && ((
Identifier
)nextPart).isEmpty()) { nextPart = null;
return
false; }
return
true; }
public
Part
nextPart() {
if
(!hasMoreElements())
throw
new
NoSuchElementException();
if
(nextPart
instanceof
OperatorComma
) {
OperatorComma
comma = (
OperatorComma
)nextPart; nextPart = comma.right;
return
comma.left; }
Part
result = nextPart; nextPart = null;
return
result; }
public
Object nextElement() {
return
nextPart(); } }