java.util
Class Hashtable.Enumerator

java.lang.Object
  extended byjava.util.Hashtable.Enumerator
All Implemented Interfaces:
Enumeration, Iterator
Enclosing class:
Hashtable

private class Hashtable.Enumerator
extends Object
implements Enumeration, Iterator

A hashtable enumerator class. This class implements both the Enumeration and Iterator interfaces, but individual instances can be created with the Iterator methods disabled. This is necessary to avoid unintentionally increasing the capabilities granted a user by passing an Enumeration.


Field Summary
(package private)  Hashtable.Entry entry
           
protected  int expectedModCount
          The modCount value that the iterator believes that the backing List should have.
(package private)  int index
           
(package private)  boolean iterator
          Indicates whether this Enumerator is serving as an Iterator or an Enumeration.
(package private)  Hashtable.Entry lastReturned
           
(package private)  Hashtable.Entry[] table
           
(package private)  int type
           
 
Constructor Summary
(package private) Hashtable.Enumerator(int type, boolean iterator)
           
 
Method Summary
 boolean hasMoreElements()
          Tests if this enumeration contains more elements.
 boolean hasNext()
          Returns true if the iteration has more elements.
 Object next()
          Returns the next element in the iteration.
 Object nextElement()
          Returns the next element of this enumeration if this enumeration object has at least one more element to provide.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

Hashtable.Entry[] table

index

int index

entry

Hashtable.Entry entry

lastReturned

Hashtable.Entry lastReturned

type

int type

iterator

boolean iterator
Indicates whether this Enumerator is serving as an Iterator or an Enumeration. (true -> Iterator).


expectedModCount

protected int expectedModCount
The modCount value that the iterator believes that the backing List should have. If this expectation is violated, the iterator has detected concurrent modification.

Constructor Detail

Hashtable.Enumerator

Hashtable.Enumerator(int type,
                     boolean iterator)
Method Detail

hasMoreElements

public boolean hasMoreElements()
Description copied from interface: Enumeration
Tests if this enumeration contains more elements.

Specified by:
hasMoreElements in interface Enumeration
Returns:
true if and only if this enumeration object contains at least one more element to provide; false otherwise.

nextElement

public Object nextElement()
Description copied from interface: Enumeration
Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

Specified by:
nextElement in interface Enumeration
Returns:
the next element of this enumeration.

hasNext

public boolean hasNext()
Description copied from interface: Iterator
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator
Returns:
true if the iterator has more elements.

next

public Object next()
Description copied from interface: Iterator
Returns the next element in the iteration.

Specified by:
next in interface Iterator
Returns:
the next element in the iteration.

remove

public void remove()
Description copied from interface: Iterator
Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.

Specified by:
remove in interface Iterator