Class ByteBufferStoringSubscriber
- java.lang.Object
-
- software.amazon.awssdk.utils.async.ByteBufferStoringSubscriber
-
- All Implemented Interfaces:
org.reactivestreams.Subscriber<ByteBuffer>
public class ByteBufferStoringSubscriber extends Object implements org.reactivestreams.Subscriber<ByteBuffer>
An implementation ofSubscriberthat storesByteBufferevents it receives for retrieval.Stored bytes can be read via
transferTo(ByteBuffer).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classByteBufferStoringSubscriber.TransferResultThe result oftransferTo(ByteBuffer).
-
Constructor Summary
Constructors Constructor Description ByteBufferStoringSubscriber(long minimumBytesBuffered)Create a subscriber that stores at leastminimumBytesBufferedin memory for retrieval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferStoringSubscriber.TransferResultblockingTransferTo(ByteBuffer out)LiketransferTo(ByteBuffer), but blocks until some data has been written.voidonComplete()voidonError(Throwable t)voidonNext(ByteBuffer byteBuffer)voidonSubscribe(org.reactivestreams.Subscription s)ByteBufferStoringSubscriber.TransferResulttransferTo(ByteBuffer out)Transfer the data stored by this subscriber into the provided byte buffer.
-
-
-
Method Detail
-
transferTo
public ByteBufferStoringSubscriber.TransferResult transferTo(ByteBuffer out)
Transfer the data stored by this subscriber into the provided byte buffer.If the data stored by this subscriber exceeds
out'slimit, thenoutwill be filled. If the data stored by this subscriber is less thanout'slimit, then all stored data will be written toout.If
onError(Throwable)was called on this subscriber, as much data as is available will be transferred intooutbefore the provided exception is thrown (as aRuntimeException).If
onComplete()was called on this subscriber, as much data as is available will be transferred intoout, and this will returnByteBufferStoringSubscriber.TransferResult.END_OF_STREAM.Note: This method MUST NOT be called concurrently with itself or
blockingTransferTo(ByteBuffer). Other methods on this class may be called concurrently with this one. This MUST NOT be called beforeonSubscribe(Subscription)has returned.
-
blockingTransferTo
public ByteBufferStoringSubscriber.TransferResult blockingTransferTo(ByteBuffer out)
LiketransferTo(ByteBuffer), but blocks until some data has been written.Note: This method MUST NOT be called concurrently with itself or
transferTo(ByteBuffer). Other methods on this class may be called concurrently with this one.
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription s)
- Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onNext
public void onNext(ByteBuffer byteBuffer)
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onError
public void onError(Throwable t)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<ByteBuffer>
-
-