Holger's
Java API

com.antelmann.io
Class ObjectEnumerator

java.lang.Object
  extended by com.antelmann.util.AbstractIterator<Object>
      extended by com.antelmann.io.ObjectEnumerator
All Implemented Interfaces:
Closeable, Iterable<Object>, Enumeration<Object>, Iterator<Object>

public class ObjectEnumerator
extends AbstractIterator<Object>

used to iterate over (potentially serialized) objects contained in a binary file or InputStream. If deserialization is enabled, the ObjectEnumerator automatically attempts to convert a discovered byte array into an Object via deserialization.

Author:
Holger Antelmann
See Also:
MyFile.objectEnumerator(), MyFile.objectEnumerator(boolean), MyFile.objectEnumerator(boolean, Logger)

Constructor Summary
ObjectEnumerator(File file, boolean useDeserialization)
           
ObjectEnumerator(File file, boolean useDeserialization, Logger exceptionLogger)
           
ObjectEnumerator(InputStream stream, boolean useDeserialization)
           
ObjectEnumerator(InputStream stream, boolean useDeserialization, Logger exceptionLogger)
           
 
Method Summary
 void close()
          closes this iterator by calling AbstractIterator.stopIteration().
protected  void finalize()
          closes the embedded input stream
 Object getNextElement()
          if no more Element is available, this method is to return null or throw any Exception.
 ObjectInputStream getStream()
          provides direct access to the embedded stream in use
 
Methods inherited from class com.antelmann.util.AbstractIterator
allowsNull, asIterable, concat, concat, convert, convert, count, currentElement, emptyEnumeration, emptyIterable, emptyIterator, enumerate, filter, filter, getAll, getCount, getEndCondition, getFilter, hasMoreElements, hasNext, iterate, iterate, iterator, list, list, list, list, monitor, monitor, next, nextElement, process, process, propagatesException, remove, reverseEnumeration, setAllowNull, setFilter, setPropagateException, sortEnumeration, sortEnumeration, stopIteration
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectEnumerator

public ObjectEnumerator(File file,
                        boolean useDeserialization)
                 throws IOException
Throws:
IOException

ObjectEnumerator

public ObjectEnumerator(File file,
                        boolean useDeserialization,
                        Logger exceptionLogger)
                 throws IOException
Throws:
IOException

ObjectEnumerator

public ObjectEnumerator(InputStream stream,
                        boolean useDeserialization)
                 throws IOException
Throws:
IOException

ObjectEnumerator

public ObjectEnumerator(InputStream stream,
                        boolean useDeserialization,
                        Logger exceptionLogger)
                 throws IOException
Throws:
IOException
Method Detail

getStream

public ObjectInputStream getStream()
provides direct access to the embedded stream in use


close

public void close()
           throws IOException
Description copied from class: AbstractIterator
closes this iterator by calling AbstractIterator.stopIteration(). You can use this method to clean up any resources there may be needed for this iterator. Note, however, that this method is not called automatically; so if you need this method to be called after the iteration is through (or only partially used), you have to call this method yourself (or you overwrite this implementation accordingly). Also, when overriding this method, you should call super.close().

Specified by:
close in interface Closeable
Overrides:
close in class AbstractIterator<Object>
Throws:
IOException

finalize

protected void finalize()
                 throws IOException
closes the embedded input stream

Overrides:
finalize in class Object
Throws:
IOException

getNextElement

public Object getNextElement()
                      throws Exception
Description copied from class: AbstractIterator
if no more Element is available, this method is to return null or throw any Exception. Errors (as opposed to Exceptions) are not caught, i.e. they would always be thrown directly and unwrapped during next().

Specified by:
getNextElement in class AbstractIterator<Object>
Throws:
Exception


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads