com.sapportals.htmlb.util

Class SingleItemEnumeration

java.lang.Object
  extended bycom.sapportals.htmlb.util.SingleItemEnumeration
All Implemented Interfaces:
Enumeration, Iterator

public class SingleItemEnumeration
extends Object
implements Enumeration, Iterator

A dummy Enumeration that lists exactly one element. This is just a helper for methods that want or need to return an Enumeration but have only one element.

Copyright 2004 SAP AG


Constructor Summary
SingleItemEnumeration(Object theItem)
          Create a new Enumeration of one.
 
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 interation.
 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
 

Constructor Detail

SingleItemEnumeration

public SingleItemEnumeration(Object theItem)
Create a new Enumeration of one.

Parameters:
theItem - the single item for the enumeration
Method Detail

hasMoreElements

public boolean hasMoreElements()
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()
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.
Throws:
NoSuchElementException - if no more elements exist.

hasNext

public boolean hasNext()
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()
Returns the next element in the interation.

Specified by:
next in interface Iterator
Returns:
the next element in the iteration.
Throws:
NoSuchElementException - iteration has no more elements.

remove

public void remove()
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
Throws:
UnsupportedOperationException - if the remove operation is not supported by this Iterator.
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.


Copyright 2006 SAP AG Complete Copyright Notice