Class ByteArrayWriteBuffer.ByteArrayBufferOutput
- java.lang.Object
-
- java.io.OutputStream
-
- com.tangosol.io.AbstractWriteBuffer.AbstractBufferOutput
-
- com.tangosol.io.ByteArrayWriteBuffer.ByteArrayBufferOutput
-
- All Implemented Interfaces:
com.oracle.coherence.common.io.OutputStreaming,OutputStreaming,WriteBuffer.BufferOutput,Closeable,DataOutput,Flushable,AutoCloseable
- Enclosing class:
- ByteArrayWriteBuffer
public final class ByteArrayWriteBuffer.ByteArrayBufferOutput extends AbstractWriteBuffer.AbstractBufferOutput
ByteArrayBufferOutput is an implementation of BufferOutput optimized for writing to the buffer's underlying byte array.- Author:
- cp 2005.03.25
-
-
Field Summary
-
Fields inherited from class com.tangosol.io.AbstractWriteBuffer.AbstractBufferOutput
m_ofWrite
-
Fields inherited from interface com.tangosol.io.WriteBuffer.BufferOutput
MAX_PACKED_INT_SIZE, MAX_PACKED_LONG_SIZE
-
-
Constructor Summary
Constructors Constructor Description ByteArrayBufferOutput()Construct an ByteArrayBufferOutput that will begin writing at the start of the containing WriteBuffer.ByteArrayBufferOutput(int of)Construct an ByteArrayBufferOutput that will begin writing at the specified offset within the containing WriteBuffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidmoveOffset(int cb)Move the offset within the stream forward.voidwriteBytes(String s)Writes the String s, but only the low-order byte from each character of the String is written.voidwriteChars(String s)Writes the String s as a sequence of characters.voidwriteInt(int n)Writes an int value.voidwriteLong(long l)Writes a long value.voidwritePackedInt(int n)Write an int value using a variable-length storage-format.voidwritePackedLong(long l)Write a long value using a variable-length storage-format.voidwriteSafeUTF(String s)Write a variable-length encoded UTF packed String.voidwriteShort(int n)Writes a short value, comprised of the 16 low-order bits of the argument n; the 16 high-order bits of n are ignored.voidwriteUTF(String s)Writes the String s as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the correspondingDataInput.readUTF()method can reconstitute a String from the written data.-
Methods inherited from class com.tangosol.io.AbstractWriteBuffer.AbstractBufferOutput
calcUTF, close, flush, formatUTF, formatUTF, getBuffer, getCharBuf, getOffset, setOffset, write, write, write, writeBoolean, writeBuffer, writeBuffer, writeByte, writeChar, writeDouble, writeFloat, writeStream, writeStream, writeUTF
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
ByteArrayBufferOutput
public ByteArrayBufferOutput()
Construct an ByteArrayBufferOutput that will begin writing at the start of the containing WriteBuffer.
-
ByteArrayBufferOutput
public ByteArrayBufferOutput(int of)
Construct an ByteArrayBufferOutput that will begin writing at the specified offset within the containing WriteBuffer.- Parameters:
of- the offset at which to begin writing
-
-
Method Detail
-
writeShort
public void writeShort(int n) throws IOExceptionWrites a short value, comprised of the 16 low-order bits of the argument n; the 16 high-order bits of n are ignored.- Specified by:
writeShortin interfaceDataOutput- Specified by:
writeShortin interfaceWriteBuffer.BufferOutput- Overrides:
writeShortin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
n- the short to write (passed as an integer)- Throws:
IOException- if an I/O error occurs
-
writeInt
public void writeInt(int n) throws IOExceptionWrites an int value.- Specified by:
writeIntin interfaceDataOutput- Specified by:
writeIntin interfaceWriteBuffer.BufferOutput- Overrides:
writeIntin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
n- the int to write- Throws:
IOException- if an I/O error occurs
-
writeLong
public void writeLong(long l) throws IOExceptionWrites a long value.- Specified by:
writeLongin interfaceDataOutput- Specified by:
writeLongin interfaceWriteBuffer.BufferOutput- Overrides:
writeLongin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
l- the long to write- Throws:
IOException- if an I/O error occurs
-
writeBytes
public void writeBytes(String s) throws IOException
Writes the String s, but only the low-order byte from each character of the String is written.- Specified by:
writeBytesin interfaceDataOutput- Specified by:
writeBytesin interfaceWriteBuffer.BufferOutput- Overrides:
writeBytesin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
s- the String to write- Throws:
IOException- if an I/O error occurs
-
writeChars
public void writeChars(String s) throws IOException
Writes the String s as a sequence of characters.- Specified by:
writeCharsin interfaceDataOutput- Specified by:
writeCharsin interfaceWriteBuffer.BufferOutput- Overrides:
writeCharsin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
s- the String to write- Throws:
IOException- if an I/O error occurs
-
writeUTF
public void writeUTF(String s) throws IOException
Writes the String s as a sequence of characters, but using UTF-8 encoding for the characters, and including the String length data so that the correspondingDataInput.readUTF()method can reconstitute a String from the written data.- Specified by:
writeUTFin interfaceDataOutput- Specified by:
writeUTFin interfaceWriteBuffer.BufferOutput- Overrides:
writeUTFin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
s- the String to write- Throws:
IOException- if an I/O error occurs
-
writeSafeUTF
public void writeSafeUTF(String s) throws IOException
Write a variable-length encoded UTF packed String. The major differences between this implementation and DataOutput is that this implementation supports null values and is not limited to 64KB UTF-encoded values.The binary format for a Safe UTF value is a "packed int" for the binary length followed by the UTF-encoded byte stream. The length is either -1 (indicating a null String) or in the range 0 .. Integer.MAX_VALUE (inclusive). The UTF-encoded portion uses a format identical to DataOutput.
- Specified by:
writeSafeUTFin interfaceWriteBuffer.BufferOutput- Overrides:
writeSafeUTFin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
s- a String value to write; may be null- Throws:
IOException- if an I/O error occurs
-
writePackedInt
public void writePackedInt(int n) throws IOExceptionWrite an int value using a variable-length storage-format.The format differs from DataOutput in that DataOutput always uses a fixed-length 4-byte Big Endian binary format for int values. The "packed" format includes a sign bit (0x40) and a continuation bit (0x80) in the first byte, followed by the least 6 significant bits of the int value. Subsequent bytes (each appearing only if the previous byte had its continuation bit set) include a continuation bit (0x80) and the next least 7 significant bits of the int value. In this way, a 32-bit value is encoded into 1-5 bytes, depending on the magnitude of the int value being encoded.
- Specified by:
writePackedIntin interfaceWriteBuffer.BufferOutput- Overrides:
writePackedIntin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
n- an int value to write- Throws:
IOException- if an I/O error occurs
-
writePackedLong
public void writePackedLong(long l) throws IOExceptionWrite a long value using a variable-length storage-format.The format differs from DataOutput in that DataOutput always uses a fixed-length 8-byte Big Endian binary format for long values. The "packed" format includes a sign bit (0x40) and a continuation bit (0x80) in the first byte, followed by the least 6 significant bits of the long value. Subsequent bytes (each appearing only if the previous byte had its continuation bit set) include a continuation bit (0x80) and the next least 7 significant bits of the long value. In this way, a 64-bit value is encoded into 1-10 bytes, depending on the magnitude of the long value being encoded.
- Specified by:
writePackedLongin interfaceWriteBuffer.BufferOutput- Overrides:
writePackedLongin classAbstractWriteBuffer.AbstractBufferOutput- Parameters:
l- a long value to write- Throws:
IOException- if an I/O error occurs
-
moveOffset
protected void moveOffset(int cb)
Move the offset within the stream forward.- Parameters:
cb- the number of bytes to advance the offset
-
-