net.sf.asyncobjects.io.util
Class NulInput<D extends BatchedData<D>,I extends AInput<D>>

java.lang.Object
  extended by net.sf.asyncobjects.AsyncUnicastServer<I>
      extended by net.sf.asyncobjects.io.util.NulInput<D,I>
Type Parameters:
D - a batched data type
I - an input stream type
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing, AInput<D>
Direct Known Subclasses:
NulByteInput, NulTextInput

public class NulInput<D extends BatchedData<D>,I extends AInput<D>>
extends AsyncUnicastServer<I>
implements AInput<D>

A zero lenght stream. It always returns EOF on read, unless close operation was called.

Author:
const

Constructor Summary
NulInput()
           
 
Method Summary
 Promise<Void> close()
          Close resource
 Promise<Boolean> isPushbackSupported()
           
 Promise<Void> pushback(D data)
          Attempt to return some data to stream.
 Promise<D> read(int limit)
          Read some data.
 
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.AsyncObject
dereference, isImmediate
 

Constructor Detail

NulInput

public NulInput()
Method Detail

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)
Description copied from interface: AInput
Attempt to return some data to stream. Most streams do not support this operation. Note that pushback operation has the same priority as read operation.

Specified by:
pushback in interface AInput<D extends BatchedData<D>>
Parameters:
data - a data to unread.
Returns:
a promise for null or exception if stream does not supports unreading.
See Also:
AInput.pushback(net.sf.asyncobjects.io.BatchedData)

read

public Promise<D> read(int limit)
Description copied from interface: AInput
Read some data.

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)

close

public Promise<Void> close()
Description copied from interface: ACloseable
Close resource

Specified by:
close in interface ACloseable
Returns:
a promise that resolves when object is closed.
See Also:
ACloseable.close()


Copyright 2002-2007 Constantine Plotnikov. All Rights Reserved.