public class ChunkedOutput extends BufferedOutput
BufferedOutput using ChunkList as an output.
Written chunks can be retrieved with getOutput method.
Subclasses of this implementation can override flush method to
write composed chunks to an underlying persistence mechanism as soon as they are complete.| Modifier and Type | Field and Description |
|---|---|
protected static int |
MAX_COPY_BYTES
Maximal number of bytes to copy when making a decision to merge two chunks together
in
writeFromChunk(Chunk, Object) method. |
buffer, EMPTY_BYTE_ARRAY, limit, position, totalPositionBase| Constructor and Description |
|---|
ChunkedOutput()
Constructs new chunked output with
default pool. |
ChunkedOutput(ChunkPool pool)
Constructs new chunked output with a specified pool.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears this chunked output and recycles all contained chunks.
|
void |
close()
This implementation does
flush(). |
long |
discard(long n)
Discards n last bytes of output.
|
void |
flush() |
ChunkList |
getOutput(Object owner)
Retrieves generated output chunks for specified owner.
|
protected void |
needSpace()
This method is invoked when output methods need more space to write data.
|
String |
toString()
Returns a string representation of the object.
|
void |
writeAllFromChunkList(ChunkList chunks,
Object owner)
Writes all data from specified chunk list into this buffered output.
|
void |
writeFromChunk(Chunk chunk,
Object owner)
Writes data from specified chunk into this buffered output.
|
checkEOB, totalPosition, write, write, write, writeBoolean, writeByte, writeByteArray, writeBytes, writeChar, writeChars, writeCompactInt, writeCompactLong, writeDouble, writeFloat, writeFromByteBuffer, writeFromDataInput, writeFromInputStream, writeInt, writeLong, writeMarshalled, writeObject, writeProperties, writeShort, writeUTF, writeUTFChar, writeUTFStringprotected static final int MAX_COPY_BYTES
writeFromChunk(Chunk, Object) method.public ChunkedOutput()
default pool.public ChunkedOutput(ChunkPool pool)
pool - chunk pool to use for acquiring new chunkspublic void clear()
totalPosition is reset to 0.public ChunkList getOutput(Object owner)
totalPosition.owner - new owner for generated chunk listnull if there is no output yetpublic void close()
throws IOException
flush().close in interface Closeableclose in interface ObjectOutputclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void flush()
throws IOException
Subclasses shall override flush, call getOutput
from inside it to obtain completed chunks, and write them to an underlying persistence mechanism.
This implementation does nothing.
flush in interface Flushableflush in interface ObjectOutputflush in class OutputStreamIOExceptionpublic long discard(long n)
n - the number of bytes to be discardedpublic void writeFromChunk(Chunk chunk, Object owner) throws IOException
read-only.
A reference to the chunk is considered to become invalid after
invocation of this method and may no longer be used, unless the chunk was read-only.writeFromChunk in class BufferedOutputchunk - the source chunk of bytesowner - current owner of the chunkIOException - if an I/O error occurspublic void writeAllFromChunkList(ChunkList chunks, Object owner) throws IOException
read-only.
A reference to the chunk list is considered to become invalid after
invocation of this method and may no longer be used, unless the chunk list was read-only.writeAllFromChunkList in class BufferedOutputchunks - the source chunk listowner - current owner of the chunk listIOException - if an I/O error occursprotected void needSpace()
throws IOException
BufferedOutput(position < limit)
is true or throw an exception. This method may block if needed.
This method is allowed to update BufferedOutput.buffer, BufferedOutput.position and
BufferedOutput.limit fields as needed and should maintain BufferedOutput.totalPositionBase accordingly.needSpace in class BufferedOutputIOException - if an I/O error occursCopyright © 2002–2025 Devexperts LLC. All rights reserved.