Package org.bson.io
Interface BsonInput
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
ByteBufferBsonInput
public interface BsonInput extends java.io.Closeable
An input stream that is optimized for reading BSON values directly from the underlying stream.- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Abstract 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.UsegetMark(int)
insteadbyte
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.PrefergetMark(int)
void
skip(int numBytes)
Skips the specified number of bytes in the stream.void
skipCString()
Skips a BSON CString value from the stream.
-
-
-
Method Detail
-
getPosition
int getPosition()
Gets the current position in the stream- Returns:
- the current position
-
readByte
byte readByte()
Reads a single byte from the stream- Returns:
- the byte value
-
readBytes
void readBytes(byte[] bytes)
Reads the specified number of bytes into the given byte array. This is equivalent to toreadBytes(bytes, 0, bytes.length)
.- Parameters:
bytes
- the byte array to write into
-
readBytes
void readBytes(byte[] bytes, int offset, int length)
Reads the specified number of bytes into the given byte array starting at the specified offset.- Parameters:
bytes
- the byte array to write intooffset
- the offset to start writinglength
- the number of bytes to write
-
readInt64
long readInt64()
Reads a BSON Int64 value from the stream.- Returns:
- the Int64 value
-
readDouble
double readDouble()
Reads a BSON Double value from the stream.- Returns:
- the double value
-
readInt32
int readInt32()
Reads a BSON Int32 value from the stream.- Returns:
- the Int32 value
-
readString
java.lang.String readString()
Reads a BSON String value from the stream.- Returns:
- the string
-
readObjectId
ObjectId readObjectId()
Reads a BSON ObjectId value from the stream.- Returns:
- the ObjectId
-
readCString
java.lang.String readCString()
Reads a BSON CString value from the stream.- Returns:
- the CString
-
skipCString
void skipCString()
Skips a BSON CString value from the stream.
-
skip
void skip(int numBytes)
Skips the specified number of bytes in the stream.- Parameters:
numBytes
- the number of bytes to skip
-
mark
@Deprecated void mark(int readLimit)
Deprecated.UsegetMark(int)
insteadMarks the current position in the stream. This method obeys the contract as specified in the same method inInputStream
.- Parameters:
readLimit
- the maximum limit of bytes that can be read before the mark position becomes invalid
-
getMark
BsonInputMark getMark(int readLimit)
Gets a mark for the current position in the stream.- Parameters:
readLimit
- the maximum limit of bytes that can be read before the mark position becomes invalid- Returns:
- the mark
- Since:
- 3.7
-
reset
@Deprecated void reset()
Deprecated.PrefergetMark(int)
Resets the stream to the current mark. This method obeys the contract as specified in the same method inInputStream
.
-
hasRemaining
boolean hasRemaining()
Returns true if there are more bytes left in the stream.- Returns:
- true if there are more bytes left in the stream.
-
close
void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-