Main Page | Packages | Class Hierarchy | Class List | File List | Class Members

ArgoPrintIterator.java

Go to the documentation of this file.
00001 //$Id: ArgoPrintIterator_8java-source.html 336 2010-01-12 20:03:17Z linus $
00002 //Copyright (c) 2003, Mikael Albertsson, Mattias Danielsson, Per Engström, 
00003 //Fredrik Gröndahl, Martin Gyllensten, Anna Kent, Anders Olsson, 
00004 //Mattias Sidebäck.
00005 //All rights reserved.
00006 //
00007 //Redistribution and use in source and binary forms, with or without 
00008 //modification, are permitted provided that the following conditions are met:
00009 //
00010 //* Redistributions of source code must retain the above copyright notice, 
00011 //  this list of conditions and the following disclaimer.
00012 // 
00013 //* Redistributions in binary form must reproduce the above copyright 
00014 //  notice, this list of conditions and the following disclaimer in the 
00015 //  documentation and/or other materials provided with the distribution.
00016 //
00017 //* Neither the name of the University of Linköping nor the names of its 
00018 //  contributors may be used to endorse or promote products derived from 
00019 //  this software without specific prior written permission. 
00020 //
00021 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00022 //AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00023 //IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00024 //ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00025 //LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00026 //CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00027 //SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00028 //INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00029 //CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00030 //ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
00031 //THE POSSIBILITY OF SUCH DAMAGE.
00032 
00033 package org.argoprint.engine;
00034 
00035 import java.util.*;
00036 
00037 /**
00038  * Class which extends iterator to better keep track of current object.
00039  *
00040  * @author matda701, Mattias Danielsson
00041  */
00042 public class ArgoPrintIterator implements Iterator{
00043     
00044     /**
00045      * The iterator
00046      */ 
00047     private Iterator _iterator;
00048 
00049     /**
00050      * The current object in the iterator. null until next() has been run.
00051      */
00052     private Object _currentObject;
00053 
00054     /**
00055      * Constructor, takes the iterator to be wrapped into ArgoPrintIterator.
00056      */
00057     public ArgoPrintIterator(Iterator iter){
00058     _iterator = iter;
00059     }
00060 
00061     /**
00062      * Checks if the iterator has more objects.
00063      */
00064     public boolean hasNext(){ return _iterator.hasNext(); }
00065    
00066     /**
00067      * Returns the next object in the iterator. Also updates _currentObject.
00068      */ 
00069     public Object next(){
00070     _currentObject = _iterator.next();
00071     return _currentObject;
00072     }
00073 
00074     /**
00075      * Removes last object returned by next(). Se Iterator for more info.
00076      */
00077     public void remove() 
00078     throws UnsupportedOperationException,
00079            IllegalStateException {
00080     try{
00081         _iterator.remove();
00082     } catch(UnsupportedOperationException e){
00083         throw e;
00084     }
00085     catch(IllegalStateException e){
00086         throw e;
00087     }
00088     }
00089 
00090     /**
00091      * Returns the currentObject in the iterator. Null if next() hasn't been
00092      * invoked.
00093      */
00094     public Object currentObject(){
00095     return _currentObject;
00096     }
00097 }

Generated on Tue Dec 2 22:50:56 2003 for ArgoPrint by doxygen 1.3.4