public abstract class AbstractInputStreamBuffer extends AbstractStreamingBuffer implements InputStreamBuffer
InputStreamBuffer.
Contains the base algorithm and template methods so that implementations can be created easily
AbstractStreamingBuffer.LockReleaser| Modifier and Type | Field and Description |
|---|---|
protected org.mule.runtime.api.util.LazyValue<ByteBuffer> |
buffer |
protected ByteBufferManager |
bufferManager |
closed, readLock, writeLock| Constructor and Description |
|---|
AbstractInputStreamBuffer(InputStream stream,
ByteBufferManager bufferManager,
int bufferSize)
Creates a new instance
|
AbstractInputStreamBuffer(InputStream stream,
ReadableByteChannel streamChannel,
ByteBufferManager bufferManager,
int bufferSize)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
canDoSoftCopy() |
void |
close()
Releases all the resources held by this buffer
|
protected void |
consume(ByteBuffer data) |
abstract int |
consumeForwardData()
Consumes the stream in order to obtain data that has not been read yet.
|
protected int |
consumeStream(ByteBuffer buffer) |
protected ByteBuffer |
copy(long position,
int length) |
protected void |
deallocate(ByteBuffer byteBuffer) |
abstract void |
doClose()
Template method to support the
close() operation |
protected abstract ByteBuffer |
doGet(long position,
int length) |
ByteBuffer |
get(long position,
int length)
Returns a ByteBuffer with up to
length amount of bytes starting from the given
position. |
ByteBuffer |
getBuffer() |
protected boolean |
isStreamFullyConsumed() |
protected static ReadableByteChannel |
openStreamChannel(InputStream stream) |
protected void |
streamFullyConsumed() |
checkNotClosed, closeSafely, withReadLock, withWriteLockprotected final ByteBufferManager bufferManager
protected org.mule.runtime.api.util.LazyValue<ByteBuffer> buffer
public AbstractInputStreamBuffer(InputStream stream, ByteBufferManager bufferManager, int bufferSize)
stream - The stream being buffered. This is the original data sourcebufferSize - the buffer sizebufferManager - the ByteBufferManager that will be used to allocate all bufferspublic AbstractInputStreamBuffer(InputStream stream, ReadableByteChannel streamChannel, ByteBufferManager bufferManager, int bufferSize)
stream - The stream being buffered. This is the original data sourcestreamChannel - a ReadableByteChannel used to read from the streambufferManager - the ByteBufferManager that will be used to allocate all buffersbufferSize - the buffer sizeprotected static ReadableByteChannel openStreamChannel(InputStream stream)
stream - the stream to consumeReadableByteChannel for consuming the streampublic abstract int consumeForwardData()
throws IOException
IOExceptionpublic final void close()
close in interface InputStreamBufferpublic abstract void doClose()
close() operationpublic final ByteBuffer get(long position, int length)
length amount of bytes starting from the given
position. The returned buffer may contain less information than requested.
If no information is available at all, then it returns nullget in interface InputStreamBufferposition - the stream position from which the data should be readlength - how many bytes to readByteBuffer with up to length bytes of information or null if no information
available at allIllegalStateException - if the buffer is closedprotected abstract ByteBuffer doGet(long position, int length)
protected void consume(ByteBuffer data)
public ByteBuffer getBuffer()
bufferprotected int consumeStream(ByteBuffer buffer) throws IOException
IOExceptionprotected void deallocate(ByteBuffer byteBuffer)
protected boolean isStreamFullyConsumed()
protected void streamFullyConsumed()
protected final ByteBuffer copy(long position, int length)
protected abstract boolean canDoSoftCopy()
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.