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

com::sleepycat::bind::tuple::TupleInput Class Reference

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

com::sleepycat::util::FastInputStream

Public Member Functions

 TupleInput (byte[] buffer)
 TupleInput (byte[] buffer, int offset, int length)
 TupleInput (TupleOutput output)
final String readString () throws IndexOutOfBoundsException, IllegalArgumentException
final char readChar () throws IndexOutOfBoundsException
final boolean readBoolean () throws IndexOutOfBoundsException
final byte readByte () throws IndexOutOfBoundsException
final short readShort () throws IndexOutOfBoundsException
final int readInt () throws IndexOutOfBoundsException
final long readLong () throws IndexOutOfBoundsException
final float readFloat () throws IndexOutOfBoundsException
final double readDouble () throws IndexOutOfBoundsException
final int readUnsignedByte () throws IndexOutOfBoundsException
final int readUnsignedShort () throws IndexOutOfBoundsException
final long readUnsignedInt () throws IndexOutOfBoundsException
final String readBytes (int length) throws IndexOutOfBoundsException
final String readChars (int length) throws IndexOutOfBoundsException
final void readBytes (char[] chars) throws IndexOutOfBoundsException
final void readChars (char[] chars) throws IndexOutOfBoundsException
final String readString (int length) throws IndexOutOfBoundsException, IllegalArgumentException
final void readString (char[] chars) throws IndexOutOfBoundsException, IllegalArgumentException

Detailed Description

An InputStream with DataInput-like methods for reading tuple fields. It is used by TupleBinding.

This class has many methods that have the same signatures as methods in the java.io.DataInput interface. The reason this class does not implement java.io.DataInput 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 TupleInput.java.


Constructor & Destructor Documentation

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

Creates a tuple input object for reading a byte array of tuple data. A reference to the byte array will be kept by this object (it will not be copied) and therefore the byte array should not be modified while this object is in use.

Parameters:
buffer is the byte array to be read and should contain data in tuple format.

Definition at line 67 of file TupleInput.java.

com::sleepycat::bind::tuple::TupleInput::TupleInput byte[]  buffer,
int  offset,
int  length
[inline]
 

Creates a tuple input object for reading a byte array of tuple data at a given offset for a given length. A reference to the byte array will be kept by this object (it will not be copied) and therefore the byte array should not be modified while this object is in use.

Parameters:
buffer is the byte array to be read and should contain data in tuple format.
offset is the byte offset at which to begin reading.
length is the number of bytes to be read.

Definition at line 85 of file TupleInput.java.

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

Creates a tuple input object from the data contained in a tuple output object. A reference to the tuple output's byte array will be kept by this object (it will not be copied) and therefore the tuple output object should not be modified while this object is in use.

Parameters:
output is the tuple output object containing the data to be read.

Definition at line 98 of file TupleInput.java.

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


Member Function Documentation

final boolean com::sleepycat::bind::tuple::TupleInput::readBoolean  )  throws IndexOutOfBoundsException [inline]
 

Reads a boolean (one byte) unsigned value from the buffer and returns true if it is non-zero and false if it is zero. Reads values that were written using TupleOutput#writeBoolean.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 160 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

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

final byte com::sleepycat::bind::tuple::TupleInput::readByte  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed byte (one byte) value from the buffer. Reads values that were written using TupleOutput#writeByte.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 178 of file TupleInput.java.

References readUnsignedByte().

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

final void com::sleepycat::bind::tuple::TupleInput::readBytes char[]  chars  )  throws IndexOutOfBoundsException [inline]
 

Reads the specified number of bytes from the buffer, converting each unsigned byte value to a character of the resulting array. Reads values that were written using TupleOutput#writeBytes. Only characters with values below 0x100 may be read using this method.

Parameters:
chars is the array to receive the data and whose length is used to determine the number of bytes to be read.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 402 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

final String com::sleepycat::bind::tuple::TupleInput::readBytes int  length  )  throws IndexOutOfBoundsException [inline]
 

Reads the specified number of bytes from the buffer, converting each unsigned byte value to a character of the resulting string. Reads values that were written using TupleOutput#writeBytes. Only characters with values below 0x100 may be read using this method.

Parameters:
length is the number of bytes to be read.
Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 354 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

final char com::sleepycat::bind::tuple::TupleInput::readChar  )  throws IndexOutOfBoundsException [inline]
 

Reads a char (two byte) unsigned value from the buffer. Reads values that were written using TupleOutput#writeChar.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 145 of file TupleInput.java.

References readUnsignedShort().

Referenced by com::sleepycat::bind::tuple::CharacterBinding::entryToObject(), and readChars().

final void com::sleepycat::bind::tuple::TupleInput::readChars char[]  chars  )  throws IndexOutOfBoundsException [inline]
 

Reads the specified number of characters from the buffer, converting each two byte unsigned value to a character of the resulting array. Reads values that were written using TupleOutput#writeChars.

Parameters:
chars is the array to receive the data and whose length is used to determine the number of characters to be read.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 425 of file TupleInput.java.

References readChar().

final String com::sleepycat::bind::tuple::TupleInput::readChars int  length  )  throws IndexOutOfBoundsException [inline]
 

Reads the specified number of characters from the buffer, converting each two byte unsigned value to a character of the resulting string. Reads values that were written using TupleOutput#writeChars.

Parameters:
length is the number of characters to be read.
Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 380 of file TupleInput.java.

References readChar().

final double com::sleepycat::bind::tuple::TupleInput::readDouble  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed double (eight byte) value from the buffer. Reads values that were written using TupleOutput#writeDouble. Double.longBitsToDouble is used to convert the signed long value.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 252 of file TupleInput.java.

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

final float com::sleepycat::bind::tuple::TupleInput::readFloat  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed float (four byte) value from the buffer. Reads values that were written using TupleOutput#writeFloat. Float.intBitsToFloat is used to convert the signed int value.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 236 of file TupleInput.java.

References readUnsignedInt().

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

final int com::sleepycat::bind::tuple::TupleInput::readInt  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed int (four byte) value from the buffer. Reads values that were written using TupleOutput#writeInt.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 206 of file TupleInput.java.

References readUnsignedInt().

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

final long com::sleepycat::bind::tuple::TupleInput::readLong  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed long (eight byte) value from the buffer. Reads values that were written using TupleOutput#writeLong.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 220 of file TupleInput.java.

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

final short com::sleepycat::bind::tuple::TupleInput::readShort  )  throws IndexOutOfBoundsException [inline]
 

Reads a signed short (two byte) value from the buffer. Reads values that were written using TupleOutput#writeShort.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 192 of file TupleInput.java.

References readUnsignedShort().

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

final void com::sleepycat::bind::tuple::TupleInput::readString char[]  chars  )  throws IndexOutOfBoundsException, IllegalArgumentException [inline]
 

Reads the specified number of UTF characters string from the data buffer and converts the data from UTF to Unicode. Reads values that were written using TupleOutput#writeString(char[]).

Parameters:
chars is the array to receive the data and whose length is used to determine the number of characters to be read.
Exceptions:
IndexOutOfBoundsException if no null terminating byte is found in the buffer.
IllegalArgumentException malformed UTF data is encountered.

Definition at line 470 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::getBufferBytes().

final String com::sleepycat::bind::tuple::TupleInput::readString int  length  )  throws IndexOutOfBoundsException, IllegalArgumentException [inline]
 

Reads the specified number of UTF characters string from the data buffer and converts the data from UTF to Unicode. Reads values that were written using TupleOutput#writeString(char[]).

Parameters:
length is the number of characters to be read.
Returns:
the converted string.
Exceptions:
IndexOutOfBoundsException if no null terminating byte is found in the buffer.
IllegalArgumentException malformed UTF data is encountered.

Definition at line 448 of file TupleInput.java.

References readString().

final String com::sleepycat::bind::tuple::TupleInput::readString  )  throws IndexOutOfBoundsException, IllegalArgumentException [inline]
 

Reads a null-terminated UTF string from the data buffer and converts the data from UTF to Unicode. Reads values that were written using TupleOutput#writeString(String).

Returns:
the converted string.
Exceptions:
IndexOutOfBoundsException if no null terminating byte is found in the buffer.
IllegalArgumentException malformed UTF data is encountered.

Definition at line 119 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::getBufferBytes(), and com::sleepycat::util::FastInputStream::getBufferOffset().

Referenced by com::sleepycat::bind::tuple::StringBinding::entryToObject(), readString(), collections::ship::marshal::SupplierKey::unmarshalKey(), collections::ship::marshal::ShipmentKey::unmarshalKey(), collections::ship::marshal::PartKey::unmarshalKey(), collections::ship::marshal::Supplier::unmarshalPrimaryKey(), collections::ship::marshal::Shipment::unmarshalPrimaryKey(), and collections::ship::marshal::Part::unmarshalPrimaryKey().

final int com::sleepycat::bind::tuple::TupleInput::readUnsignedByte  )  throws IndexOutOfBoundsException [inline]
 

Reads an unsigned byte (one byte) value from the buffer. Reads values that were written using TupleOutput#writeUnsignedByte.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 267 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

Referenced by readByte().

final long com::sleepycat::bind::tuple::TupleInput::readUnsignedInt  )  throws IndexOutOfBoundsException [inline]
 

Reads an unsigned int (four byte) value from the buffer. Reads values that were written using TupleOutput#writeUnsignedInt.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 308 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

Referenced by readFloat(), and readInt().

final int com::sleepycat::bind::tuple::TupleInput::readUnsignedShort  )  throws IndexOutOfBoundsException [inline]
 

Reads an unsigned short (two byte) value from the buffer. Reads values that were written using TupleOutput#writeUnsignedShort.

Returns:
the value read from the buffer.
Exceptions:
IndexOutOfBoundsException if not enough bytes are available in the buffer.

Definition at line 286 of file TupleInput.java.

References com::sleepycat::util::FastInputStream::readFast().

Referenced by readChar(), and readShort().


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