org.snmp4j.agent.request
Class SubRequestIteratorSupport

java.lang.Object
  extended by org.snmp4j.agent.request.SubRequestIteratorSupport
All Implemented Interfaces:
java.util.Iterator, SubRequestIterator

public class SubRequestIteratorSupport
extends java.lang.Object
implements SubRequestIterator

This support class allows to implement a SubRequestIterator instance based on an Iterator that iterates on SubRequest instances.

Version:
1.0
Author:
Frank Fock

Constructor Summary
SubRequestIteratorSupport(java.util.Iterator subRequests)
          Creates a SubRequestIterator that decorates an Iterator.
 
Method Summary
 boolean hasNext()
          Returns true if there are more sub-requests to process.
protected  SubRequest mapToSubRequest(java.lang.Object element)
          Returns the SubRequest contained or represented by the supplied object (element of the iterator).
 java.lang.Object next()
           
 SubRequest nextSubRequest()
          Gets the next sub-request that is pending.
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubRequestIteratorSupport

public SubRequestIteratorSupport(java.util.Iterator subRequests)
Creates a SubRequestIterator that decorates an Iterator.

Parameters:
subRequests - an Iterator on SubRequest instances or instances of other objects if mapToSubRequest(Object element) is implemented (overwritten) accordingly.
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: SubRequestIterator
Returns true if there are more sub-requests to process. In other words, returns true if next would return an element rather than throwing an exception.

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in interface SubRequestIterator
Returns:
true if there are more sub-requests.

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

nextSubRequest

public SubRequest nextSubRequest()
                          throws java.util.NoSuchElementException
Description copied from interface: SubRequestIterator
Gets the next sub-request that is pending.

Specified by:
nextSubRequest in interface SubRequestIterator
Returns:
an unprocessed SnmpSubRequest instance.
Throws:
java.util.NoSuchElementException

remove

public void remove()
Specified by:
remove in interface java.util.Iterator

mapToSubRequest

protected SubRequest mapToSubRequest(java.lang.Object element)
Returns the SubRequest contained or represented by the supplied object (element of the iterator). The default implementation simply casts the supplied object to SubRequest.

Parameters:
element - an Object from which a SubRequest can be deduced.
Returns:
a SubRequest instance.

Copyright 2005-2008 Frank Fock (SNMP4J.org)