Package org.bson
Class AbstractBsonReader
- java.lang.Object
-
- org.bson.AbstractBsonReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,BsonReader
- Direct Known Subclasses:
BsonBinaryReader
,BsonDocumentReader
,JsonReader
public abstract class AbstractBsonReader extends Object implements BsonReader
Abstract base class for BsonReader implementations.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractBsonReader.Context
The context for the reader.protected class
AbstractBsonReader.Mark
static class
AbstractBsonReader.State
The state of a reader.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBsonReader()
Initializes a new instance of the BsonReader class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkPreconditions(String methodName, BsonType type)
Ensures any conditions are met before reading commences.void
close()
Closes the reader.protected abstract int
doPeekBinarySize()
Handles the logic to peek at the binary size.protected abstract byte
doPeekBinarySubType()
Handles the logic to peek at the binary subtype.protected abstract BsonBinary
doReadBinaryData()
Handles the logic to read binary dataprotected abstract boolean
doReadBoolean()
Handles the logic to read booleansprotected abstract long
doReadDateTime()
Handles the logic to read date timeprotected abstract BsonDbPointer
doReadDBPointer()
Handles the logic to read a DBPointerprotected abstract Decimal128
doReadDecimal128()
Handles the logic to read Decimal128protected abstract double
doReadDouble()
Handles the logic to read doublesprotected abstract void
doReadEndArray()
Handles the logic when reading the end of an arrayprotected abstract void
doReadEndDocument()
Handles the logic when reading the end of a documentprotected abstract int
doReadInt32()
Handles the logic to read 32 bit intsprotected abstract long
doReadInt64()
Handles the logic to read 64 bit intsprotected abstract String
doReadJavaScript()
Handles the logic to read Javascript functionsprotected abstract String
doReadJavaScriptWithScope()
Handles the logic to read scoped Javascript functionsprotected abstract void
doReadMaxKey()
Handles the logic to read a Max keyprotected abstract void
doReadMinKey()
Handles the logic to read a Min keyprotected abstract void
doReadNull()
Handles the logic to read a null valueprotected abstract ObjectId
doReadObjectId()
Handles the logic to read an ObjectIdprotected abstract BsonRegularExpression
doReadRegularExpression()
Handles the logic to read a regular expressionprotected abstract void
doReadStartArray()
Handles the logic to read the start of an arrayprotected abstract void
doReadStartDocument()
Handles the logic to read the start of a documentprotected abstract String
doReadString()
Handles the logic to read a Stringprotected abstract String
doReadSymbol()
Handles the logic to read a Symbolprotected abstract BsonTimestamp
doReadTimestamp()
Handles the logic to read a timestampprotected abstract void
doReadUndefined()
Handles the logic to read an Undefined valueprotected abstract void
doSkipName()
Handles any logic required to skip the name (reader must be positioned on a name).protected abstract void
doSkipValue()
Handles any logic required to skip the value (reader must be positioned on a value).protected AbstractBsonReader.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.BsonType
getCurrentBsonType()
String
getCurrentName()
Gets the most recently read name.protected AbstractBsonReader.State
getNextState()
Returns the nextState
to transition to, based on theAbstractBsonReader.Context
of this reader.AbstractBsonReader.State
getState()
protected boolean
isClosed()
Return true if the reader has been closed.int
peekBinarySize()
Peeks the size of the binary data that the reader is positioned at.byte
peekBinarySubType()
Peeks the subtype of the binary data that the reader is positioned at.BsonBinary
readBinaryData()
Reads BSON Binary data from the reader.BsonBinary
readBinaryData(String name)
Reads a BSON Binary data element from the reader.boolean
readBoolean()
Reads a BSON Boolean from the reader.boolean
readBoolean(String name)
Reads a BSON Boolean element from the reader.abstract BsonType
readBsonType()
Reads a BSONType from the reader.long
readDateTime()
Reads a BSON DateTime from the reader.long
readDateTime(String name)
Reads a BSON DateTime element from the reader.BsonDbPointer
readDBPointer()
Reads a BSON DBPointer from the reader.BsonDbPointer
readDBPointer(String name)
Reads a BSON DBPointer element from the reader.Decimal128
readDecimal128()
Reads a BSON Decimal128 from the reader.Decimal128
readDecimal128(String name)
Reads a BSON Decimal128 element from the reader.double
readDouble()
Reads a BSON Double from the reader.double
readDouble(String name)
Reads a BSON Double element from the reader.void
readEndArray()
Reads the end of a BSON array from the reader.void
readEndDocument()
Reads the end of a BSON document from the reader.int
readInt32()
Reads a BSON Int32 from the reader.int
readInt32(String name)
Reads a BSON Int32 element from the reader.long
readInt64()
Reads a BSON Int64 from the reader.long
readInt64(String name)
Reads a BSON Int64 element from the reader.String
readJavaScript()
Reads a BSON JavaScript from the reader.String
readJavaScript(String name)
Reads a BSON JavaScript element from the reader.String
readJavaScriptWithScope()
Reads a BSON JavaScript with scope from the reader (call readStartDocument next to read the scope).String
readJavaScriptWithScope(String name)
Reads a BSON JavaScript with scope element from the reader (call readStartDocument next to read the scope).void
readMaxKey()
Reads a BSON MaxKey from the reader.void
readMaxKey(String name)
Reads a BSON MaxKey element from the reader.void
readMinKey()
Reads a BSON MinKey from the reader.void
readMinKey(String name)
Reads a BSON MinKey element from the reader.String
readName()
Reads the name of an element from the reader.void
readName(String name)
Reads the name of an element from the reader.void
readNull()
Reads a BSON null from the reader.void
readNull(String name)
Reads a BSON null element from the reader.ObjectId
readObjectId()
Reads a BSON ObjectId from the reader.ObjectId
readObjectId(String name)
Reads a BSON ObjectId element from the reader.BsonRegularExpression
readRegularExpression()
Reads a BSON regular expression from the reader.BsonRegularExpression
readRegularExpression(String name)
Reads a BSON regular expression element from the reader.void
readStartArray()
Reads the start of a BSON array.void
readStartDocument()
Reads the start of a BSON document.String
readString()
Reads a BSON String from the reader.String
readString(String name)
Reads a BSON string element from the reader.String
readSymbol()
Reads a BSON symbol from the reader.String
readSymbol(String name)
Reads a BSON symbol element from the reader.BsonTimestamp
readTimestamp()
Reads a BSON timestamp from the reader.BsonTimestamp
readTimestamp(String name)
Reads a BSON timestamp element from the reader.void
readUndefined()
Reads a BSON undefined from the reader.void
readUndefined(String name)
Reads a BSON undefined element from the reader.protected void
setContext(AbstractBsonReader.Context context)
Set the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.protected void
setCurrentBsonType(BsonType newType)
Sets the type of the current value being read.protected void
setCurrentName(String newName)
Sets the field name for the key/value pair being read.protected void
setState(AbstractBsonReader.State newState)
Sets the new current state of this reader.void
skipName()
Skips the name (reader must be positioned on a name).void
skipValue()
Skips the value (reader must be positioned on a value).protected void
throwInvalidContextType(String methodName, BsonContextType actualContextType, BsonContextType... validContextTypes)
Throws an InvalidOperationException when the method called is not valid for the current ContextType.protected void
throwInvalidState(String methodName, AbstractBsonReader.State... validStates)
Throws an InvalidOperationException when the method called is not valid for the current state.protected void
verifyBSONType(String methodName, BsonType requiredBsonType)
Verifies the current state and BSONType of the reader.protected void
verifyName(String expectedName)
Verifies the name of the current element.-
Methods inherited from interface org.bson.BsonReader
getMark, mark, reset
-
-
-
-
Method Detail
-
getCurrentBsonType
public BsonType getCurrentBsonType()
- Specified by:
getCurrentBsonType
in interfaceBsonReader
- Returns:
- The current BsonType.
-
getCurrentName
public String getCurrentName()
Description copied from interface:BsonReader
Gets the most recently read name.- Specified by:
getCurrentName
in interfaceBsonReader
- Returns:
- the most recently read name
-
setCurrentBsonType
protected void setCurrentBsonType(BsonType newType)
Sets the type of the current value being read.- Parameters:
newType
- the BSON Type.
-
getState
public AbstractBsonReader.State getState()
- Returns:
- The current state of the reader.
-
setState
protected void setState(AbstractBsonReader.State newState)
Sets the new current state of this reader.- Parameters:
newState
- the state to set this reader to.
-
setCurrentName
protected void setCurrentName(String newName)
Sets the field name for the key/value pair being read.- Parameters:
newName
- the field name
-
close
public void close()
Closes the reader.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBsonReader
- Specified by:
close
in interfaceCloseable
-
isClosed
protected boolean isClosed()
Return true if the reader has been closed.- Returns:
- true if closed
-
doReadBinaryData
protected abstract BsonBinary doReadBinaryData()
Handles the logic to read binary data- Returns:
- the BsonBinary value
-
doPeekBinarySubType
protected abstract byte doPeekBinarySubType()
Handles the logic to peek at the binary subtype.- Returns:
- the binary subtype
-
doPeekBinarySize
protected abstract int doPeekBinarySize()
Handles the logic to peek at the binary size.- Returns:
- the binary size
- Since:
- 3.4
-
doReadBoolean
protected abstract boolean doReadBoolean()
Handles the logic to read booleans- Returns:
- the boolean value
-
doReadDateTime
protected abstract long doReadDateTime()
Handles the logic to read date time- Returns:
- the long value
-
doReadDouble
protected abstract double doReadDouble()
Handles the logic to read doubles- Returns:
- the double value
-
doReadEndArray
protected abstract void doReadEndArray()
Handles the logic when reading the end of an array
-
doReadEndDocument
protected abstract void doReadEndDocument()
Handles the logic when reading the end of a document
-
doReadInt32
protected abstract int doReadInt32()
Handles the logic to read 32 bit ints- Returns:
- the int value
-
doReadInt64
protected abstract long doReadInt64()
Handles the logic to read 64 bit ints- Returns:
- the long value
-
doReadDecimal128
protected abstract Decimal128 doReadDecimal128()
Handles the logic to read Decimal128- Returns:
- the Decimal128 value
- Since:
- 3.4
-
doReadJavaScript
protected abstract String doReadJavaScript()
Handles the logic to read Javascript functions- Returns:
- the String value
-
doReadJavaScriptWithScope
protected abstract String doReadJavaScriptWithScope()
Handles the logic to read scoped Javascript functions- Returns:
- the String value
-
doReadMaxKey
protected abstract void doReadMaxKey()
Handles the logic to read a Max key
-
doReadMinKey
protected abstract void doReadMinKey()
Handles the logic to read a Min key
-
doReadNull
protected abstract void doReadNull()
Handles the logic to read a null value
-
doReadObjectId
protected abstract ObjectId doReadObjectId()
Handles the logic to read an ObjectId- Returns:
- the ObjectId value
-
doReadRegularExpression
protected abstract BsonRegularExpression doReadRegularExpression()
Handles the logic to read a regular expression- Returns:
- the BsonRegularExpression value
-
doReadDBPointer
protected abstract BsonDbPointer doReadDBPointer()
Handles the logic to read a DBPointer- Returns:
- the BsonDbPointer value
-
doReadStartArray
protected abstract void doReadStartArray()
Handles the logic to read the start of an array
-
doReadStartDocument
protected abstract void doReadStartDocument()
Handles the logic to read the start of a document
-
doReadString
protected abstract String doReadString()
Handles the logic to read a String- Returns:
- the String value
-
doReadSymbol
protected abstract String doReadSymbol()
Handles the logic to read a Symbol- Returns:
- the String value
-
doReadTimestamp
protected abstract BsonTimestamp doReadTimestamp()
Handles the logic to read a timestamp- Returns:
- the BsonTimestamp value
-
doReadUndefined
protected abstract void doReadUndefined()
Handles the logic to read an Undefined value
-
doSkipName
protected abstract void doSkipName()
Handles any logic required to skip the name (reader must be positioned on a name).
-
doSkipValue
protected abstract void doSkipValue()
Handles any logic required to skip the value (reader must be positioned on a value).
-
readBinaryData
public BsonBinary readBinaryData()
Description copied from interface:BsonReader
Reads BSON Binary data from the reader.- Specified by:
readBinaryData
in interfaceBsonReader
- Returns:
- A Binary.
-
peekBinarySubType
public byte peekBinarySubType()
Description copied from interface:BsonReader
Peeks the subtype of the binary data that the reader is positioned at. This operation is not permitted if the mark is already set.- Specified by:
peekBinarySubType
in interfaceBsonReader
- Returns:
- the subtype
- See Also:
BsonReader.mark()
-
peekBinarySize
public int peekBinarySize()
Description copied from interface:BsonReader
Peeks the size of the binary data that the reader is positioned at. This operation is not permitted if the mark is already set.- Specified by:
peekBinarySize
in interfaceBsonReader
- Returns:
- the size of the binary data
- See Also:
BsonReader.mark()
-
readBoolean
public boolean readBoolean()
Description copied from interface:BsonReader
Reads a BSON Boolean from the reader.- Specified by:
readBoolean
in interfaceBsonReader
- Returns:
- A Boolean.
-
readBsonType
public abstract BsonType readBsonType()
Description copied from interface:BsonReader
Reads a BSONType from the reader.- Specified by:
readBsonType
in interfaceBsonReader
- Returns:
- A BSONType.
-
readDateTime
public long readDateTime()
Description copied from interface:BsonReader
Reads a BSON DateTime from the reader.- Specified by:
readDateTime
in interfaceBsonReader
- Returns:
- The number of milliseconds since the Unix epoch.
-
readDouble
public double readDouble()
Description copied from interface:BsonReader
Reads a BSON Double from the reader.- Specified by:
readDouble
in interfaceBsonReader
- Returns:
- A Double.
-
readEndArray
public void readEndArray()
Description copied from interface:BsonReader
Reads the end of a BSON array from the reader.- Specified by:
readEndArray
in interfaceBsonReader
-
readEndDocument
public void readEndDocument()
Description copied from interface:BsonReader
Reads the end of a BSON document from the reader.- Specified by:
readEndDocument
in interfaceBsonReader
-
readInt32
public int readInt32()
Description copied from interface:BsonReader
Reads a BSON Int32 from the reader.- Specified by:
readInt32
in interfaceBsonReader
- Returns:
- An Int32.
-
readInt64
public long readInt64()
Description copied from interface:BsonReader
Reads a BSON Int64 from the reader.- Specified by:
readInt64
in interfaceBsonReader
- Returns:
- An Int64.
-
readDecimal128
public Decimal128 readDecimal128()
Description copied from interface:BsonReader
Reads a BSON Decimal128 from the reader.- Specified by:
readDecimal128
in interfaceBsonReader
- Returns:
- A Decimal128
-
readJavaScript
public String readJavaScript()
Description copied from interface:BsonReader
Reads a BSON JavaScript from the reader.- Specified by:
readJavaScript
in interfaceBsonReader
- Returns:
- A string.
-
readJavaScriptWithScope
public String readJavaScriptWithScope()
Description copied from interface:BsonReader
Reads a BSON JavaScript with scope from the reader (call readStartDocument next to read the scope).- Specified by:
readJavaScriptWithScope
in interfaceBsonReader
- Returns:
- A string.
-
readMaxKey
public void readMaxKey()
Description copied from interface:BsonReader
Reads a BSON MaxKey from the reader.- Specified by:
readMaxKey
in interfaceBsonReader
-
readMinKey
public void readMinKey()
Description copied from interface:BsonReader
Reads a BSON MinKey from the reader.- Specified by:
readMinKey
in interfaceBsonReader
-
readNull
public void readNull()
Description copied from interface:BsonReader
Reads a BSON null from the reader.- Specified by:
readNull
in interfaceBsonReader
-
readObjectId
public ObjectId readObjectId()
Description copied from interface:BsonReader
Reads a BSON ObjectId from the reader.- Specified by:
readObjectId
in interfaceBsonReader
- Returns:
- the
ObjectId
value
-
readRegularExpression
public BsonRegularExpression readRegularExpression()
Description copied from interface:BsonReader
Reads a BSON regular expression from the reader.- Specified by:
readRegularExpression
in interfaceBsonReader
- Returns:
- A regular expression.
-
readDBPointer
public BsonDbPointer readDBPointer()
Description copied from interface:BsonReader
Reads a BSON DBPointer from the reader.- Specified by:
readDBPointer
in interfaceBsonReader
- Returns:
- A DBPointer.
-
readStartArray
public void readStartArray()
Description copied from interface:BsonReader
Reads the start of a BSON array.- Specified by:
readStartArray
in interfaceBsonReader
-
readStartDocument
public void readStartDocument()
Description copied from interface:BsonReader
Reads the start of a BSON document.- Specified by:
readStartDocument
in interfaceBsonReader
-
readString
public String readString()
Description copied from interface:BsonReader
Reads a BSON String from the reader.- Specified by:
readString
in interfaceBsonReader
- Returns:
- A String.
-
readSymbol
public String readSymbol()
Description copied from interface:BsonReader
Reads a BSON symbol from the reader.- Specified by:
readSymbol
in interfaceBsonReader
- Returns:
- A string.
-
readTimestamp
public BsonTimestamp readTimestamp()
Description copied from interface:BsonReader
Reads a BSON timestamp from the reader.- Specified by:
readTimestamp
in interfaceBsonReader
- Returns:
- The combined timestamp/increment.
-
readUndefined
public void readUndefined()
Description copied from interface:BsonReader
Reads a BSON undefined from the reader.- Specified by:
readUndefined
in interfaceBsonReader
-
skipName
public void skipName()
Description copied from interface:BsonReader
Skips the name (reader must be positioned on a name).- Specified by:
skipName
in interfaceBsonReader
-
skipValue
public void skipValue()
Description copied from interface:BsonReader
Skips the value (reader must be positioned on a value).- Specified by:
skipValue
in interfaceBsonReader
-
readBinaryData
public BsonBinary readBinaryData(String name)
Description copied from interface:BsonReader
Reads a BSON Binary data element from the reader.- Specified by:
readBinaryData
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A Binary.
-
readBoolean
public boolean readBoolean(String name)
Description copied from interface:BsonReader
Reads a BSON Boolean element from the reader.- Specified by:
readBoolean
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A Boolean.
-
readDateTime
public long readDateTime(String name)
Description copied from interface:BsonReader
Reads a BSON DateTime element from the reader.- Specified by:
readDateTime
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- The number of milliseconds since the Unix epoch.
-
readDouble
public double readDouble(String name)
Description copied from interface:BsonReader
Reads a BSON Double element from the reader.- Specified by:
readDouble
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A Double.
-
readInt32
public int readInt32(String name)
Description copied from interface:BsonReader
Reads a BSON Int32 element from the reader.- Specified by:
readInt32
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- An Int32.
-
readInt64
public long readInt64(String name)
Description copied from interface:BsonReader
Reads a BSON Int64 element from the reader.- Specified by:
readInt64
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- An Int64.
-
readDecimal128
public Decimal128 readDecimal128(String name)
Description copied from interface:BsonReader
Reads a BSON Decimal128 element from the reader.- Specified by:
readDecimal128
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A Decimal128
-
readJavaScript
public String readJavaScript(String name)
Description copied from interface:BsonReader
Reads a BSON JavaScript element from the reader.- Specified by:
readJavaScript
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A string.
-
readJavaScriptWithScope
public String readJavaScriptWithScope(String name)
Description copied from interface:BsonReader
Reads a BSON JavaScript with scope element from the reader (call readStartDocument next to read the scope).- Specified by:
readJavaScriptWithScope
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A string.
-
readMaxKey
public void readMaxKey(String name)
Description copied from interface:BsonReader
Reads a BSON MaxKey element from the reader.- Specified by:
readMaxKey
in interfaceBsonReader
- Parameters:
name
- The name of the element.
-
readMinKey
public void readMinKey(String name)
Description copied from interface:BsonReader
Reads a BSON MinKey element from the reader.- Specified by:
readMinKey
in interfaceBsonReader
- Parameters:
name
- The name of the element.
-
readName
public String readName()
Description copied from interface:BsonReader
Reads the name of an element from the reader.- Specified by:
readName
in interfaceBsonReader
- Returns:
- The name of the element.
-
readName
public void readName(String name)
Description copied from interface:BsonReader
Reads the name of an element from the reader.- Specified by:
readName
in interfaceBsonReader
- Parameters:
name
- The name of the element.
-
readNull
public void readNull(String name)
Description copied from interface:BsonReader
Reads a BSON null element from the reader.- Specified by:
readNull
in interfaceBsonReader
- Parameters:
name
- The name of the element.
-
readObjectId
public ObjectId readObjectId(String name)
Description copied from interface:BsonReader
Reads a BSON ObjectId element from the reader.- Specified by:
readObjectId
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- ObjectId.
-
readRegularExpression
public BsonRegularExpression readRegularExpression(String name)
Description copied from interface:BsonReader
Reads a BSON regular expression element from the reader.- Specified by:
readRegularExpression
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A regular expression.
-
readDBPointer
public BsonDbPointer readDBPointer(String name)
Description copied from interface:BsonReader
Reads a BSON DBPointer element from the reader.- Specified by:
readDBPointer
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A DBPointer.
-
readString
public String readString(String name)
Description copied from interface:BsonReader
Reads a BSON string element from the reader.- Specified by:
readString
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A String.
-
readSymbol
public String readSymbol(String name)
Description copied from interface:BsonReader
Reads a BSON symbol element from the reader.- Specified by:
readSymbol
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- A string.
-
readTimestamp
public BsonTimestamp readTimestamp(String name)
Description copied from interface:BsonReader
Reads a BSON timestamp element from the reader.- Specified by:
readTimestamp
in interfaceBsonReader
- Parameters:
name
- The name of the element.- Returns:
- The combined timestamp/increment.
-
readUndefined
public void readUndefined(String name)
Description copied from interface:BsonReader
Reads a BSON undefined element from the reader.- Specified by:
readUndefined
in interfaceBsonReader
- Parameters:
name
- The name of the element.
-
throwInvalidContextType
protected void throwInvalidContextType(String methodName, BsonContextType actualContextType, BsonContextType... validContextTypes)
Throws an InvalidOperationException when the method called is not valid for the current ContextType.- Parameters:
methodName
- The name of the method.actualContextType
- The actual ContextType.validContextTypes
- The valid ContextTypes.- Throws:
BsonInvalidOperationException
- when the method called is not valid for the current ContextType.
-
throwInvalidState
protected void throwInvalidState(String methodName, AbstractBsonReader.State... validStates)
Throws an InvalidOperationException when the method called is not valid for the current state.- Parameters:
methodName
- The name of the method.validStates
- The valid states.- Throws:
BsonInvalidOperationException
- when the method called is not valid for the current state.
-
verifyBSONType
protected void verifyBSONType(String methodName, BsonType requiredBsonType)
Verifies the current state and BSONType of the reader.- Parameters:
methodName
- The name of the method calling this one.requiredBsonType
- The required BSON type.
-
verifyName
protected void verifyName(String expectedName)
Verifies the name of the current element.- Parameters:
expectedName
- The expected name.- Throws:
BsonSerializationException
- when the name read is not the expected name
-
checkPreconditions
protected void checkPreconditions(String methodName, BsonType type)
Ensures any conditions are met before reading commences. Throws exceptions if the conditions are not met.- Parameters:
methodName
- the name of the current method, which will indicate the field being readtype
- the type of this field
-
getContext
protected AbstractBsonReader.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.- Returns:
- the context
-
setContext
protected void setContext(AbstractBsonReader.Context context)
Set the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.- Parameters:
context
- the current context.
-
getNextState
protected AbstractBsonReader.State getNextState()
Returns the nextState
to transition to, based on theAbstractBsonReader.Context
of this reader.- Returns:
- the next state
-
-