Package org.bson
Class BsonDocumentReader
- java.lang.Object
-
- org.bson.AbstractBsonReader
-
- org.bson.BsonDocumentReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BsonReader
public class BsonDocumentReader extends AbstractBsonReader
ABsonReader
implementation that reads from an instance ofBsonDocument
. This can be used to decode aBsonDocument
using aDecoder
.- Since:
- 3.0
- See Also:
BsonDocument
,Decoder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BsonDocumentReader.Context
protected class
BsonDocumentReader.Mark
-
Nested classes/interfaces inherited from class org.bson.AbstractBsonReader
AbstractBsonReader.State
-
-
Constructor Summary
Constructors Constructor Description BsonDocumentReader(BsonDocument document)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected int
doPeekBinarySize()
Handles the logic to peek at the binary size.protected byte
doPeekBinarySubType()
Handles the logic to peek at the binary subtype.protected BsonBinary
doReadBinaryData()
Handles the logic to read binary dataprotected boolean
doReadBoolean()
Handles the logic to read booleansprotected long
doReadDateTime()
Handles the logic to read date timeprotected BsonDbPointer
doReadDBPointer()
Handles the logic to read a DBPointerDecimal128
doReadDecimal128()
Handles the logic to read Decimal128protected double
doReadDouble()
Handles the logic to read doublesprotected void
doReadEndArray()
Handles the logic when reading the end of an arrayprotected void
doReadEndDocument()
Handles the logic when reading the end of a documentprotected int
doReadInt32()
Handles the logic to read 32 bit intsprotected long
doReadInt64()
Handles the logic to read 64 bit intsprotected String
doReadJavaScript()
Handles the logic to read Javascript functionsprotected String
doReadJavaScriptWithScope()
Handles the logic to read scoped Javascript functionsprotected void
doReadMaxKey()
Handles the logic to read a Max keyprotected void
doReadMinKey()
Handles the logic to read a Min keyprotected void
doReadNull()
Handles the logic to read a null valueprotected ObjectId
doReadObjectId()
Handles the logic to read an ObjectIdprotected BsonRegularExpression
doReadRegularExpression()
Handles the logic to read a regular expressionprotected void
doReadStartArray()
Handles the logic to read the start of an arrayprotected void
doReadStartDocument()
Handles the logic to read the start of a documentprotected String
doReadString()
Handles the logic to read a Stringprotected String
doReadSymbol()
Handles the logic to read a Symbolprotected BsonTimestamp
doReadTimestamp()
Handles the logic to read a timestampprotected void
doReadUndefined()
Handles the logic to read an Undefined valueprotected void
doSkipName()
Handles any logic required to skip the name (reader must be positioned on a name).protected void
doSkipValue()
Handles any logic required to skip the value (reader must be positioned on a value).protected BsonDocumentReader.Context
getContext()
Get the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.BsonReaderMark
getMark()
Gets a mark representing the current state of the reader.void
mark()
Deprecated.BsonType
readBsonType()
Reads a BSONType from the reader.void
reset()
Deprecated.-
Methods inherited from class org.bson.AbstractBsonReader
checkPreconditions, close, getCurrentBsonType, getCurrentName, getNextState, getState, isClosed, peekBinarySize, peekBinarySubType, readBinaryData, readBinaryData, readBoolean, readBoolean, readDateTime, readDateTime, readDBPointer, readDBPointer, readDecimal128, readDecimal128, readDouble, readDouble, readEndArray, readEndDocument, readInt32, readInt32, readInt64, readInt64, readJavaScript, readJavaScript, readJavaScriptWithScope, readJavaScriptWithScope, readMaxKey, readMaxKey, readMinKey, readMinKey, readName, readName, readNull, readNull, readObjectId, readObjectId, readRegularExpression, readRegularExpression, readStartArray, readStartDocument, readString, readString, readSymbol, readSymbol, readTimestamp, readTimestamp, readUndefined, readUndefined, setContext, setCurrentBsonType, setCurrentName, setState, skipName, skipValue, throwInvalidContextType, throwInvalidState, verifyBSONType, verifyName
-
-
-
-
Constructor Detail
-
BsonDocumentReader
public BsonDocumentReader(BsonDocument document)
Construct a new instance.- Parameters:
document
- the document to read from
-
-
Method Detail
-
doReadBinaryData
protected BsonBinary doReadBinaryData()
Description copied from class:AbstractBsonReader
Handles the logic to read binary data- Specified by:
doReadBinaryData
in classAbstractBsonReader
- Returns:
- the BsonBinary value
-
doPeekBinarySubType
protected byte doPeekBinarySubType()
Description copied from class:AbstractBsonReader
Handles the logic to peek at the binary subtype.- Specified by:
doPeekBinarySubType
in classAbstractBsonReader
- Returns:
- the binary subtype
-
doPeekBinarySize
protected int doPeekBinarySize()
Description copied from class:AbstractBsonReader
Handles the logic to peek at the binary size.- Specified by:
doPeekBinarySize
in classAbstractBsonReader
- Returns:
- the binary size
-
doReadBoolean
protected boolean doReadBoolean()
Description copied from class:AbstractBsonReader
Handles the logic to read booleans- Specified by:
doReadBoolean
in classAbstractBsonReader
- Returns:
- the boolean value
-
doReadDateTime
protected long doReadDateTime()
Description copied from class:AbstractBsonReader
Handles the logic to read date time- Specified by:
doReadDateTime
in classAbstractBsonReader
- Returns:
- the long value
-
doReadDouble
protected double doReadDouble()
Description copied from class:AbstractBsonReader
Handles the logic to read doubles- Specified by:
doReadDouble
in classAbstractBsonReader
- Returns:
- the double value
-
doReadEndArray
protected void doReadEndArray()
Description copied from class:AbstractBsonReader
Handles the logic when reading the end of an array- Specified by:
doReadEndArray
in classAbstractBsonReader
-
doReadEndDocument
protected void doReadEndDocument()
Description copied from class:AbstractBsonReader
Handles the logic when reading the end of a document- Specified by:
doReadEndDocument
in classAbstractBsonReader
-
doReadInt32
protected int doReadInt32()
Description copied from class:AbstractBsonReader
Handles the logic to read 32 bit ints- Specified by:
doReadInt32
in classAbstractBsonReader
- Returns:
- the int value
-
doReadInt64
protected long doReadInt64()
Description copied from class:AbstractBsonReader
Handles the logic to read 64 bit ints- Specified by:
doReadInt64
in classAbstractBsonReader
- Returns:
- the long value
-
doReadDecimal128
public Decimal128 doReadDecimal128()
Description copied from class:AbstractBsonReader
Handles the logic to read Decimal128- Specified by:
doReadDecimal128
in classAbstractBsonReader
- Returns:
- the Decimal128 value
-
doReadJavaScript
protected String doReadJavaScript()
Description copied from class:AbstractBsonReader
Handles the logic to read Javascript functions- Specified by:
doReadJavaScript
in classAbstractBsonReader
- Returns:
- the String value
-
doReadJavaScriptWithScope
protected String doReadJavaScriptWithScope()
Description copied from class:AbstractBsonReader
Handles the logic to read scoped Javascript functions- Specified by:
doReadJavaScriptWithScope
in classAbstractBsonReader
- Returns:
- the String value
-
doReadMaxKey
protected void doReadMaxKey()
Description copied from class:AbstractBsonReader
Handles the logic to read a Max key- Specified by:
doReadMaxKey
in classAbstractBsonReader
-
doReadMinKey
protected void doReadMinKey()
Description copied from class:AbstractBsonReader
Handles the logic to read a Min key- Specified by:
doReadMinKey
in classAbstractBsonReader
-
doReadNull
protected void doReadNull()
Description copied from class:AbstractBsonReader
Handles the logic to read a null value- Specified by:
doReadNull
in classAbstractBsonReader
-
doReadObjectId
protected ObjectId doReadObjectId()
Description copied from class:AbstractBsonReader
Handles the logic to read an ObjectId- Specified by:
doReadObjectId
in classAbstractBsonReader
- Returns:
- the ObjectId value
-
doReadRegularExpression
protected BsonRegularExpression doReadRegularExpression()
Description copied from class:AbstractBsonReader
Handles the logic to read a regular expression- Specified by:
doReadRegularExpression
in classAbstractBsonReader
- Returns:
- the BsonRegularExpression value
-
doReadDBPointer
protected BsonDbPointer doReadDBPointer()
Description copied from class:AbstractBsonReader
Handles the logic to read a DBPointer- Specified by:
doReadDBPointer
in classAbstractBsonReader
- Returns:
- the BsonDbPointer value
-
doReadStartArray
protected void doReadStartArray()
Description copied from class:AbstractBsonReader
Handles the logic to read the start of an array- Specified by:
doReadStartArray
in classAbstractBsonReader
-
doReadStartDocument
protected void doReadStartDocument()
Description copied from class:AbstractBsonReader
Handles the logic to read the start of a document- Specified by:
doReadStartDocument
in classAbstractBsonReader
-
doReadString
protected String doReadString()
Description copied from class:AbstractBsonReader
Handles the logic to read a String- Specified by:
doReadString
in classAbstractBsonReader
- Returns:
- the String value
-
doReadSymbol
protected String doReadSymbol()
Description copied from class:AbstractBsonReader
Handles the logic to read a Symbol- Specified by:
doReadSymbol
in classAbstractBsonReader
- Returns:
- the String value
-
doReadTimestamp
protected BsonTimestamp doReadTimestamp()
Description copied from class:AbstractBsonReader
Handles the logic to read a timestamp- Specified by:
doReadTimestamp
in classAbstractBsonReader
- Returns:
- the BsonTimestamp value
-
doReadUndefined
protected void doReadUndefined()
Description copied from class:AbstractBsonReader
Handles the logic to read an Undefined value- Specified by:
doReadUndefined
in classAbstractBsonReader
-
doSkipName
protected void doSkipName()
Description copied from class:AbstractBsonReader
Handles any logic required to skip the name (reader must be positioned on a name).- Specified by:
doSkipName
in classAbstractBsonReader
-
doSkipValue
protected void doSkipValue()
Description copied from class:AbstractBsonReader
Handles any logic required to skip the value (reader must be positioned on a value).- Specified by:
doSkipValue
in classAbstractBsonReader
-
readBsonType
public BsonType readBsonType()
Description copied from interface:BsonReader
Reads a BSONType from the reader.- Specified by:
readBsonType
in interfaceBsonReader
- Specified by:
readBsonType
in classAbstractBsonReader
- Returns:
- A BSONType.
-
mark
@Deprecated public void mark()
Deprecated.Description copied from interface:BsonReader
Creates a bookmark in the BsonReader's input The previous mark must be cleared before creating a new one
-
getMark
public BsonReaderMark getMark()
Description copied from interface:BsonReader
Gets a mark representing the current state of the reader.- Returns:
- the mark
-
reset
@Deprecated public void reset()
Deprecated.Description copied from interface:BsonReader
Go back to the state at the last mark and removes the mark
-
getContext
protected BsonDocumentReader.Context getContext()
Description copied from class:AbstractBsonReader
Get the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.- Overrides:
getContext
in classAbstractBsonReader
- Returns:
- the context
-
-