public class BsonDataInput extends Object implements DataInput
DataInput with additional methods needed for reading BSON formatted content from another DataInput
instance. Specifically, this class reads little-endian byte order (purposefully in violation of the DataInput interface
specification) and provides a way to read C-style strings (where the length is not known up front but instead contain all
characters until the zero-byte terminator), which are commonly used within the BSON specification.| Constructor and Description |
|---|
BsonDataInput(DataInput input) |
| Modifier and Type | Method and Description |
|---|---|
int |
getTotalBytesRead()
Returns the number of bytes that have been read from this input.
|
protected byte |
read() |
protected int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
static String |
readUTF(DataInput dis,
int len)
Utility method to read a UTF-8 string from the supplied DataInput object given the supplied number of bytes to read or, if
the number of bytes is not known, all of the UTF-8 characters until the next zero-byte value.
|
String |
readUTF(int len)
Read a UTF-8 string with the supplied length or, if the length is not known, the UTF-8 characters until the next zero-byte
value.
|
int |
skipBytes(int n) |
public BsonDataInput(DataInput input)
public int getTotalBytesRead()
throws IOException
IOException - if an I/O error occurs.public final int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputIOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputIOExceptionprotected int read(byte[] b,
int off,
int len)
throws IOException
IOExceptionprotected final byte read()
throws IOException
IOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputIOExceptionpublic String readUTF(int len) throws IOException
standard way to read a string, which always expects the
length to be the first value on the stream.len - the number of bytes to read, or -1 if the length is not known and characters should be read until the next
zero-byte string.IOExceptionpublic static String readUTF(DataInput dis, int len) throws IOException
standard way to read a string, which always expects the length to be the first value on the
stream.dis - the DataInput from which the UTF-8 string is to be readlen - the number of bytes to read, or -1 if the length is not known and characters should be read until the next
zero-byte string.IOException - if there is a problem reading from the inputCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.