001 /** 002 * OntoBride library 003 * Departamento de Ingeniería del Software e Inteligencia Artificial 004 * Universidad Complutense de Madrid 005 * 006 * Licensed under the terms of the GNU Library or Lesser General Public License (LGPL) 007 * 008 * @author Juan A. Recio García 009 * 010 * This software is a subproject of the jCOLIBRI framework 011 * http://sourceforge.net/projects/jcolibri-cbr/ 012 * http://gaia.fdi.ucm.es/projects/jcolibri/ 013 * 014 * File: ToStringIterator.java 015 * 22/11/2006 016 */ 017 package es.ucm.fdi.gaia.ontobridge.util; 018 019 import java.util.Iterator; 020 021 /** 022 * Converts a JENA iterator into an String iterator. This class allows to convert 023 * between JENA classes and their corresponding URI representation in a very 024 * efficient way. 025 * 026 * @author Juan A. Recio Garcia 027 */ 028 public class ToStringIterator<T> implements Iterator<T> { 029 030 private Iterator _iter; 031 032 /** 033 * Constructor. 034 * @param iter wrapped iterator which elements are converted into strings. 035 */ 036 public ToStringIterator(Iterator iter) 037 { 038 _iter = iter; 039 } 040 041 /** 042 * Indicates if there are more elements 043 */ 044 public boolean hasNext() { 045 return _iter.hasNext(); 046 } 047 048 /** 049 * Returns the following element as an string. 050 */ 051 @SuppressWarnings("unchecked") 052 public T next() { 053 return (T)_iter.next().toString(); 054 } 055 056 /** 057 * Removes an element of the collection 058 */ 059 public void remove() { 060 _iter.remove(); 061 062 } 063 064 065 066 }