Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 57   Methods: 4
NCLOC: 22   Classes: 2
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
TransformingIterator.java - 100% 100% 100%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.util.collection;
 11   
 
 12   
 import java.util.Iterator;
 13   
 
 14   
 public class TransformingIterator implements Iterator {
 15   
 
 16   
   private Iterator myIterator = null;
 17   
   private ITransformation myTransformation = null;
 18   
 
 19   
   /**
 20   
    * Interface which must be implemented in order to decide wheter objects
 21   
    * should be included in the iteration or not.
 22   
    */
 23   
   public static interface ITransformation {
 24   
     /**
 25   
      * Transforms the iterated objects.
 26   
      *
 27   
      * @return <i>(optional)</i>. A transformed object.
 28   
      */
 29   
     Object transform(Object anObject);
 30   
   }
 31   
 
 32   
   /**
 33   
    * Constructs a TransformingIterator, i.e.&nbsp; an iterator which returns as many
 34   
    * transformed objects as the source iterator contains objects.
 35   
    *
 36   
    * @param anIterator The iterator that should be transformed.
 37   
    * @param aTransformation The transformation that should be applied to the objects.
 38   
    */
 39  2530
   public TransformingIterator(Iterator anIterator, ITransformation aTransformation) {
 40  2530
     myIterator = anIterator;
 41  2530
     myTransformation = aTransformation;
 42   
   }
 43   
 
 44  2253
   public Object next() {
 45  2253
     return myTransformation.transform(myIterator.next());
 46   
   }
 47   
 
 48  4698
   public boolean hasNext() {
 49  4698
     return myIterator.hasNext();
 50   
   }
 51   
 
 52  4
   public void remove() {
 53  4
     myIterator.remove();
 54   
   }
 55   
 
 56   
 }
 57