Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

com::sleepycat::bind::tuple::TupleOutput Class Reference

Inheritance diagram for com::sleepycat::bind::tuple::TupleOutput:

com::sleepycat::util::FastOutputStream

Public Member Functions

 TupleOutput ()
 TupleOutput (byte[] buffer)
final TupleOutput writeBytes (String val)
final TupleOutput writeChars (String val)
final TupleOutput writeString (String val)
final TupleOutput writeChar (int val)
final TupleOutput writeBoolean (boolean val)
final TupleOutput writeByte (int val)
final TupleOutput writeShort (int val)
final TupleOutput writeInt (int val)
final TupleOutput writeLong (long val)
final TupleOutput writeFloat (float val)
final TupleOutput writeDouble (double val)
final TupleOutput writeBytes (char[] chars)
final TupleOutput writeChars (char[] chars)
final TupleOutput writeString (char[] chars)
final TupleOutput writeUnsignedByte (int val)
final TupleOutput writeUnsignedShort (int val)
final TupleOutput writeUnsignedInt (long val)

Static Package Attributes

static final int NULL_STRING_UTF_VALUE = ((byte) 0xFF)

Detailed Description

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 java.io.DataOutput interface. The reason this class does not implement java.io.DataOutput is because it would break the interface contract for those methods because of data format differences.

Signed numbers are stored in the buffer in MSB (most significant byte first) order with their sign bit (high-order bit) inverted to cause negative numbers to be sorted first when comparing values as unsigned byte arrays, as done in a database. Unsigned numbers, including characters, are stored in MSB order with no change to their sign bit.

Strings and character arrays are stored either as a fixed length array of unicode characters, where the length must be known by the application, or as a null-terminated UTF byte array.

Floats and doubles are stored in standard Java integer-bit representation (IEEE 754). Non-negative numbers are correctly ordered by numeric value. However, negative numbers are not correctly ordered; therefore, if you use negative floating point numbers in a key, you'll need to implement and configure a custom comparator to get correct numeric ordering.

Author:
Mark Hayes

Definition at line 56 of file TupleOutput.java.


Constructor & Destructor Documentation

com::sleepycat::bind::tuple::TupleOutput::TupleOutput  )  [inline]
 

Creates a tuple output object for writing a byte array of tuple data.

Definition at line 67 of file TupleOutput.java.

com::sleepycat::bind::tuple::TupleOutput::TupleOutput byte[]  buffer  )  [inline]
 

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.

Definition at line 81 of file TupleOutput.java.


Member Function Documentation

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeBoolean boolean  val  )  [inline]
 

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 using TupleInput#readBoolean.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 170 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

Referenced by com::sleepycat::bind::tuple::BooleanBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeByte int  val  )  [inline]
 

Writes an signed byte (one byte) value to the buffer. Writes values that can be read using TupleInput#readByte.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 184 of file TupleOutput.java.

References writeUnsignedByte().

Referenced by com::sleepycat::bind::tuple::ByteBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeBytes char[]  chars  )  [inline]
 

Writes the specified bytes to the buffer, converting each character to an unsigned byte value. Writes values that can be read using TupleInput#readBytes. Only characters with values below 0x100 may be written using this method, since the high-order 8 bits of all characters are discarded.

Parameters:
chars is the array of values to be written.
Returns:
this tuple output object.
Exceptions:
NullPointerException if the chars parameter is null.

Definition at line 279 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeBytes String  val  )  [inline]
 

Writes the specified bytes to the buffer, converting each character to an unsigned byte value. Writes values that can be read using TupleInput#readBytes. Only characters with values below 0x100 may be written using this method, since the high-order 8 bits of all characters are discarded.

Parameters:
val is the string containing the values to be written.
Returns:
this tuple output object.
Exceptions:
NullPointerException if the val parameter is null.

Definition at line 101 of file TupleOutput.java.

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeChar int  val  )  [inline]
 

Writes a char (two byte) unsigned value to the buffer. Writes values that can be read using TupleInput#readChar.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 154 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

Referenced by com::sleepycat::bind::tuple::CharacterBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeChars char[]  chars  )  [inline]
 

Writes the specified characters to the buffer, converting each character to a two byte unsigned value. Writes values that can be read using TupleInput#readChars.

Parameters:
chars is the array of characters to be written.
Returns:
this tuple output object.
Exceptions:
NullPointerException if the chars parameter is null.

Definition at line 298 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeChars String  val  )  [inline]
 

Writes the specified characters to the buffer, converting each character to a two byte unsigned value. Writes values that can be read using TupleInput#readChars.

Parameters:
val is the string containing the characters to be written.
Returns:
this tuple output object.
Exceptions:
NullPointerException if the val parameter is null.

Definition at line 118 of file TupleOutput.java.

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeDouble double  val  )  [inline]
 

Writes an signed double (eight byte) value to the buffer. Writes values that can be read using TupleInput#readDouble. Double.doubleToLongBits is used to convert the signed double value.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 258 of file TupleOutput.java.

Referenced by com::sleepycat::bind::tuple::DoubleBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeFloat float  val  )  [inline]
 

Writes an signed float (four byte) value to the buffer. Writes values that can be read using TupleInput#readFloat. Float.floatToIntBits is used to convert the signed float value.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 242 of file TupleOutput.java.

References writeUnsignedInt().

Referenced by com::sleepycat::bind::tuple::FloatBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeInt int  val  )  [inline]
 

Writes an signed int (four byte) value to the buffer. Writes values that can be read using TupleInput#readInt.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 212 of file TupleOutput.java.

References writeUnsignedInt().

Referenced by com::sleepycat::bind::tuple::IntegerBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeLong long  val  )  [inline]
 

Writes an signed long (eight byte) value to the buffer. Writes values that can be read using TupleInput#readLong.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 226 of file TupleOutput.java.

Referenced by com::sleepycat::bind::tuple::LongBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeShort int  val  )  [inline]
 

Writes an signed short (two byte) value to the buffer. Writes values that can be read using TupleInput#readShort.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 198 of file TupleOutput.java.

References writeUnsignedShort().

Referenced by com::sleepycat::bind::tuple::ShortBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeString char[]  chars  )  [inline]
 

Writes the specified characters to the buffer, converting each character to UTF format. Note that zero (0x0000) character values are encoded as non-zero values. Writes values that can be read using TupleInput#readString(int) or TupleInput#readString(char[]).

Parameters:
chars is the array of characters to be written.
Returns:
this tuple output object.
Exceptions:
NullPointerException if the chars parameter is null.

Definition at line 320 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::addSize(), com::sleepycat::util::FastOutputStream::getBufferBytes(), com::sleepycat::util::FastOutputStream::getBufferLength(), and com::sleepycat::util::FastOutputStream::makeSpace().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeString String  val  )  [inline]
 

Writes the specified characters to the buffer, converting each character to UTF format, and adding a null terminator byte. Note that zero (0x0000) character values are encoded as non-zero values and a null String parameter is encoded as 0xFF. Writes values that can be read using TupleInput#readString().

Parameters:
val is the string containing the characters to be written.
Returns:
this tuple output object.

Definition at line 135 of file TupleOutput.java.

References NULL_STRING_UTF_VALUE, and com::sleepycat::util::FastOutputStream::writeFast().

Referenced by com::sleepycat::bind::tuple::test::MarshalledObject::marshalEntry(), collections::ship::factory::SupplierKey::marshalEntry(), collections::ship::factory::ShipmentKey::marshalEntry(), collections::ship::factory::PartKey::marshalEntry(), collections::ship::marshal::SupplierKey::marshalKey(), collections::ship::marshal::ShipmentKey::marshalKey(), collections::ship::marshal::PartKey::marshalKey(), com::sleepycat::bind::tuple::test::MarshalledObject::marshalPrimaryKey(), com::sleepycat::bind::serial::test::MarshalledObject::marshalPrimaryKey(), collections::ship::marshal::Supplier::marshalPrimaryKey(), collections::ship::factory::Supplier::marshalPrimaryKey(), collections::ship::marshal::Shipment::marshalPrimaryKey(), collections::ship::factory::Shipment::marshalPrimaryKey(), collections::ship::marshal::Part::marshalPrimaryKey(), collections::ship::factory::Part::marshalPrimaryKey(), com::sleepycat::bind::tuple::test::MarshalledObject::marshalSecondaryKey(), com::sleepycat::bind::serial::test::MarshalledObject::marshalSecondaryKey(), collections::ship::marshal::Supplier::marshalSecondaryKey(), collections::ship::factory::Supplier::marshalSecondaryKey(), collections::ship::marshal::Shipment::marshalSecondaryKey(), collections::ship::factory::Shipment::marshalSecondaryKey(), and com::sleepycat::bind::tuple::StringBinding::objectToEntry().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeUnsignedByte int  val  )  [inline]
 

Writes an unsigned byte (one byte) value to the buffer. Writes values that can be read using TupleInput#readUnsignedByte.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 342 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

Referenced by writeByte().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeUnsignedInt long  val  )  [inline]
 

Writes an unsigned int (four byte) value to the buffer. Writes values that can be read using TupleInput#readUnsignedInt.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 373 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

Referenced by writeFloat(), and writeInt().

final TupleOutput com::sleepycat::bind::tuple::TupleOutput::writeUnsignedShort int  val  )  [inline]
 

Writes an unsigned short (two byte) value to the buffer. Writes values that can be read using TupleInput#readUnsignedShort.

Parameters:
val is the value to write to the buffer.
Returns:
this tuple output object.

Definition at line 357 of file TupleOutput.java.

References com::sleepycat::util::FastOutputStream::writeFast().

Referenced by writeShort().


Field Documentation

final int com::sleepycat::bind::tuple::TupleOutput::NULL_STRING_UTF_VALUE = ((byte) 0xFF) [static, package]
 

We represent a null string as a single FF UTF character, which cannot occur in a UTF encoded string.

Definition at line 62 of file TupleOutput.java.

Referenced by writeString().


The documentation for this class was generated from the following file:
Generated on Sun Dec 25 12:15:00 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2