net.sf.asyncobjects.io.util
Class SavingInput<D extends BatchedData<D>,I extends AInput<D>,O extends AOutput<D>>
java.lang.Object
net.sf.asyncobjects.AsyncUnicastServer<FacetType>
net.sf.asyncobjects.util.CloseableWrapper<I,I>
net.sf.asyncobjects.io.util.SavingInput<D,I,O>
- Type Parameters:
D
- a batched data typeI
- an input typeO
- 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.
- Author:
- const
Constructor Summary |
SavingInput(I in,
boolean closeInput,
O out)
A constructor |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SavingInput
public SavingInput(I in,
boolean closeInput,
O out)
- A constructor
- Parameters:
in
- an input to readcloseInput
- if true input is closed on close operationout
- an output to write
read
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>>
- Parameters:
limit
- a maximum amount of data elements to read.
- Returns:
- Promise for non-empty data batch that contains read inforation or
null if eof is reached.
- See Also:
AInput.read(int)
allWritten
public Promise<Void> allWritten()
- Returns:
- 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.
isPushbackSupported
public Promise<Boolean> isPushbackSupported()
- Specified by:
isPushbackSupported
in interface AInput<D extends BatchedData<D>>
- Returns:
- true if pushback supported for this stream
- See Also:
AInput.isPushbackSupported()
pushback
public Promise<Void> pushback(D data)
- Pushbback some data
- Specified by:
pushback
in interface AInput<D extends BatchedData<D>>
- Parameters:
data
- a data to push back
- Returns:
- when pushback finishes
- See Also:
AInput.pushback(net.sf.asyncobjects.io.BatchedData)
Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.