com.bluemarsh.jswat.util
Class ThreadGroupIterator

java.lang.Object
  |
  +--com.bluemarsh.jswat.util.ThreadGroupIterator
All Implemented Interfaces:
java.util.Iterator

public class ThreadGroupIterator
extends java.lang.Object
implements java.util.Iterator

Class ThreadGroupIterator has special functionality for iterating over a list of thread group references. Since thread groups are often assembled in trees, this iterator uses a stack to traverse that tree in depth-first order.

Author:
Nathan Fiedler

Field Summary
protected  java.util.Stack stack
          Stack of thread group iterators.
 
Constructor Summary
ThreadGroupIterator(java.util.List groups)
          Constructs a new ThreadGroupIterator with an initial set of thread group iterators.
ThreadGroupIterator(com.sun.jdi.ThreadGroupReference group)
          Constructs a new ThreadGroupIterator with an initial set of thread groups.
 
Method Summary
 boolean hasNext()
          Returns true if there are more iterators to be examined.
 java.lang.Object next()
          Returns the next element in the interation.
protected  java.util.Iterator peek()
          Looks at the object at the top of this stack without removing it from the stack.
protected  void push(java.util.List groups)
          Push the given list of thread group iterators onto the stack.
 void remove()
          Remove is not supported on this iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stack

protected java.util.Stack stack
Stack of thread group iterators.
Constructor Detail

ThreadGroupIterator

public ThreadGroupIterator(java.util.List groups)
Constructs a new ThreadGroupIterator with an initial set of thread group iterators.
Parameters:
groups - ThreadGroup list.

ThreadGroupIterator

public ThreadGroupIterator(com.sun.jdi.ThreadGroupReference group)
Constructs a new ThreadGroupIterator with an initial set of thread groups.
Parameters:
group - ThreadGroup
Method Detail

hasNext

public boolean hasNext()
Returns true if there are more iterators to be examined.
Specified by:
hasNext in interface java.util.Iterator
Returns:
True if there are more iterators.

next

public java.lang.Object next()
Returns the next element in the interation.
Specified by:
next in interface java.util.Iterator
Returns:
Next object in iteration.

peek

protected java.util.Iterator peek()
Looks at the object at the top of this stack without removing it from the stack.
Returns:
First iterator on the stack, or null if none.

push

protected void push(java.util.List groups)
Push the given list of thread group iterators onto the stack.
Parameters:
groups - List of ThreadGroup iterators.

remove

public void remove()
Remove is not supported on this iterator.
Specified by:
remove in interface java.util.Iterator
Throws:
UnsupportedOperationException - Thrown always.