<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_03) on Mon Jan 31 15:55:51 EST 2011 --> <TITLE> com.sleepycat.bind.tuple (Oracle - Berkeley DB Java API) </TITLE> <META NAME="date" CONTENT="2011-01-31"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../style.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="com.sleepycat.bind.tuple (Oracle - Berkeley DB Java API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Berkeley DB</b><br><font size="-1"> version 5.1.25</font></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/sleepycat/bind/serial/package-summary.html"><B>PREV PACKAGE</B></A> <A HREF="../../../../com/sleepycat/collections/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/sleepycat/bind/tuple/package-summary.html" target="_top"><B>FRAMES</B></A> <A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <H2> Package com.sleepycat.bind.tuple </H2> Bindings that use sequences of primitive fields, or tuples. <P> <B>See:</B> <BR> <A HREF="#package_description"><B>Description</B></A> <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Interface Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/MarshalledTupleEntry.html" title="interface in com.sleepycat.bind.tuple">MarshalledTupleEntry</A></B></TD> <TD>A marshalling interface implemented by key, data or entity classes that are represented as tuples.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/MarshalledTupleKeyEntity.html" title="interface in com.sleepycat.bind.tuple">MarshalledTupleKeyEntity</A></B></TD> <TD>A marshalling interface implemented by entity classes that represent keys as tuples.</TD> </TR> </TABLE> <P> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Class Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/BigDecimalBinding.html" title="class in com.sleepycat.bind.tuple">BigDecimalBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for an unsorted <code>BigDecimal</code> value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/BigIntegerBinding.html" title="class in com.sleepycat.bind.tuple">BigIntegerBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>BigInteger</code> value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/BooleanBinding.html" title="class in com.sleepycat.bind.tuple">BooleanBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Boolean</code> primitive wrapper or a <code>boolean</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/ByteBinding.html" title="class in com.sleepycat.bind.tuple">ByteBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Byte</code> primitive wrapper or a <code>byte</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/CharacterBinding.html" title="class in com.sleepycat.bind.tuple">CharacterBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Character</code> primitive wrapper or a <code>char</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/DoubleBinding.html" title="class in com.sleepycat.bind.tuple">DoubleBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for an unsorted <code>Double</code> primitive wrapper or an unsorted <code>double</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/FloatBinding.html" title="class in com.sleepycat.bind.tuple">FloatBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for an unsorted <code>Float</code> primitive wrapper or an unsorted <code>float</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/IntegerBinding.html" title="class in com.sleepycat.bind.tuple">IntegerBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Integer</code> primitive wrapper or an <code>int</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/LongBinding.html" title="class in com.sleepycat.bind.tuple">LongBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Long</code> primitive wrapper or a <code>long</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/PackedIntegerBinding.html" title="class in com.sleepycat.bind.tuple">PackedIntegerBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for an unsorted <code>Integer</code> primitive wrapper or an unsorted <code>int</code> primitive, that stores the value in the smallest number of bytes possible.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/PackedLongBinding.html" title="class in com.sleepycat.bind.tuple">PackedLongBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for an unsorted <code>Long</code> primitive wrapper or an unsorted <code>long</code> primitive, that stores the value in the smallest number of bytes possible.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/ShortBinding.html" title="class in com.sleepycat.bind.tuple">ShortBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a <code>Short</code> primitive wrapper or a <code>short</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/SortedBigDecimalBinding.html" title="class in com.sleepycat.bind.tuple">SortedBigDecimalBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a sorted <code>BigDecimal</code> value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/SortedDoubleBinding.html" title="class in com.sleepycat.bind.tuple">SortedDoubleBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a sorted <code>Double</code> primitive wrapper or a sorted <code>double</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/SortedFloatBinding.html" title="class in com.sleepycat.bind.tuple">SortedFloatBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a sorted <code>Float</code> primitive wrapper or sorted a <code>float</code> primitive.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/SortedPackedIntegerBinding.html" title="class in com.sleepycat.bind.tuple">SortedPackedIntegerBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a sorted <code>Integer</code> primitive wrapper or a sorted <code>int</code> primitive, that stores the value in the smallest number of bytes possible.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/SortedPackedLongBinding.html" title="class in com.sleepycat.bind.tuple">SortedPackedLongBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a sorted <code>Long</code> primitive wrapper or a sorted <code>long</code> primitive, that stores the value in the smallest number of bytes possible.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/StringBinding.html" title="class in com.sleepycat.bind.tuple">StringBinding</A></B></TD> <TD>A concrete <code>TupleBinding</code> for a simple <code>String</code> value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleBase.html" title="class in com.sleepycat.bind.tuple">TupleBase<E></A></B></TD> <TD>A base class for tuple bindings and tuple key creators that provides control over the allocation of the output buffer.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleBinding.html" title="class in com.sleepycat.bind.tuple">TupleBinding<E></A></B></TD> <TD>An abstract <code>EntryBinding</code> that treats a key or data entry as a tuple; it includes predefined bindings for Java primitive types.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html" title="class in com.sleepycat.bind.tuple">TupleInput</A></B></TD> <TD>An <code>InputStream</code> with <code>DataInput</code>-like methods for reading tuple fields.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleInputBinding.html" title="class in com.sleepycat.bind.tuple">TupleInputBinding</A></B></TD> <TD>A concrete <code>EntryBinding</code> that uses the <code>TupleInput</code> object as the key or data object.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleMarshalledBinding.html" title="class in com.sleepycat.bind.tuple">TupleMarshalledBinding<E extends MarshalledTupleEntry></A></B></TD> <TD>A concrete <code>TupleBinding</code> that delegates to the <code>MarshalledTupleEntry</code> interface of the data or key object.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html" title="class in com.sleepycat.bind.tuple">TupleOutput</A></B></TD> <TD>An <code>OutputStream</code> with <code>DataOutput</code>-like methods for writing tuple fields.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleTupleBinding.html" title="class in com.sleepycat.bind.tuple">TupleTupleBinding<E></A></B></TD> <TD>An abstract <code>EntityBinding</code> that treats an entity's key entry and data entry as tuples.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleTupleKeyCreator.html" title="class in com.sleepycat.bind.tuple">TupleTupleKeyCreator<E></A></B></TD> <TD>An abstract key creator that uses a tuple key and a tuple data entry.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleTupleMarshalledBinding.html" title="class in com.sleepycat.bind.tuple">TupleTupleMarshalledBinding<E extends MarshalledTupleEntry & MarshalledTupleKeyEntity></A></B></TD> <TD>A concrete <code>TupleTupleBinding</code> that delegates to the <code>MarshalledTupleEntry</code> and <code>MarshalledTupleKeyEntity</code> interfaces of the entity class.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD WIDTH="15%"><B><A HREF="../../../../com/sleepycat/bind/tuple/TupleTupleMarshalledKeyCreator.html" title="class in com.sleepycat.bind.tuple">TupleTupleMarshalledKeyCreator<E extends MarshalledTupleEntry & MarshalledTupleKeyEntity></A></B></TD> <TD>A concrete key creator that works in conjunction with a <A HREF="../../../../com/sleepycat/bind/tuple/TupleTupleMarshalledBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>TupleTupleMarshalledBinding</CODE></A>.</TD> </TR> </TABLE> <P> <A NAME="package_description"><!-- --></A><H2> Package com.sleepycat.bind.tuple Description </H2> <P> Bindings that use sequences of primitive fields, or tuples. <h2><a name="formats">Tuple Formats</a></h2> <p>The serialization format for tuple bindings are designed for compactness, serialization speed and proper default sorting.</p> <p>When a format is used for database keys, it is important to use default sorting for best performance. Although a custom comparator may be specified for a <A HREF="../../../../com/sleepycat/db/DatabaseConfig.html#setBtreeComparator(java.util.Comparator)"><CODE>database</CODE></A> or <a href="../../../../com/sleepycat/persist/model/KeyField.html#comparable">entity index</a>, custom comparators often reduce performance because comparators are called very frequently during Btree operations.</p> <p>For proper default sorting, the byte array of the stored format must be designed so that a byte-by-byte unsigned comparison results in the natural sort order, as defined by the <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html?is-external=true#compareTo(T)" title="class or interface in java.lang"><CODE>Comparable.compareTo(T)</CODE></A> method of the data type. For example, the natural sort order for integers is the standard mathematical definition, and is implemented by <code>Integer.compareTo</code>, <code>Long.compareTo</code>, etc. This is called <em>default natural sorting</em>.</p> <p>Although most tuple formats provide default natural sorting, not all of them do. Certain formats do not provide default natural sorting for historical reasons (see the discussion of packed integer and float formats below.) Other formats sacrifice default natural sorting for other performance factors (see the discussion of BigDecimal formats below.)</p> <h3><a name="stringFormats">String Formats</a></h3> <p>All <code>String</code> formats support default natural sorting.</p> <p>Strings are stored as a byte array of UTF encoded characters, either where the length must be known by the application, or the byte array is zero-terminated. The UTF encoding is described below.</p> <ul> <li>Null strings are UTF encoded as { 0xFF }, which is not allowed in a standard UTF encoding. This allows null strings, as distinct from empty or zero length strings, to be represented. Using default sorting, null strings will be ordered last. </li> <li>Zero (0x0000) character values are UTF encoded as non-zero values, and therefore embedded zeros in the string are supported. The sequence { 0xC0, 0x80 } is used to encode a zero character. This UTF encoding is the same one used by the native Java UTF libraries. However, this encoding of zero does impact the lexicographical ordering, and zeros will not be sorted first (the natural order) or last. </li> <li>For all character values other than zero, the default UTF encoding is used, and the default sorting is the same as the Unicode lexicographical character ordering. </li> </ul> <p>Binding classes and methods are provided for zero-terminated and known-length <code>String</code> values.</p> <ul> <li>Single-value binding classes for zero-terminated <code>String</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/StringBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>StringBinding</CODE></A></li> </ul> <li>Multi-value binding methods for zero-terminated and known-length <code>String</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeString(java.lang.String)"><CODE>TupleOutput.writeString(String)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readString()"><CODE>TupleInput.readString()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getStringByteLength()"><CODE>TupleInput.getStringByteLength()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeString(char[])"><CODE>TupleOutput.writeString(char[])</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readString(char[])"><CODE>TupleInput.readString(char[])</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readString(int)"><CODE>TupleInput.readString(int)</CODE></A></li> </ul> </ul> <h3><a name="integerFormats">Integer Formats</a></h3> <h4>Fixed Size Integer Formats</h4> <p>All fixed size integer formats support default natural sorting.</p> <p>The size of the stored value depends on the type, and ranges (as one would expect) from 1 byte for type <code>byte</code> and class {code Byte}, to 8 bytes for type <code>long</code> and class <code>Long</code>.</p> <p>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.</p> <ul> <li>Single-value binding classes for signed, fixed size integers.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/ByteBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>ByteBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/ShortBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>ShortBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/IntegerBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>IntegerBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/LongBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>LongBinding</CODE></A></li> </ul> <li>Multi-value binding methods for signed, fixed size integers.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeByte(int)"><CODE>TupleOutput.writeByte(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readByte()"><CODE>TupleInput.readByte()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeShort(int)"><CODE>TupleOutput.writeShort(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readShort()"><CODE>TupleInput.readShort()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeInt(int)"><CODE>TupleOutput.writeInt(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readInt()"><CODE>TupleInput.readInt()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeLong(long)"><CODE>TupleOutput.writeLong(long)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readLong()"><CODE>TupleInput.readLong()</CODE></A></li> </ul> </ul> <p>Unsigned numbers, including characters, are stored in MSB order with no change to their sign bit. Arrays of characters and unsigned bytes may also be stored and may be treated as <code>String</code> values. For booleans, <code>true</code> is stored as the unsigned byte value one and <code>false</code> as the unsigned byte value zero.</p> <ul> <li>Single-value binding classes for characters and booleans.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/BooleanBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>BooleanBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/CharacterBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>CharacterBinding</CODE></A></li> </ul> <li>Multi-value binding methods for unsigned, fixed size integers, characters and booleans.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeBoolean(boolean)"><CODE>TupleOutput.writeBoolean(boolean)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readBoolean()"><CODE>TupleInput.readBoolean()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeChar(int)"><CODE>TupleOutput.writeChar(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readChar()"><CODE>TupleInput.readChar()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeUnsignedByte(int)"><CODE>TupleOutput.writeUnsignedByte(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readUnsignedByte()"><CODE>TupleInput.readUnsignedByte()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeUnsignedShort(int)"><CODE>TupleOutput.writeUnsignedShort(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readUnsignedShort()"><CODE>TupleInput.readUnsignedShort()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeUnsignedInt(long)"><CODE>TupleOutput.writeUnsignedInt(long)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readUnsignedInt()"><CODE>TupleInput.readUnsignedInt()</CODE></A></li> </ul> <li>Multi-value binding methods for character arrays and unsigned byte arrays that may be treated as <code>String</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeChars(java.lang.String)"><CODE>TupleOutput.writeChars(String)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readChars(int)"><CODE>TupleInput.readChars(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeChars(char[])"><CODE>TupleOutput.writeChars(char[])</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readChars(char[])"><CODE>TupleInput.readChars(char[])</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeBytes(java.lang.String)"><CODE>TupleOutput.writeBytes(String)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readBytes(int)"><CODE>TupleInput.readBytes(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeBytes(char[])"><CODE>TupleOutput.writeBytes(char[])</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readBytes(char[])"><CODE>TupleInput.readBytes(char[])</CODE></A></li> </ul> </ul> <h4>Packed Integer Formats</h4> <p>The packed integer format stores integers with small absolute values in a single byte. The size increases as the absolute value increases, up to a maximum of 5 bytes for <code>int</code> values and 9 bytes for <code>long</code> values.</p> <p>The packed integer format can be used for integer values between <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Long.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><CODE>Long.MIN_VALUE</CODE></A> and <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Long.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Long.MAX_VALUE</CODE></A>. However, different bindings and methods are provided for type <code>int</code> and <code>long</code>, to avoid unsafe casting from <code>long</code> to <code>int</code> when <code>int</code> values are used.</p> <p>Because the same packed format is used for <code>int</code> and <code>long</code> values, stored <code>int</code> values may be expanded to <code>long</code> values without introducing a format incompatibility. In other words, you can treat previously stored packed <code>int</code> values as packed <code>long</code> values.</p> <p>Packed integer formats come in two varieties: those that support default natural sorting and those that don't. The formats of the two varieties are incompatible. For new applications, the format that supports default natural sorting should normally be used. There is no performance advantage to using the unsorted format.</p> <p>The format with support for default natural sorting stores values in the inclusive range [-119,120] in a single byte.</p> <ul> <li>Single-value binding classes for packed integers with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/SortedPackedIntegerBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>SortedPackedIntegerBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/SortedPackedLongBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>SortedPackedLongBinding</CODE></A></li> </ul> <li>Multi-value binding methods for packed integers with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeSortedPackedInt(int)"><CODE>TupleOutput.writeSortedPackedInt(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readSortedPackedInt()"><CODE>TupleInput.readSortedPackedInt()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getSortedPackedIntByteLength()"><CODE>TupleInput.getSortedPackedIntByteLength()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeSortedPackedLong(long)"><CODE>TupleOutput.writeSortedPackedLong(long)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readSortedPackedLong()"><CODE>TupleInput.readSortedPackedLong()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getSortedPackedLongByteLength()"><CODE>TupleInput.getSortedPackedLongByteLength()</CODE></A></li> </ul> </ul> <p>The unsorted packed integer format is an older, legacy format that is used internally and supported for compatibility. It stores values in the inclusive range [-119,119] in a single byte. Because default natural sorting is not supported, this format should not be used for keys. However, it so happens that packed integers in the inclusive range [0,630] are sorted correctly by default, and this may be useful for some applications.</p> <ul> <li>Single-value binding classes for legacy, unsorted packed integers.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/PackedIntegerBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>PackedIntegerBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/PackedLongBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>PackedLongBinding</CODE></A></li> </ul> <li>Multi-value binding methods for legacy, unsorted packed integers.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writePackedInt(int)"><CODE>TupleOutput.writePackedInt(int)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readPackedInt()"><CODE>TupleInput.readPackedInt()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getPackedIntByteLength()"><CODE>TupleInput.getPackedIntByteLength()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writePackedLong(long)"><CODE>TupleOutput.writePackedLong(long)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readPackedLong()"><CODE>TupleInput.readPackedLong()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getPackedLongByteLength()"><CODE>TupleInput.getPackedLongByteLength()</CODE></A></li> </ul> </ul> <h4>BigInteger Formats</h4> <p>All <code>BigInteger</code> formats support default natural sorting.</p> <p><code>BigInteger</code> values are variable length and are stored as signed values with a preceding byte length. The length has the same sign as the value, in order to support default natural sorting.</p> <p>The length is stored as a 2-byte (short), fixed size, signed integer. Supported values are therefore limited to those with a byte array (<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigInteger.html?is-external=true#toByteArray()" title="class or interface in java.math"><CODE>BigInteger.toByteArray()</CODE></A>) representation with a size of 0x7fff bytes or less. The maximum <code>BigInteger</code> value is (2<sup>0x3fff7</sup> - 1) and the minimum value is (-2<sup>0x3fff7</sup>).</p> <ul> <li>Single-value binding classes for <code>BigInteger</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/BigIntegerBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>BigIntegerBinding</CODE></A></li> </ul> <li>Multi-value binding methods for <code>BigInteger</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeBigInteger(java.math.BigInteger)"><CODE>TupleOutput.writeBigInteger(java.math.BigInteger)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readBigInteger()"><CODE>TupleInput.readBigInteger()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#getBigIntegerByteLength(java.math.BigInteger)"><CODE>TupleOutput.getBigIntegerByteLength(java.math.BigInteger)</CODE></A></li> </ul> </ul> <h3><a name="floatFormats">Floating Point Formats</a></h3> <p>Floats and doubles are stored in a fixed size, 4 and 8 byte format, respectively. Floats and doubles are stored using two different representations: a representation with default natural sorting, and an unsorted, integer-bit (IEEE 754) representation. For new applications, the format that supports default natural sorting should normally be used. There is no performance advantage to using the unsorted format.</p> <p>For <code>float</code> values, <code>Float.floatToIntBits</code> and the following bit manipulations are used to convert the signed float value to a representation that is sorted correctly by default.</p> <pre> int intVal = Float.floatToIntBits(val); intVal ^= (intVal < 0) ? 0xffffffff : 0x80000000; </pre> <p>For <code>double</code> values, <code>Float.doubleToLongBits</code> and the following bit manipulations are used to convert the signed double value to a representation that is sorted correctly by default.</p> <pre> long longVal = Double.doubleToLongBits(val); longVal ^= (longVal < 0) ? 0xffffffffffffffffL : 0x8000000000000000L; </pre> <p>In both cases, the resulting <code>int</code> or <code>long</code> value is stored as an unsigned value.</p> <ul> <li>Single-value binding classes for <code>float</code> and <code>double</code> values with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/SortedFloatBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>SortedFloatBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/SortedDoubleBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>SortedDoubleBinding</CODE></A></li> </ul> <li>Multi-value binding methods for <code>float</code> and <code>double</code> values with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeSortedFloat(float)"><CODE>TupleOutput.writeSortedFloat(float)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readSortedFloat()"><CODE>TupleInput.readSortedFloat()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeSortedDouble(double)"><CODE>TupleOutput.writeSortedDouble(double)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readSortedDouble()"><CODE>TupleInput.readSortedDouble()</CODE></A></li> </ul> </ul> <p>The unsorted floating point format is an older, legacy format that is supported for compatibility. With this format, only zero and positive values have default natural sorting; negative values do not.</p> <ul> <li>Single-value binding classes for legacy, unsorted <code>float</code> and <code>double</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/FloatBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>FloatBinding</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/DoubleBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>DoubleBinding</CODE></A></li> </ul> <li>Multi-value binding methods for legacy, unsorted <code>float</code> and <code>double</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeFloat(float)"><CODE>TupleOutput.writeFloat(float)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readFloat()"><CODE>TupleInput.readFloat()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeDouble(double)"><CODE>TupleOutput.writeDouble(double)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readDouble()"><CODE>TupleInput.readDouble()</CODE></A></li> </ul> </ul> <h3><a name="bigDecimalFormats">BigDecimal Formats</a></h3> <p><code>BigDecimal</code> values are stored using two different, variable length representations: a representation that supports default natural sorting, and an unsorted representation. Differences between the two formats are: <ul> <li>The <code>BigDecimal</code> format with default natural sorting should normally be used for database keys.</li> <ul> <li>Default natural sorting <em>is</em> supported.</li> <li>The stored value is around 3 bytes larger than the unsorted format, more or less, and is a minimum of 8 bytes.</li> <li>More computation is required for serialization than the unsorted format.</li> <li>Trailing zeros after the decimal place are stripped, meaning that precision is not preserved.</li> </ul> <li>The unsorted <code>BigDecimal</code> format should normally be used for non-key values.</li> <ul> <li>Default natural sorting is <em>not</em> supported.</li> <li>The stored value is around 3 bytes smaller than the sorted format, more or less, and is a minimum of 3 bytes.</li> <li>Less computation is required for serialization than the sorted format.</li> <li>Trailing zeros after the decimal place are preserved, meaning that precision is preserved.</li> </ul> </ul> <p>Both formats store the scale or exponent separately from the unscaled value, and the stored size does not increase proportionally as the absolute value of the scale or exponent increases.</p> <ul> <li>Single-value binding classes for <code>BigDecimal</code> values with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/SortedBigDecimalBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>SortedBigDecimalBinding</CODE></A></li> </ul> <li>Multi-value binding methods for <code>BigDecimal</code> values with default natural sorting.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeSortedBigDecimal(java.math.BigDecimal)"><CODE>TupleOutput.writeSortedBigDecimal(java.math.BigDecimal)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#getSortedBigDecimalMaxByteLength(java.math.BigDecimal)"><CODE>TupleOutput.getSortedBigDecimalMaxByteLength(java.math.BigDecimal)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readSortedBigDecimal()"><CODE>TupleInput.readSortedBigDecimal()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getSortedBigDecimalByteLength()"><CODE>TupleInput.getSortedBigDecimalByteLength()</CODE></A></li> </ul> <li>Single-value binding classes for unsorted <code>BigDecimal</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/BigDecimalBinding.html" title="class in com.sleepycat.bind.tuple"><CODE>BigDecimalBinding</CODE></A></li> </ul> <li>Multi-value binding methods for unsorted <code>BigDecimal</code> values.</li> <ul> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#writeBigDecimal(java.math.BigDecimal)"><CODE>TupleOutput.writeBigDecimal(java.math.BigDecimal)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleOutput.html#getBigDecimalMaxByteLength(java.math.BigDecimal)"><CODE>TupleOutput.getBigDecimalMaxByteLength(java.math.BigDecimal)</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#readBigDecimal()"><CODE>TupleInput.readBigDecimal()</CODE></A></li> <li><A HREF="../../../../com/sleepycat/bind/tuple/TupleInput.html#getBigDecimalByteLength()"><CODE>TupleInput.getBigDecimalByteLength()</CODE></A></li> </ul> </ul> * @see <a href="package-summary.html#stringFormats">String Formats</a> * @see <a href="package-summary.html#integerFormats">Integer Formats</a> * @see <a href="package-summary.html#floatFormats">Floating Point Formats</a> * @see <a href="package-summary.html#bigDecimalFormats">BigDecimal Formats</a> <P> <P> <DL> </DL> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Package</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <FONT CLASS="NavBarFont1">Class</FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-use.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> <b>Berkeley DB</b><br><font size="-1"> version 5.1.25</font></EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/sleepycat/bind/serial/package-summary.html"><B>PREV PACKAGE</B></A> <A HREF="../../../../com/sleepycat/collections/package-summary.html"><B>NEXT PACKAGE</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/sleepycat/bind/tuple/package-summary.html" target="_top"><B>FRAMES</B></A> <A HREF="package-summary.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> <font size=1>Copyright (c) 1996, 2010 Oracle and/or its affiliates. All rights reserved.</font> </BODY> </HTML>