public abstract class BufferInputStreamConsumer extends InputStreamConsumer
InputStream
into a buffer.
I check my interrupted status when I can, but I will usually not see that
I have been interrupted since I will almost always be blocked reading my
InputStream
which is not an interruptible channel. So, the best
way to get me to die is to close the InputStream
I am reading.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buffer |
protected int |
bufferPosition |
exception, finishedChannel, stream
Constructor and Description |
---|
BufferInputStreamConsumer(int bufferSize)
Creates an instance with the specified buffer size.
|
BufferInputStreamConsumer(int bufferSize,
java.lang.String name)
Creates an instance with the specified buffer size and thread name.
|
BufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group)
Creates an instance with the specified buffer size and thread group.
|
BufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group,
java.lang.String name)
Creates an instance with the specified buffer size, thread group, and
thread name.
|
BufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group,
java.lang.String name,
long stackSize)
Creates an instance with the specified buffer size, thread group,
thread name, and thread stack size.
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
data()
Returns the data consumed from my input stream.
|
protected void |
initialize(int bufferSize)
Initializes me with the specified buffer size.
|
exception, finishedChannel, finishedChannel, hasException, initialize, postProcessData, read, run, stream, stream
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public BufferInputStreamConsumer(int bufferSize)
super()
.bufferSize
- size of the buffer into which I read data from my
input streampublic BufferInputStreamConsumer(int bufferSize, java.lang.String name)
super(name)
.bufferSize
- size of the buffer into which I read data from my
input streamname
- thread namepublic BufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group)
super(group)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread grouppublic BufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name)
super(group, name)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread groupname
- thread namepublic BufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name, long stackSize)
super(group, name, stackSize)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread groupname
- thread namestackSize
- thread stack sizeprotected void initialize(int bufferSize)
bufferSize
- size of the buffer into which I read data from my
input streampublic java.nio.ByteBuffer data()
InputStreamConsumer
This method can be called safely from another thread only after
ensuring all my actions happen-before the action of calling this
method from the other thread. This is the Java memory model
happens-before relationship. For example, after I have been
started, it would be safe to call this method from another thread after
it called my join
method.
data
in class InputStreamConsumer