Package com.sleepycat.bind.tuple
Class TupleOutput
java.lang.Object
java.io.OutputStream
com.sleepycat.util.FastOutputStream
com.sleepycat.bind.tuple.TupleOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An
OutputStream with DataOutput-like methods for
writing tuple fields. It is used by TupleBinding.
This class has many methods that have the same signatures as methods in
the DataOutput interface. The reason this class does not
implement DataOutput is because it would break the interface
contract for those methods because of data format differences.
- See Also:
-
Field Summary
Fields inherited from class com.sleepycat.util.FastOutputStream
DEFAULT_BUMP_SIZE, DEFAULT_INIT_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a tuple output object for writing a byte array of tuple data.TupleOutput(byte[] buffer) Creates a tuple output object for writing a byte array of tuple data, using a given buffer. -
Method Summary
Modifier and TypeMethodDescriptionstatic intReturns the maximum byte length that would be output for a givenBigDecimalvalue ifwriteBigDecimal(java.math.BigDecimal)were called.static intReturns the exact byte length that would would be output for a givenBigIntegervalue ifwriteBigInteger(java.math.BigInteger)were called.static intReturns the maximum byte length that would be output for a givenBigDecimalvalue ifwriteSortedBigDecimal(java.math.BigDecimal)were called.final TupleOutputWrites an unsortedBigDecimal.final TupleOutputWrites aBigInteger.final TupleOutputwriteBoolean(boolean val) Writes a boolean (one byte) unsigned value to the buffer, writing one if the value is true and zero if it is false.final TupleOutputwriteByte(int val) Writes an signed byte (one byte) value to the buffer.final TupleOutputwriteBytes(char[] chars) Writes the specified bytes to the buffer, converting each character to an unsigned byte value.final TupleOutputwriteBytes(String val) Writes the specified bytes to the buffer, converting each character to an unsigned byte value.final TupleOutputwriteChar(int val) Writes a char (two byte) unsigned value to the buffer.final TupleOutputwriteChars(char[] chars) Writes the specified characters to the buffer, converting each character to a two byte unsigned value.final TupleOutputwriteChars(String val) Writes the specified characters to the buffer, converting each character to a two byte unsigned value.final TupleOutputwriteDouble(double val) Writes an unsorted double (eight byte) value to the buffer.final TupleOutputwriteFloat(float val) Writes an unsorted float (four byte) value to the buffer.final TupleOutputwriteInt(int val) Writes an signed int (four byte) value to the buffer.final TupleOutputwriteLong(long val) Writes an signed long (eight byte) value to the buffer.final TupleOutputwritePackedInt(int val) Writes an unsorted packed integer.final TupleOutputwritePackedLong(long val) Writes an unsorted packed long integer.final TupleOutputwriteShort(int val) Writes an signed short (two byte) value to the buffer.final TupleOutputWrites a sortedBigDecimal.final TupleOutputwriteSortedDouble(double val) Writes a sorted double (eight byte) value to the buffer.final TupleOutputwriteSortedFloat(float val) Writes a sorted float (four byte) value to the buffer.final TupleOutputwriteSortedPackedInt(int val) Writes a sorted packed integer.final TupleOutputwriteSortedPackedLong(long val) Writes a sorted packed long integer.final TupleOutputwriteString(char[] chars) Writes the specified characters to the buffer, converting each character to UTF format.final TupleOutputwriteString(String val) Writes the specified characters to the buffer, converting each character to UTF format, and adding a null terminator byte.final TupleOutputwriteUnsignedByte(int val) Writes an unsigned byte (one byte) value to the buffer.final TupleOutputwriteUnsignedInt(long val) Writes an unsigned int (four byte) value to the buffer.final TupleOutputwriteUnsignedShort(int val) Writes an unsigned short (two byte) value to the buffer.Methods inherited from class com.sleepycat.util.FastOutputStream
addSize, getBufferBytes, getBufferLength, getBufferOffset, makeSpace, reset, size, toByteArray, toString, toString, write, write, write, writeFast, writeFast, writeFast, writeToMethods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Constructor Details
-
TupleOutput
public TupleOutput()Creates a tuple output object for writing a byte array of tuple data. -
TupleOutput
public TupleOutput(byte[] buffer) Creates a tuple output object for writing a byte array of tuple data, using a given buffer. A new buffer will be allocated only if the number of bytes needed is greater than the length of this buffer. A reference to the byte array will be kept by this object and therefore the byte array should not be modified while this object is in use.- Parameters:
buffer- is the byte array to use as the buffer.
-
-
Method Details
-
writeBytes
Writes the specified bytes to the buffer, converting each character to an unsigned byte value. Writes values that can be read usingTupleInput.readBytes(int).- Parameters:
val- is the string containing the values to be written. Only characters with values below 0x100 may be written using this method, since the high-order 8 bits of all characters are discarded.- Returns:
- this tuple output object.
- Throws:
NullPointerException- if the val parameter is null.- See Also:
-
writeChars
Writes the specified characters to the buffer, converting each character to a two byte unsigned value. Writes values that can be read usingTupleInput.readChars(int).- Parameters:
val- is the string containing the characters to be written.- Returns:
- this tuple output object.
- Throws:
NullPointerException- if the val parameter is null.- See Also:
-
writeString
Writes the specified characters to the buffer, converting each character to UTF format, and adding a null terminator byte. Writes values that can be read usingTupleInput.readString().- Parameters:
val- is the string containing the characters to be written.- Returns:
- this tuple output object.
- See Also:
-
writeChar
Writes a char (two byte) unsigned value to the buffer. Writes values that can be read usingTupleInput.readChar().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeBoolean
Writes a boolean (one byte) unsigned value to the buffer, writing one if the value is true and zero if it is false. Writes values that can be read usingTupleInput.readBoolean().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeByte
Writes an signed byte (one byte) value to the buffer. Writes values that can be read usingTupleInput.readByte().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeShort
Writes an signed short (two byte) value to the buffer. Writes values that can be read usingTupleInput.readShort().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeInt
Writes an signed int (four byte) value to the buffer. Writes values that can be read usingTupleInput.readInt().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeLong
Writes an signed long (eight byte) value to the buffer. Writes values that can be read usingTupleInput.readLong().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeFloat
Writes an unsorted float (four byte) value to the buffer. Writes values that can be read usingTupleInput.readFloat().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeDouble
Writes an unsorted double (eight byte) value to the buffer. Writes values that can be read usingTupleInput.readDouble().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeSortedFloat
Writes a sorted float (four byte) value to the buffer. Writes values that can be read usingTupleInput.readSortedFloat().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeSortedDouble
Writes a sorted double (eight byte) value to the buffer. Writes values that can be read usingTupleInput.readSortedDouble().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeBytes
Writes the specified bytes to the buffer, converting each character to an unsigned byte value. Writes values that can be read usingTupleInput.readBytes(int).- Parameters:
chars- is the array of values to be written. Only characters with values below 0x100 may be written using this method, since the high-order 8 bits of all characters are discarded.- Returns:
- this tuple output object.
- Throws:
NullPointerException- if the chars parameter is null.- See Also:
-
writeChars
Writes the specified characters to the buffer, converting each character to a two byte unsigned value. Writes values that can be read usingTupleInput.readChars(int).- Parameters:
chars- is the array of characters to be written.- Returns:
- this tuple output object.
- Throws:
NullPointerException- if the chars parameter is null.- See Also:
-
writeString
Writes the specified characters to the buffer, converting each character to UTF format. Writes values that can be read usingTupleInput.readString(int)orTupleInput.readString(char[]).- Parameters:
chars- is the array of characters to be written.- Returns:
- this tuple output object.
- Throws:
NullPointerException- if the chars parameter is null.- See Also:
-
writeUnsignedByte
Writes an unsigned byte (one byte) value to the buffer. Writes values that can be read usingTupleInput.readUnsignedByte().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeUnsignedShort
Writes an unsigned short (two byte) value to the buffer. Writes values that can be read usingTupleInput.readUnsignedShort().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writeUnsignedInt
Writes an unsigned int (four byte) value to the buffer. Writes values that can be read usingTupleInput.readUnsignedInt().- Parameters:
val- is the value to write to the buffer.- Returns:
- this tuple output object.
- See Also:
-
writePackedInt
Writes an unsorted packed integer.- See Also:
-
writePackedLong
Writes an unsorted packed long integer.- See Also:
-
writeSortedPackedInt
Writes a sorted packed integer.- See Also:
-
writeSortedPackedLong
Writes a sorted packed long integer.- See Also:
-
writeBigInteger
Writes aBigInteger.- Throws:
NullPointerException- if val is null.IllegalArgumentException- if the byte array representation of val is larger than 0x7fff bytes.- See Also:
-
getBigIntegerByteLength
Returns the exact byte length that would would be output for a givenBigIntegervalue ifwriteBigInteger(java.math.BigInteger)were called.- See Also:
-
writeBigDecimal
Writes an unsortedBigDecimal.- Throws:
NullPointerException- if val is null.- See Also:
-
getBigDecimalMaxByteLength
Returns the maximum byte length that would be output for a givenBigDecimalvalue ifwriteBigDecimal(java.math.BigDecimal)were called.- See Also:
-
writeSortedBigDecimal
Writes a sortedBigDecimal.- See Also:
-
getSortedBigDecimalMaxByteLength
Returns the maximum byte length that would be output for a givenBigDecimalvalue ifwriteSortedBigDecimal(java.math.BigDecimal)were called.- See Also:
-