Class SavingInput<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>>

  extended by net.sf.asyncobjects.AsyncUnicastServer<FacetType>
      extended by net.sf.asyncobjects.util.CloseableWrapper<I,I>
          extended by<D,I,O>
Type Parameters:
D - a batched data type
I - an input type
O - an output type
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing, AInput<D>
Direct Known Subclasses:
SavingByteInput, SavingTextInput

public class SavingInput<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>>
extends CloseableWrapper<I,I>
implements AInput<D>

This utility stream allows to save all data read from byte input to some output. It is useful for saving protocol of the session in file for further analysis during debugging. Note that output is never closed by this stream. The stream should be closed when allWritten() is smashed or resolved.

The stream support pushback(BatchedData) method if the underlying stream supports it. However the pushed back data is not saved. If pushback is detected, the stream ignores the next amount of bytes that has been pushed back if pushback operation was successful.


Nested Class Summary
Nested classes/interfaces inherited from class net.sf.asyncobjects.util.CloseableWrapper
Field Summary
Fields inherited from class net.sf.asyncobjects.util.CloseableWrapper
closeWrapper, requests, wrapped
Constructor Summary
SavingInput(I in, boolean closeInput, O out)
          A constructor
Method Summary
 Promise<Void> allWritten()
 Promise<Boolean> isPushbackSupported()
 Promise<Void> pushback(D data)
          Pushbback some data
 Promise<D> read(int limit)
          In addition to stantad semantics.
Methods inherited from class net.sf.asyncobjects.util.CloseableWrapper
afterInvalidate, beforeClose, close, closed, ensureOpen, ensureValid, invalidate, isValid
Methods inherited from class net.sf.asyncobjects.AsyncUnicastServer
dereference, export, isImmediate, myVat, promise
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.sf.asyncobjects.ACloseable
Methods inherited from interface net.sf.asyncobjects.AsyncObject
dereference, isImmediate

Constructor Detail


public SavingInput(I in,
                   boolean closeInput,
                   O out)
A constructor

in - an input to read
closeInput - if true input is closed on close operation
out - an output to write
Method Detail


public Promise<D> read(int limit)
In addition to stantad semantics. This method also saves all read data to output stream.

Specified by:
read in interface AInput<D extends BatchedData<D>>
limit - a maximum amount of data elements to read.
Promise for non-empty data batch that contains read inforation or null if eof is reached.
See Also:


public Promise<Void> allWritten()
a promise that resolves when all data has been read and sent to output. If there were errors during read or write operations, the promise is smashed with corresponding problem.


public Promise<Boolean> isPushbackSupported()
Specified by:
isPushbackSupported in interface AInput<D extends BatchedData<D>>
true if pushback supported for this stream
See Also:


public Promise<Void> pushback(D data)
Pushbback some data

Specified by:
pushback in interface AInput<D extends BatchedData<D>>
data - a data to push back
when pushback finishes
See Also:

Copyright 2002-2007 Constantine Plotnikov. All Rights Reserved.