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 DataInput
IOException
public boolean readBoolean() throws IOException
readBoolean
in interface DataInput
IOException
public byte readByte() throws IOException
readByte
in interface DataInput
IOException
public char readChar() throws IOException
readChar
in interface DataInput
IOException
public int readUnsignedShort() throws IOException
readUnsignedShort
in interface DataInput
IOException
public short readShort() throws IOException
readShort
in interface DataInput
IOException
public int readInt() throws IOException
readInt
in interface DataInput
IOException
public long readLong() throws IOException
readLong
in interface DataInput
IOException
public float readFloat() throws IOException
readFloat
in interface DataInput
IOException
public double readDouble() throws IOException
readDouble
in interface DataInput
IOException
public void readFully(byte[] b) throws IOException
readFully
in interface DataInput
IOException
public void readFully(byte[] b, int off, int len) throws IOException
readFully
in interface DataInput
IOException
protected int read(byte[] b, int off, int len) throws IOException
IOException
protected final byte read() throws IOException
IOException
public int skipBytes(int n) throws IOException
skipBytes
in interface DataInput
IOException
public String readUTF() throws IOException
readUTF
in interface DataInput
IOException
public 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.IOException
public 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–2016 JBoss, a division of Red Hat. All rights reserved.