|
ESC/Java2 © 2003,2004,2005,2006 David Cok and Joseph Kiniry © 2005,2006 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjavafe.filespace.LookAheadEnum
This layer describes how to implement an Enumeration in
terms of a single function that returns the next element in a
series, or null if the series is exhausted.
Using one function instead of the two used by Enumeration
has the advantage of avoiding possible duplication of code to
determine whether or not any elements remain in the series.
Limitation: null cannot belong to the resulting
Enumerations.
| Field Summary | |
private java.lang.Object |
lookAhead
|
private boolean |
lookAheadValid
|
| Constructor Summary | |
LookAheadEnum()
Create an look-ahead enumerator that will return the non-null results of calcNextElement(). |
|
LookAheadEnum(java.lang.Object first)
Create a look-ahead enumerator that will return first followed by the non-null results of calcNextElement(). |
|
| Method Summary | |
protected abstract java.lang.Object |
calcNextElement()
Compute the next element in the series, or return null if the series is exhausted. |
private void |
ensureLookedAhead()
Ensure that lookAheadValid is set, calling calcNextElement if needed. |
boolean |
hasMoreElements()
|
java.lang.Object |
nextElement()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private boolean lookAheadValid
private java.lang.Object lookAhead
| Constructor Detail |
public LookAheadEnum()
public LookAheadEnum(java.lang.Object first)
| Method Detail |
private void ensureLookedAhead()
public final boolean hasMoreElements()
hasMoreElements in interface java.util.Enumerationpublic final java.lang.Object nextElement()
nextElement in interface java.util.Enumerationprotected abstract java.lang.Object calcNextElement()
|
ESC/Java2 © 2003,2004,2005,2006 David Cok and Joseph Kiniry © 2005,2006 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||