com.healthmarketscience.rmiio
Class RemoteIteratorClient<DataType>

java.lang.Object
  extended by com.healthmarketscience.rmiio.RemoteIteratorClient<DataType>
All Implemented Interfaces:
CloseableIOIterator<DataType>, IOIterator<DataType>, RemoteClient, RemoteIterator<DataType>, Closeable, Serializable
Direct Known Subclasses:
SerialRemoteIteratorClient

public abstract class RemoteIteratorClient<DataType>
extends Object
implements RemoteIterator<DataType>, Serializable

Base class for implementing the client side of a RemoteIterator. This object is serialized and sent to the consumer of the data. The consumer then pulls objects through the internal RemoteInputStream as needed. Implementations of this class must implement the initialize(InputStream) and readNextObject() methods. The initialize() method is called once before the first call to readNextObject() and gives the subclass access to the remote input stream. The readNextObject() method should read an object from the underlying input stream and return it. When all data is read, an EOFException should be thrown indicating that the iterator is finished. A subclass may also override closeIterator() to do any final cleanup (called when the EOFException is thrown).

Author:
James Ahlborn
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.healthmarketscience.rmiio.CloseableIOIterator
CloseableIOIterator.Adapter<DataType>
 
Field Summary
 
Fields inherited from interface com.healthmarketscience.rmiio.RemoteClient
DEFAULT_RETRY
 
Constructor Summary
protected RemoteIteratorClient(RemoteIteratorServer<DataType> server)
           
protected RemoteIteratorClient(RemoteIteratorServer<DataType> server, RemoteStreamExporter exporter)
           
 
Method Summary
 void close()
          Closes the iterator and releases the resources for the server object.
protected  void closeIterator()
          Closes any resources held by this iterator.
 boolean hasNext()
          Returns true iff the iteration has more elements.
protected abstract  void initialize(InputStream istream)
          Initializes the subclass with a handle to the underlying remote input stream.
 DataType next()
          Returns the next element in the iteration.
protected abstract  DataType readNextObject()
          Reads the next object from the underlying input stream and returns it.
 void setRemoteRetry(RemoteRetry newRemoteRetry)
          Sets the client side RemoteRetry policy to use for the underlying remote communication layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteIteratorClient

protected RemoteIteratorClient(RemoteIteratorServer<DataType> server)
                        throws IOException
Throws:
IOException

RemoteIteratorClient

protected RemoteIteratorClient(RemoteIteratorServer<DataType> server,
                               RemoteStreamExporter exporter)
                        throws IOException
Throws:
IOException
Method Detail

setRemoteRetry

public void setRemoteRetry(RemoteRetry newRemoteRetry)
Description copied from interface: RemoteClient
Sets the client side RemoteRetry policy to use for the underlying remote communication layer. For most client side implementations, this method must be called before any other calls on this client object (any calls to this method after one of those methods is called will have no affect).

Specified by:
setRemoteRetry in interface RemoteClient
Parameters:
newRemoteRetry - the new RemoteRetry policy to use for remote communication. null causes the RemoteClient.DEFAULT_RETRY policy to be used.

hasNext

public boolean hasNext()
                throws IOException
Description copied from interface: IOIterator
Returns true iff the iteration has more elements.

Specified by:
hasNext in interface IOIterator<DataType>
Throws:
IOException

next

public DataType next()
              throws IOException
Description copied from interface: IOIterator
Returns the next element in the iteration.

Specified by:
next in interface IOIterator<DataType>
Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: RemoteIterator
Closes the iterator and releases the resources for the server object. Note that the remote object may no longer be accessible after this call (depending on the implementation), so clients should not attempt to use this iterator after making this call.

Specified by:
close in interface RemoteIterator<DataType>
Specified by:
close in interface Closeable
Throws:
IOException

closeIterator

protected void closeIterator()
                      throws IOException
Closes any resources held by this iterator.

Throws:
IOException

initialize

protected abstract void initialize(InputStream istream)
                            throws IOException
Initializes the subclass with a handle to the underlying remote input stream. Will be called before any call to readNextObject().

Throws:
IOException

readNextObject

protected abstract DataType readNextObject()
                                    throws IOException
Reads the next object from the underlying input stream and returns it.

Throws:
IOException


Copyright © 2006–2016 Health Market Science. All rights reserved.