Dresden OCL Toolkit

tudresden.ocl.lib
Class OclIterator

java.lang.Object
  extended bytudresden.ocl.lib.OclIterator

public class OclIterator
extends Object

The OclIterator is needed to transform OCL iterating methods to Java. An OclIterator can be obtained from an OclCollection and is given back to the OclCollection as an argument of the iterating method.

This class is a wrapper class around an java.util.Iterator. It differs from Iterator in the ability to set the pointer to the next element once and then read this element arbitrarily often. In contrast, Iterator moves the pointer every time the element is read.

When constructed, the OclIterators pointer is before the first element. Calling getValue() would yield null.

Author:
Frank Finger
See Also:
OclCollection

Field Summary
private  Iterator iter
           
private  OclRoot value
           
 
Constructor Summary
protected OclIterator(Collection c)
           
protected OclIterator(Iterator i)
           
 
Method Summary
 OclRoot getValue()
          This operation is the only one that is called from out of the OCL class library.
(package private)  boolean hasNext()
           
(package private)  void next()
          moves the OclIterators pointer to the next element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iter

private Iterator iter

value

private OclRoot value
Constructor Detail

OclIterator

protected OclIterator(Collection c)

OclIterator

protected OclIterator(Iterator i)
Method Detail

getValue

public OclRoot getValue()
This operation is the only one that is called from out of the OCL class library. It returns the OclRoot element that the OclIterator is pointing to.


hasNext

boolean hasNext()
Returns:
true if the iteration has more elements

next

void next()
moves the OclIterators pointer to the next element

Throws:
OclClassCastException - if the next element that the backing java.lang.Iterator returns is not of type OclRoot; this means propably that the OclCollection that returned this OclIterator contains non-OclRoot elements

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.