cbr.util
Class LineIterator

java.lang.Object
  extended bycbr.util.LineIterator
All Implemented Interfaces:
Iterator

public class LineIterator
extends Object
implements Iterator

This iterator takes an input stream and iterates through the lines read from it. Each line is returned successively as a String on calls to the method next. In order to iterate through a directory of pictures, make a list of the pictures in that directory. This is accomplished for instance by issuing the command ls >ls.txt in the picture folder.

Version:
"$Id: LineIterator.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth

Field Summary
private  String next_
           
private  LineNumberReader reader_
           
 
Constructor Summary
LineIterator(InputStream in)
          Creates an instance that iterates the given directory.
 
Method Summary
protected  void finalize()
          Free the reader if the iterator is not exhausted.
 boolean hasNext()
          Fulfils the contract of Iterator.
 Object next()
          Fulfils the contract of Iterator.
 void remove()
          Callers have no business removing pictures.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reader_

private LineNumberReader reader_

next_

private String next_
Constructor Detail

LineIterator

public LineIterator(InputStream in)
Creates an instance that iterates the given directory. No-one but the owning class is allowed to create an instance.

Method Detail

hasNext

public boolean hasNext()
Fulfils the contract of Iterator.

Specified by:
hasNext in interface Iterator
Returns:
true if there are more pictures.

next

public Object next()
            throws NoSuchElementException
Fulfils the contract of Iterator.

Specified by:
next in interface Iterator
Throws:
NoSuchElementException

remove

public void remove()
Callers have no business removing pictures.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - always.

finalize

protected void finalize()
Free the reader if the iterator is not exhausted.



Copyright © Fraunhofer Gesellschaft. All Rights Reserved.