org.ontoware.rdf2go.util
Class Iterators

java.lang.Object
  extended by org.ontoware.rdf2go.util.Iterators

public class Iterators
extends java.lang.Object

This class consists exclusively of static methods that operate on or return iterators. It is the Iterator-equivalent of java.util.Collections. copied into RDF2Go by Leo Sauemann on 11.1.2007, it helps to get working quicker.


Constructor Summary
Iterators()
           
 
Method Summary
static
<E,C extends java.util.Collection<E>>
C
addAll(java.util.Iterator<? extends E> iter, C collection)
          Adds all elements from the supplied iterator to the specified collection.
static void closeCloseable(java.util.Iterator<?> iter)
          Closes the supplied iterator if it is an instance of CloseableIterator, otherwise the request is ignored.
static int count(java.util.Iterator<?> it)
          Runs through the iterator and returns number of items.
static java.lang.String toString(java.util.Iterator<?> iter, java.lang.String separator)
          Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
static void toString(java.util.Iterator<?> iter, java.lang.String separator, java.lang.StringBuilder sb)
          Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterators

public Iterators()
Method Detail

addAll

public static <E,C extends java.util.Collection<E>> C addAll(java.util.Iterator<? extends E> iter,
                                                             C collection)
Adds all elements from the supplied iterator to the specified collection. If the supplied iterator is an instance of CloseableIterator it is automatically closed after consumption.

Parameters:
iter - An iterator containing elements to add to the container. If the iterator is an instance of CloseableIterator it is automatically closed after consumption.
collection - The collection to add the elements to.
Returns:
The collection object that was supplied to this method.

closeCloseable

public static void closeCloseable(java.util.Iterator<?> iter)
Closes the supplied iterator if it is an instance of CloseableIterator, otherwise the request is ignored.

Parameters:
iter - The iterator that should be closed.

toString

public static java.lang.String toString(java.util.Iterator<?> iter,
                                        java.lang.String separator)
Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.

Parameters:
iter - An iterator over arbitrary objects that are expected to implement Object.toString().
separator - The separator to insert between the object strings.
Returns:
A String representation of the objects provided by the supplied iterator.

toString

public static void toString(java.util.Iterator<?> iter,
                            java.lang.String separator,
                            java.lang.StringBuilder sb)
Converts an iterator to a string by concatenating all of the string representations of objects in the iterator, divided by a separator.

Parameters:
iter - An iterator over arbitrary objects that are expected to implement Object.toString().
separator - The separator to insert between the object strings.
sb - A StringBuilder to append the iterator string to.

count

public static int count(java.util.Iterator<?> it)
Runs through the iterator and returns number of items. It doesn't close it.

Parameters:
it - Any type of iterator, not null


Copyright © 2005-2008 FZI - Forschungszentrum Informatik | Karlsruhe | Germany. All Rights Reserved.