Subclasses determine the behavior when the in-memory buffer capacity has been exceeded and additional bytes are still being received for output.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| private class | |
| public static class | TemporaryBuffer.
A temporary buffer that will never exceed its in-memory limit. |
| public static class | TemporaryBuffer.
A fully buffered output stream using local disk storage for large data. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv ArrayList | blocks
Chain of data, if we are still completely in-core; otherwise null. |
| protected static final int | DEFAULT_IN_CORE_LIMIT
Default limit for in-core storage. |
| private int | inCoreLimit
Maximum number of bytes we will permit storing in memory. |
| private int | initialBlocks
Initial size of block list. |
| private OutputStream | overflow
If |
| Access | Constructor and Description |
|---|---|
| protected | TemporaryBuffer(int
maximum number of bytes to store in memory before entering the
overflow output path; also used as the estimated size. limit)Create a new empty temporary buffer. |
| protected | TemporaryBuffer(int
estimated size of storage used, to size the initial list of
block pointers. estimatedSize, int maximum number of bytes to store in memory before entering the
overflow output path. limit)Create a new empty temporary buffer. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. Closes this output stream and releases any system resources associated with this stream. |
| public void | copy(InputStream
the stream to read from, until EOF is reached. in)Copy all bytes remaining on the input stream into this buffer. |
| public void | |
| protected void | |
| private long | |
| private TemporaryBuffer. | |
| public long | |
| public InputStream | Returns: a stream to read from the buffer. The caller must close the stream when it is no longer useful.Open an input stream to read from the buffered data. |
| public InputStream | Returns: an InputStream which will automatically destroy any associated temporary file onclose()Same as |
| protected abstract OutputStream | Returns: the output stream to receive the buffered content, followed by the remaining output.Open the overflow output stream, so the remaining output can be stored. |
| private boolean | |
| public void | |
| private void | |
| public byte[] | Returns: the complete byte array; length matcheslength().Convert this buffer's contents into a contiguous byte array. |
| public byte[] | Returns: the byte array limited tolimit bytes.the maximum number of bytes to be returned limit)Convert this buffer's contents into a contiguous byte array. |
| public String | Returns: firstlimit number of bytes of the buffer content
converted to String.the maximum number of bytes to be converted to String limit)Convert first |
| public void | write(int
the b)byte.Implements abstract java. Writes the specified byte to this output stream. |
| public void | write(byte[]
the data. b, int the start offset in the data. off, int the number of bytes to write. len)Overrides java. Writes |
| public void | writeTo(OutputStream
stream to send this buffer's complete content to. os, ProgressMonitor if not null progress updates are sent here. Caller should
initialize the task and the number of work units to pm)
.Send this buffer to an output stream. |
| blocks | back to summary |
|---|---|
| pack-priv ArrayList<TemporaryBuffer. Chain of data, if we are still completely in-core; otherwise null. | |
| DEFAULT_IN_CORE_LIMIT | back to summary |
|---|---|
| protected static final int DEFAULT_IN_CORE_LIMIT Default limit for in-core storage. | |
| inCoreLimit | back to summary |
|---|---|
| private int inCoreLimit Maximum number of bytes we will permit storing in memory. When this limit is reached the data will be shifted to a file on disk, preventing the JVM heap from growing out of control. | |
| initialBlocks | back to summary |
|---|---|
| private int initialBlocks Initial size of block list. | |
| overflow | back to summary |
|---|---|
| private OutputStream overflow If | |
| TemporaryBuffer | back to summary |
|---|---|
| protected TemporaryBuffer(int limit) Create a new empty temporary buffer.
| |
| TemporaryBuffer | back to summary |
|---|---|
| protected TemporaryBuffer(int estimatedSize, int limit) Create a new empty temporary buffer.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources
associated with this stream. The general contract of
| |
| copy | back to summary |
|---|---|
| public void copy(InputStream in) throws IOException Copy all bytes remaining on the input stream into this buffer.
| |
| destroy | back to summary |
|---|---|
| public void destroy() Clear this buffer so it has no data, and cannot be used again. | |
| doFlush | back to summary |
|---|---|
| protected void doFlush() throws IOException Dumps the entire buffer into the overflow stream, and flushes it.
| |
| inCoreLength | back to summary |
|---|---|
| private long inCoreLength() | |
| last | back to summary |
|---|---|
| private TemporaryBuffer. | |
| length | back to summary |
|---|---|
| public long length() Obtain the length (in bytes) of the buffer.
The length is only accurate after
| |
| openInputStream | back to summary |
|---|---|
| public InputStream openInputStream() throws IOException Open an input stream to read from the buffered data.
This method may only be invoked after
| |
| openInputStreamWithAutoDestroy | back to summary |
|---|---|
| public InputStream openInputStreamWithAutoDestroy() throws IOException Same as
| |
| overflow | back to summary |
|---|---|
| protected abstract OutputStream overflow() throws IOException Open the overflow output stream, so the remaining output can be stored.
| |
| reachedInCoreLimit | back to summary |
|---|---|
| private boolean reachedInCoreLimit() throws IOException | |
| reset | back to summary |
|---|---|
| public void reset() Reset this buffer for reuse, purging all buffered content. | |
| switchToOverflow | back to summary |
|---|---|
| private void switchToOverflow() throws IOException | |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray() throws IOException Convert this buffer's contents into a contiguous byte array.
The buffer is only complete after
| |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray(int limit) throws IOException Convert this buffer's contents into a contiguous byte array. If this size
of the buffer exceeds the limit only return the first
The buffer is only complete after
| |
| toString | back to summary |
|---|---|
| public String toString(int limit) Convert first
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Writes
If
If
| |
| writeTo | back to summary |
|---|---|
| public void writeTo(OutputStream os, ProgressMonitor pm) throws IOException Send this buffer to an output stream.
This method may only be invoked after
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final byte[] | |
| pack-priv int | |
| pack-priv static final int |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean |
| buffer | back to summary |
|---|---|
| pack-priv final byte[] buffer | |
| count | back to summary |
|---|---|
| pack-priv int count | |
| SZ | back to summary |
|---|---|
| pack-priv static final int SZ | |
| Block | back to summary |
|---|---|
| pack-priv Block() | |
| Block | back to summary |
|---|---|
| pack-priv Block(int sz) | |
| isFull | back to summary |
|---|---|
| pack-priv boolean isFull() | |
| Modifier and Type | Field and Description |
|---|---|
| private TemporaryBuffer. | |
| private int | |
| private int | |
| private byte[] |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private boolean | |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| public int | read(byte[]
the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. Reads up to |
| public long | skip(long
the number of bytes to be skipped. cnt)Overrides java. Skips over and discards |
| block | back to summary |
|---|---|
| private TemporaryBuffer. | |
| blockIndex | back to summary |
|---|---|
| private int blockIndex | |
| blockPos | back to summary |
|---|---|
| private int blockPos | |
| singleByteBuffer | back to summary |
|---|---|
| private byte[] singleByteBuffer | |
| BlockInputStream | back to summary |
|---|---|
| pack-priv BlockInputStream() | |
| nextBlock | back to summary |
|---|---|
| private boolean nextBlock() | |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| skip | back to summary |
|---|---|
| public long skip(long cnt) throws IOException Overrides java. Doc from java. Skips over and discards
| |
If the in-memory limit is reached an IOException is thrown, rather than attempting to spool to local disk.
| Access | Constructor and Description |
|---|---|
| public | Heap(int
maximum number of bytes that can be stored in this buffer;
also used as the estimated size. Storing beyond this many
will cause an IOException to be thrown during write. limit)Create a new heap buffer with a maximum storage limit. |
| public | Heap(int
estimated size of storage used, to size the initial list of
block pointers. estimatedSize, int maximum number of bytes that can be stored in this buffer.
Storing beyond this many will cause an IOException to be
thrown during write. limit)Create a new heap buffer with a maximum storage limit. |
| Modifier and Type | Method and Description |
|---|---|
| protected OutputStream | overflow()
Implements abstract org. Open the overflow output stream, so the remaining output can be stored. |
| Heap | back to summary |
|---|---|
| public Heap(int limit) Create a new heap buffer with a maximum storage limit.
| |
| Heap | back to summary |
|---|---|
| public Heap(int estimatedSize, int limit) Create a new heap buffer with a maximum storage limit.
| |
| overflow | back to summary |
|---|---|
| protected OutputStream overflow() throws IOException Implements abstract org. Doc from org. Open the overflow output stream, so the remaining output can be stored.
| |
Initially this output stream buffers to memory and is therefore similar to ByteArrayOutputStream, but it shifts to using an on disk temporary file if the output gets too large.
The content of this buffered stream may be sent to another OutputStream
only after this stream has been properly closed by close().
| Modifier and Type | Field and Description |
|---|---|
| private final File | directory
Directory to store the temporary file under. |
| private File | onDiskFile
Location of our temporary file if we are on disk; otherwise null. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | LocalFile(File
if the buffer has to spill over into a temporary file, the
directory where the file should be saved. If null the
system default temporary directory (for example /tmp) will
be used instead. directory, int maximum number of bytes to store in memory. Storage beyond
this limit will use the local file. inCoreLimit)Create a new temporary buffer, limiting memory usage. |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy()
Overrides org. Clear this buffer so it has no data, and cannot be used again. |
| public long | length()
Overrides org. Obtain the length (in bytes) of the buffer. |
| public InputStream | openInputStream()
Overrides org. Open an input stream to read from the buffered data. |
| public InputStream | openInputStreamWithAutoDestroy()
Overrides org. Same as |
| protected OutputStream | overflow()
Implements abstract org. Open the overflow output stream, so the remaining output can be stored. |
| public byte[] | toByteArray()
Overrides org. Convert this buffer's contents into a contiguous byte array. |
| public byte[] | toByteArray(int
the maximum number of bytes to be returned limit)Overrides org. Convert this buffer's contents into a contiguous byte array. |
| public void | writeTo(OutputStream
stream to send this buffer's complete content to. os, ProgressMonitor if not null progress updates are sent here. Caller should
initialize the task and the number of work units to pm)
.Overrides org. Send this buffer to an output stream. |
| directory | back to summary |
|---|---|
| private final File directory Directory to store the temporary file under. | |
| onDiskFile | back to summary |
|---|---|
| private File onDiskFile Location of our temporary file if we are on disk; otherwise null.
If we exceeded the | |
| LocalFile | back to summary |
|---|---|
| public LocalFile(File directory) Create a new temporary buffer, limiting memory usage.
| |
| LocalFile | back to summary |
|---|---|
| public LocalFile(File directory, int inCoreLimit) Create a new temporary buffer, limiting memory usage.
| |
| destroy | back to summary |
|---|---|
| public void destroy() Overrides org. Doc from org. Clear this buffer so it has no data, and cannot be used again.
| |
| length | back to summary |
|---|---|
| public long length() Overrides org. Doc from org. Obtain the length (in bytes) of the buffer.
The length is only accurate after
| |
| openInputStream | back to summary |
|---|---|
| public InputStream openInputStream() throws IOException Overrides org. Doc from org. Open an input stream to read from the buffered data.
This method may only be invoked after
| |
| openInputStreamWithAutoDestroy | back to summary |
|---|---|
| public InputStream openInputStreamWithAutoDestroy() throws IOException Overrides org. Doc from org. Same as
| |
| overflow | back to summary |
|---|---|
| protected OutputStream overflow() throws IOException Implements abstract org. Doc from org. Open the overflow output stream, so the remaining output can be stored.
| |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray() throws IOException Overrides org. Doc from org. Convert this buffer's contents into a contiguous byte array.
The buffer is only complete after
| |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray(int limit) throws IOException Overrides org. Doc from org. Convert this buffer's contents into a contiguous byte array. If this size
of the buffer exceeds the limit only return the first
The buffer is only complete after
| |
| writeTo | back to summary |
|---|---|
| public void writeTo(OutputStream os, ProgressMonitor pm) throws IOException Overrides org. Doc from org. Send this buffer to an output stream.
This method may only be invoked after
| |