FreeHEP API
Version v1.2.2

hep.graphics.heprep.ref
Class DefaultHepRepIterator

java.lang.Object
  |
  +--hep.graphics.heprep.ref.DefaultHepRepIterator
All Implemented Interfaces:
HepRepIterator, Iterator

public class DefaultHepRepIterator
extends Object
implements HepRepIterator

Fast iterator, which allows for iteration of all HepRepInstances in a HepRepInstanceTree or for iteration of a specific layer. It also features a callback to a HepRepListener to signal changes in attributes.

Version:
$Id: DefaultHepRepIterator.java,v 1.18 2003/12/03 01:07:24 duns Exp $
Author:
M.Donszelmann

Constructor Summary
DefaultHepRepIterator(HepRepInstanceTree instanceTree)
          Creates a HepRepIterator for the given InstanceTree.
DefaultHepRepIterator(HepRepInstanceTree instanceTree, List layers)
          Creates a HepRepIterator for the given InstanceTree and set of layers.
DefaultHepRepIterator(HepRepInstanceTree instanceTree, List layers, boolean reportAllForLayerChange)
          Creates a HepRepIterator for the given InstanceTree and set of layers.
 
Method Summary
 void addHepRepIteratorListener(HepRepIteratorListener l)
          Add a listener to be informed about attribute changes while the iteration is ongoing.
 HepRepAttValue getAttValue(String key)
          Returns the attValue for key at the current point of iteration.
 boolean hasNext()
          Prepares the next instance and returns true if exists.
 Object next()
           
 HepRepInstance nextInstance()
          Returns next instance.
 void remove()
          Removes the current instance, however this is not permitted.
 void removeHepRepIteratorListener(HepRepIteratorListener l)
          Remove a listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultHepRepIterator

public DefaultHepRepIterator(HepRepInstanceTree instanceTree)
Creates a HepRepIterator for the given InstanceTree. Layer changes are reported but ignored.

Parameters:
instanceTree - to be iterated over.

DefaultHepRepIterator

public DefaultHepRepIterator(HepRepInstanceTree instanceTree,
                             List layers)
Creates a HepRepIterator for the given InstanceTree and set of layers.

Parameters:
instanceTree - to be iterated over.
layers - to be used in iteration.

DefaultHepRepIterator

public DefaultHepRepIterator(HepRepInstanceTree instanceTree,
                             List layers,
                             boolean reportAllForLayerChange)
Creates a HepRepIterator for the given InstanceTree and set of layers.

Parameters:
instanceTree - to be iterated over for given layers.
layers - to be used in iteration.
reportAllForLayerChange - true will report all attributes at every layer change.
Method Detail

addHepRepIteratorListener

public void addHepRepIteratorListener(HepRepIteratorListener l)
                               throws TooManyListenersException
Add a listener to be informed about attribute changes while the iteration is ongoing. Only one listener is allowed.

Specified by:
addHepRepIteratorListener in interface HepRepIterator
Parameters:
l - listener to be added.
TooManyListenersException

removeHepRepIteratorListener

public void removeHepRepIteratorListener(HepRepIteratorListener l)
Remove a listener.

Specified by:
removeHepRepIteratorListener in interface HepRepIterator
Parameters:
l - listener to be removed.

getAttValue

public HepRepAttValue getAttValue(String key)
Description copied from interface: HepRepIterator
Returns the attValue for key at the current point of iteration.

Specified by:
getAttValue in interface HepRepIterator
Parameters:
key - name of tye attribute to be looked up.
Returns:
the current value of an attribute, given the key

nextInstance

public HepRepInstance nextInstance()
Description copied from interface: HepRepIterator
Returns next instance.

Specified by:
nextInstance in interface HepRepIterator
Returns:
the next HepRepInstance

next

public Object next()
Specified by:
next in interface Iterator
Returns:
the next HepRepInstance

hasNext

public boolean hasNext()
Prepares the next instance and returns true if exists. Successive calls to hasNext() without calling next() or nextInstance() are ignored. The instances are walked through the tree in in-order traversal.

Specified by:
hasNext in interface HepRepIterator
Returns:
true if there exists a next HepRepInstance

remove

public void remove()
            throws UnsupportedOperationException
Removes the current instance, however this is not permitted.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - in all cases.

FreeHEP API
Version v1.2.2

Copyright © 2000-2003 FreeHEP, All Rights Reserved.