Package org.bson.io
Class ByteBufferBsonInput
- java.lang.Object
-
- org.bson.io.ByteBufferBsonInput
-
-
Constructor Summary
Constructors Constructor Description ByteBufferBsonInput(ByteBuf buffer)
Construct an instance with the given byte buffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
BsonInputMark
getMark(int readLimit)
Gets a mark for the current position in the stream.int
getPosition()
Gets the current position in the streamboolean
hasRemaining()
Returns true if there are more bytes left in the stream.void
mark(int readLimit)
Deprecated.byte
readByte()
Reads a single byte from the streamvoid
readBytes(byte[] bytes)
Reads the specified number of bytes into the given byte array.void
readBytes(byte[] bytes, int offset, int length)
Reads the specified number of bytes into the given byte array starting at the specified offset.java.lang.String
readCString()
Reads a BSON CString value from the stream.double
readDouble()
Reads a BSON Double value from the stream.int
readInt32()
Reads a BSON Int32 value from the stream.long
readInt64()
Reads a BSON Int64 value from the stream.ObjectId
readObjectId()
Reads a BSON ObjectId value from the stream.java.lang.String
readString()
Reads a BSON String value from the stream.void
reset()
Deprecated.void
skip(int numBytes)
Skips the specified number of bytes in the stream.void
skipCString()
Skips a BSON CString value from the stream.
-
-
-
Constructor Detail
-
ByteBufferBsonInput
public ByteBufferBsonInput(ByteBuf buffer)
Construct an instance with the given byte buffer. The stream takes over ownership of the buffer and closes it when this instance is closed.- Parameters:
buffer
- the byte buffer
-
-
Method Detail
-
getPosition
public int getPosition()
Description copied from interface:BsonInput
Gets the current position in the stream- Specified by:
getPosition
in interfaceBsonInput
- Returns:
- the current position
-
readByte
public byte readByte()
Description copied from interface:BsonInput
Reads a single byte from the stream
-
readBytes
public void readBytes(byte[] bytes)
Description copied from interface:BsonInput
Reads the specified number of bytes into the given byte array. This is equivalent to toreadBytes(bytes, 0, bytes.length)
.
-
readBytes
public void readBytes(byte[] bytes, int offset, int length)
Description copied from interface:BsonInput
Reads the specified number of bytes into the given byte array starting at the specified offset.
-
readInt64
public long readInt64()
Description copied from interface:BsonInput
Reads a BSON Int64 value from the stream.
-
readDouble
public double readDouble()
Description copied from interface:BsonInput
Reads a BSON Double value from the stream.- Specified by:
readDouble
in interfaceBsonInput
- Returns:
- the double value
-
readInt32
public int readInt32()
Description copied from interface:BsonInput
Reads a BSON Int32 value from the stream.
-
readObjectId
public ObjectId readObjectId()
Description copied from interface:BsonInput
Reads a BSON ObjectId value from the stream.- Specified by:
readObjectId
in interfaceBsonInput
- Returns:
- the ObjectId
-
readString
public java.lang.String readString()
Description copied from interface:BsonInput
Reads a BSON String value from the stream.- Specified by:
readString
in interfaceBsonInput
- Returns:
- the string
-
readCString
public java.lang.String readCString()
Description copied from interface:BsonInput
Reads a BSON CString value from the stream.- Specified by:
readCString
in interfaceBsonInput
- Returns:
- the CString
-
skipCString
public void skipCString()
Description copied from interface:BsonInput
Skips a BSON CString value from the stream.- Specified by:
skipCString
in interfaceBsonInput
-
skip
public void skip(int numBytes)
Description copied from interface:BsonInput
Skips the specified number of bytes in the stream.
-
mark
@Deprecated public void mark(int readLimit)
Deprecated.Description copied from interface:BsonInput
Marks the current position in the stream. This method obeys the contract as specified in the same method inInputStream
.
-
getMark
public BsonInputMark getMark(int readLimit)
Description copied from interface:BsonInput
Gets a mark for the current position in the stream.
-
reset
@Deprecated public void reset()
Deprecated.Description copied from interface:BsonInput
Resets the stream to the current mark. This method obeys the contract as specified in the same method inInputStream
.
-
hasRemaining
public boolean hasRemaining()
Description copied from interface:BsonInput
Returns true if there are more bytes left in the stream.- Specified by:
hasRemaining
in interfaceBsonInput
- Returns:
- true if there are more bytes left in the stream.
-
-