cbr.service
Class PicsIterator

java.lang.Object
  extended bycbr.service.PicsIterator
All Implemented Interfaces:
Iterator

public class PicsIterator
extends Object
implements Iterator

This class iterates over the picture entries read from an input stream. Please note that this class does not close the input stream. The owning class must do this when the input stream is not longer required. For convenience this class provides a close() method which closes the stream passed to the constructor. This close method is also called upon finalization of instances of this class.

StoreDelegate instances can be passed to instances of this class in order to handle thumbnails.

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

Field Summary
private  StoreDelegate delegate_
          The StoreDelegate that is used to paste back in entries into the entries.
private  ObjectInputStream in_
          The stream from which the entries are read.
private  Object next_
          The next object that will be returned upon a call to next() or null if there are no more objects.
 
Constructor Summary
PicsIterator()
          Creates an instance that iterates the empty set of pictures.
PicsIterator(InputStream in)
          Creates an instance that reads from the given input stream.
PicsIterator(InputStream in, StoreDelegate delegate)
          Creates an instance that uses the given StoreDelegate for pasting thumbnails back into the entries which are returned.
 
Method Summary
 void close()
          Closes the stream.
protected  void finalize()
           
 boolean hasNext()
          Fulfills the general contract of Iterator.
 Object next()
          Fulfills the general contract of Iterator.
private  void read()
          Reads in the next picture entry.
 void remove()
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in_

private ObjectInputStream in_
The stream from which the entries are read.


next_

private Object next_
The next object that will be returned upon a call to next() or null if there are no more objects.


delegate_

private StoreDelegate delegate_
The StoreDelegate that is used to paste back in entries into the entries.

Constructor Detail

PicsIterator

public PicsIterator()
Creates an instance that iterates the empty set of pictures.


PicsIterator

public PicsIterator(InputStream in)
             throws IOException
Creates an instance that reads from the given input stream. Picture entries are read until an instance is encountered in the stream which is not of class PictureEntry. The given stream is not automatically closed.

This constructor is equivalent to calling PicsIterator(in, null).

Parameters:
in - The stream from which picture entries are read.
Throws:
IOException - if an I/O error occurs.

PicsIterator

public PicsIterator(InputStream in,
                    StoreDelegate delegate)
             throws IOException
Creates an instance that uses the given StoreDelegate for pasting thumbnails back into the entries which are returned.

If null is passed as input stream then the iterator iterates the equivalent of an empty set.

Parameters:
in - The stream from which picture entries are read.
delegate - The StoreDelegate that handles thumbnails.
Throws:
IOException - if an I/O error occurs.
Method Detail

hasNext

public boolean hasNext()
Fulfills the general contract of Iterator.

Specified by:
hasNext in interface Iterator
Returns:
true iff there are more picture entries.

next

public Object next()
            throws NoSuchElementException
Fulfills the general contract of Iterator. This method returns the next picture entry or throws NoSuchElementException if there are no more entries.

Specified by:
next in interface Iterator
Returns:
The next picture entry.
Throws:
NoSuchElementException - iff there are no more picture entries.

remove

public void remove()
Not supported.

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

read

private void read()
Reads in the next picture entry. If a StoreDelegate delegate was set then it is asked to paste the thumbnail of that entry back into it.


close

public void close()
           throws IOException
Closes the stream.

Throws:
IOException - thrown by InputStream.

finalize

protected void finalize()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.