View Javadoc
1 /* 2 Bloof - visualize the evolution of your software project 3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de> 4 http://bloof.sf.net/ 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 this program; if not, write to the Free Software Foundation, Inc., 16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 $RCSfile: StringIterator.java,v $ 19 Created on $Date: 2003/06/28 06:51:42 $ 20 */ 21 package net.sf.bloof.db; 22 23 import java.sql.ResultSet; 24 import java.sql.SQLException; 25 import java.util.ArrayList; 26 import java.util.Iterator; 27 import java.util.logging.Logger; 28 29 /*** 30 * Interates on a ResultList of Strings 31 * @author Lukasz Pekacki <pekacki@users.sourceforge.net> 32 * @version $Id: StringIterator.java,v 1.4 2003/06/28 06:51:42 pekacki Exp $ 33 */ 34 public class StringIterator { 35 /*** 36 * Constructs a StringIterator for a list of Strings 37 * @param aStringList list of Strings 38 */ 39 public StringIterator(ArrayList aStringList) { 40 mStringListIterator = aStringList.iterator(); 41 } 42 /*** 43 * Constructs a StringIterator on a ResultSet 44 * PRE: aResultSet.getString( 1 ) must return valid String objects 45 * @param aResultSet the ResultSet 46 */ 47 public StringIterator(ResultSet aResultSet) { 48 mResultSet = aResultSet; 49 } 50 /*** 51 * @see java.util.Iterator#hasNext( ) 52 */ 53 public boolean hasNext() { 54 if (mResultSet != null) { 55 try { 56 return mResultSet.next(); 57 } catch (SQLException e) { 58 sLogger.warning(e.toString()); 59 return false; 60 } 61 } else { 62 return mStringListIterator.hasNext(); 63 } 64 } 65 66 /*** 67 * @see java.util.Iterator#next( ) 68 */ 69 public String next() { 70 if (mResultSet != null) { 71 try { 72 return mResultSet.getString(1); 73 } catch (SQLException e) { 74 sLogger.warning(e.toString()); 75 return null; 76 } 77 } else { 78 return (String) mStringListIterator.next(); 79 } 80 } 81 82 private static Logger sLogger = Logger.getLogger(StringIterator.class.getName()); 83 private ResultSet mResultSet; 84 private Iterator mStringListIterator; 85 }

This page was automatically generated by Maven