Java Doc for TupleInput.java in  » JMX » je » com » sleepycat » bind » tuple » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » JMX » je » com.sleepycat.bind.tuple 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sleepycat.util.FastInputStream
   com.sleepycat.bind.tuple.TupleInput

All known Subclasses:   com.sleepycat.persist.impl.RecordInput,
TupleInput
public class TupleInput extends FastInputStream (Code)
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. BigInteger values are stored with a preceding length having the same sign as the value.

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.

  • 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 in a tuple. Using the default comparator, null strings will be ordered last.
  • 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 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. For all character values other than zero, the default UTF byte ordering is the same as the Unicode lexicographical character ordering.

Floats and doubles are stored using two different representations: sorted representation and integer-bit (IEEE 754) representation. If you use negative floating point numbers in a key, you should use sorted representation; alternatively you may use integer-bit representation but you will need to implement and configure a custom comparator to get correct numeric ordering for negative numbers.

To use sorted representation use this set of methods:

To use integer-bit representation use this set of methods:


author:
   Mark Hayes



Constructor Summary
public  TupleInput(byte[] buffer)
     Creates a tuple input object for reading a byte array of tuple data.
public  TupleInput(byte[] buffer, int offset, int length)
     Creates a tuple input object for reading a byte array of tuple data at a given offset for a given length.
public  TupleInput(TupleOutput output)
     Creates a tuple input object from the data contained in a tuple output object.

Method Summary
final public  intgetBigIntegerByteLength()
     Returns the byte length of a BigInteger .
final public  intgetPackedIntByteLength()
     Returns the byte length of a packed integer.
final public  intgetStringByteLength()
     Returns the byte length of a null-terminated UTF string in the data buffer, including the terminator.
final public  BigIntegerreadBigInteger()
     Reads a BigInteger .
final public  booleanreadBoolean()
     Reads a boolean (one byte) unsigned value from the buffer and returns true if it is non-zero and false if it is zero.
final public  bytereadByte()
     Reads a signed byte (one byte) value from the buffer.
final public  StringreadBytes(int length)
     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.
final public  voidreadBytes(char[] chars)
     Reads the specified number of bytes from the buffer, converting each unsigned byte value to a character of the resulting array.
final public  charreadChar()
     Reads a char (two byte) unsigned value from the buffer.
final public  StringreadChars(int length)
     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.
final public  voidreadChars(char[] chars)
     Reads the specified number of characters from the buffer, converting each two byte unsigned value to a character of the resulting array.
final public  doublereadDouble()
     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.

Note: This method operations on byte array values that by default (without a custom comparator) do not sort correctly for negative values.

final public  floatreadFloat()
     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.

Note: This method operations on byte array values that by default (without a custom comparator) do not sort correctly for negative values.

final public  intreadInt()
     Reads a signed int (four byte) value from the buffer.
final public  longreadLong()
     Reads a signed long (eight byte) value from the buffer.
final public  intreadPackedInt()
     Reads a packed integer.
final public  shortreadShort()
     Reads a signed short (two byte) value from the buffer.
final public  doublereadSortedDouble()
     Reads a signed double (eight byte) value from the buffer, with support for correct default sorting of all values. Reads values that were written using TupleOutput.writeSortedDouble .

Float.longBitsToDouble and the following bit manipulations are used to convert the stored representation to a signed double value.

 int val = ...
final public  floatreadSortedFloat()
     Reads a signed float (four byte) value from the buffer, with support for correct default sorting of all values. Reads values that were written using TupleOutput.writeSortedFloat .

Float.intBitsToFloat and the following bit manipulations are used to convert the stored representation to a signed float value.

 int val = ...
final public  StringreadString()
     Reads a null-terminated UTF string from the data buffer and converts the data from UTF to Unicode.
final public  StringreadString(int length)
     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.
final public  voidreadString(char[] chars)
     Reads the specified number of UTF characters string from the data buffer and converts the data from UTF to Unicode.
final public  intreadUnsignedByte()
     Reads an unsigned byte (one byte) value from the buffer.
final public  longreadUnsignedInt()
     Reads an unsigned int (four byte) value from the buffer.
final public  intreadUnsignedShort()
     Reads an unsigned short (two byte) value from the buffer.


Constructor Detail
TupleInput
public TupleInput(byte[] buffer)(Code)
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 intuple format.



TupleInput
public TupleInput(byte[] buffer, int offset, int length)(Code)
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 intuple format.
Parameters:
  offset - is the byte offset at which to begin reading.
Parameters:
  length - is the number of bytes to be read.



TupleInput
public TupleInput(TupleOutput output)(Code)
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.




Method Detail
getBigIntegerByteLength
final public int getBigIntegerByteLength()(Code)
Returns the byte length of a BigInteger .
See Also:   TupleOutput.writeBigInteger



getPackedIntByteLength
final public int getPackedIntByteLength()(Code)
Returns the byte length of a packed integer.
See Also:   PackedInteger



getStringByteLength
final public int getStringByteLength() throws IndexOutOfBoundsException, IllegalArgumentException(Code)
Returns the byte length of a null-terminated UTF string in the data buffer, including the terminator. Used with string values that were written using TupleOutput.writeString(String) .
throws:
  IndexOutOfBoundsException - if no null terminating byte is foundin the buffer.
throws:
  IllegalArgumentException - malformed UTF data is encountered.



readBigInteger
final public BigInteger readBigInteger()(Code)
Reads a BigInteger .
See Also:   TupleOutput.writeBigInteger



readBoolean
final public boolean readBoolean() throws IndexOutOfBoundsException(Code)
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 . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readByte
final public byte readByte() throws IndexOutOfBoundsException(Code)
Reads a signed byte (one byte) value from the buffer. Reads values that were written using TupleOutput.writeByte . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readBytes
final public String readBytes(int length) throws IndexOutOfBoundsException(Code)
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. the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readBytes
final public void readBytes(char[] chars) throws IndexOutOfBoundsException(Code)
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 usedto determine the number of bytes to be read.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readChar
final public char readChar() throws IndexOutOfBoundsException(Code)
Reads a char (two byte) unsigned value from the buffer. Reads values that were written using TupleOutput.writeChar . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readChars
final public String readChars(int length) throws IndexOutOfBoundsException(Code)
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. the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readChars
final public void readChars(char[] chars) throws IndexOutOfBoundsException(Code)
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 usedto determine the number of characters to be read.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readDouble
final public double readDouble() throws IndexOutOfBoundsException(Code)
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.

Note: This method operations on byte array values that by default (without a custom comparator) do not sort correctly for negative values. Only non-negative values are sorted correctly by default. To sort all values correctly by default, use TupleInput.readSortedDouble .

the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readFloat
final public float readFloat() throws IndexOutOfBoundsException(Code)
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.

Note: This method operations on byte array values that by default (without a custom comparator) do not sort correctly for negative values. Only non-negative values are sorted correctly by default. To sort all values correctly by default, use TupleInput.readSortedFloat .

the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readInt
final public int readInt() throws IndexOutOfBoundsException(Code)
Reads a signed int (four byte) value from the buffer. Reads values that were written using TupleOutput.writeInt . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readLong
final public long readLong() throws IndexOutOfBoundsException(Code)
Reads a signed long (eight byte) value from the buffer. Reads values that were written using TupleOutput.writeLong . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readPackedInt
final public int readPackedInt()(Code)
Reads a packed integer. Note that packed integers are not appropriate for sorted values (keys) unless a custom comparator is used.
See Also:   PackedInteger



readShort
final public short readShort() throws IndexOutOfBoundsException(Code)
Reads a signed short (two byte) value from the buffer. Reads values that were written using TupleOutput.writeShort . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readSortedDouble
final public double readSortedDouble() throws IndexOutOfBoundsException(Code)
Reads a signed double (eight byte) value from the buffer, with support for correct default sorting of all values. Reads values that were written using TupleOutput.writeSortedDouble .

Float.longBitsToDouble and the following bit manipulations are used to convert the stored representation to a signed double value.

 int val = ... // get stored bits
 val ^= (val < 0) ? 0x8000000000000000L : 0xffffffffffffffffL;
 return Double.longBitsToDouble(val);
 
the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readSortedFloat
final public float readSortedFloat() throws IndexOutOfBoundsException(Code)
Reads a signed float (four byte) value from the buffer, with support for correct default sorting of all values. Reads values that were written using TupleOutput.writeSortedFloat .

Float.intBitsToFloat and the following bit manipulations are used to convert the stored representation to a signed float value.

 int val = ... // get stored bits
 val ^= (val < 0) ? 0x80000000 : 0xffffffff;
 return Float.intBitsToFloat(val);
 
the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readString
final public String readString() throws IndexOutOfBoundsException, IllegalArgumentException(Code)
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) . the converted string.
throws:
  IndexOutOfBoundsException - if no null terminating byte is foundin the buffer.
throws:
  IllegalArgumentException - malformed UTF data is encountered.



readString
final public String readString(int length) throws IndexOutOfBoundsException, IllegalArgumentException(Code)
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. the converted string.
throws:
  IndexOutOfBoundsException - if no null terminating byte is foundin the buffer.
throws:
  IllegalArgumentException - malformed UTF data is encountered.



readString
final public void readString(char[] chars) throws IndexOutOfBoundsException, IllegalArgumentException(Code)
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 usedto determine the number of characters to be read.
throws:
  IndexOutOfBoundsException - if no null terminating byte is foundin the buffer.
throws:
  IllegalArgumentException - malformed UTF data is encountered.



readUnsignedByte
final public int readUnsignedByte() throws IndexOutOfBoundsException(Code)
Reads an unsigned byte (one byte) value from the buffer. Reads values that were written using TupleOutput.writeUnsignedByte . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readUnsignedInt
final public long readUnsignedInt() throws IndexOutOfBoundsException(Code)
Reads an unsigned int (four byte) value from the buffer. Reads values that were written using TupleOutput.writeUnsignedInt . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



readUnsignedShort
final public int readUnsignedShort() throws IndexOutOfBoundsException(Code)
Reads an unsigned short (two byte) value from the buffer. Reads values that were written using TupleOutput.writeUnsignedShort . the value read from the buffer.
throws:
  IndexOutOfBoundsException - if not enough bytes are available inthe buffer.



Fields inherited from com.sleepycat.util.FastInputStream
protected byte[] buf(Code)(Java Doc)
protected int len(Code)(Java Doc)
protected int mark(Code)(Java Doc)
protected int off(Code)(Java Doc)

Methods inherited from com.sleepycat.util.FastInputStream
public int available()(Code)(Java Doc)
final public byte[] getBufferBytes()(Code)(Java Doc)
final public int getBufferLength()(Code)(Java Doc)
final public int getBufferOffset()(Code)(Java Doc)
public void mark(int readLimit)(Code)(Java Doc)
public boolean markSupported()(Code)(Java Doc)
public int read() throws IOException(Code)(Java Doc)
public int read(byte[] toBuf) throws IOException(Code)(Java Doc)
public int read(byte[] toBuf, int offset, int length) throws IOException(Code)(Java Doc)
final public int readFast()(Code)(Java Doc)
final public int readFast(byte[] toBuf)(Code)(Java Doc)
final public int readFast(byte[] toBuf, int offset, int length)(Code)(Java Doc)
public void reset()(Code)(Java Doc)
public long skip(long count)(Code)(Java Doc)
final public void skipFast(int count)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.