public abstract class AbstractBsonReader extends Object implements Closeable, BsonReader
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractBsonReader.Context
The context for the reader.
|
protected class |
AbstractBsonReader.Mark |
static class |
AbstractBsonReader.State
The state of a reader.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractBsonReader()
Initializes a new instance of the BsonReader class.
|
Modifier and Type | Method and 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 data
|
protected abstract boolean |
doReadBoolean()
Handles the logic to read booleans
|
protected abstract long |
doReadDateTime()
Handles the logic to read date time
|
protected abstract BsonDbPointer |
doReadDBPointer()
Handles the logic to read a DBPointer
|
protected abstract Decimal128 |
doReadDecimal128()
Handles the logic to read Decimal128
|
protected abstract double |
doReadDouble()
Handles the logic to read doubles
|
protected abstract void |
doReadEndArray()
Handles the logic when reading the end of an array
|
protected abstract void |
doReadEndDocument()
Handles the logic when reading the end of a document
|
protected abstract int |
doReadInt32()
Handles the logic to read 32 bit ints
|
protected abstract long |
doReadInt64()
Handles the logic to read 64 bit ints
|
protected abstract String |
doReadJavaScript()
Handles the logic to read Javascript functions
|
protected abstract String |
doReadJavaScriptWithScope()
Handles the logic to read scoped Javascript functions
|
protected abstract void |
doReadMaxKey()
Handles the logic to read a Max key
|
protected abstract void |
doReadMinKey()
Handles the logic to read a Min key
|
protected abstract void |
doReadNull()
Handles the logic to read a null value
|
protected abstract ObjectId |
doReadObjectId()
Handles the logic to read an ObjectId
|
protected abstract BsonRegularExpression |
doReadRegularExpression()
Handles the logic to read a regular expression
|
protected abstract void |
doReadStartArray()
Handles the logic to read the start of an array
|
protected abstract void |
doReadStartDocument()
Handles the logic to read the start of a document
|
protected abstract String |
doReadString()
Handles the logic to read a String
|
protected abstract String |
doReadSymbol()
Handles the logic to read a Symbol
|
protected abstract BsonTimestamp |
doReadTimestamp()
Handles the logic to read a timestamp
|
protected abstract void |
doReadUndefined()
Handles the logic to read an Undefined value
|
protected 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 next
State to transition to, based on the AbstractBsonReader.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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMark, mark, reset
protected AbstractBsonReader()
public BsonType getCurrentBsonType()
getCurrentBsonType
in interface BsonReader
public String getCurrentName()
BsonReader
getCurrentName
in interface BsonReader
protected void setCurrentBsonType(BsonType newType)
newType
- the BSON Type.public AbstractBsonReader.State getState()
protected void setState(AbstractBsonReader.State newState)
newState
- the state to set this reader to.protected void setCurrentName(String newName)
newName
- the field namepublic void close()
close
in interface Closeable
close
in interface AutoCloseable
protected boolean isClosed()
protected abstract BsonBinary doReadBinaryData()
protected abstract byte doPeekBinarySubType()
protected abstract int doPeekBinarySize()
protected abstract boolean doReadBoolean()
protected abstract long doReadDateTime()
protected abstract double doReadDouble()
protected abstract void doReadEndArray()
protected abstract void doReadEndDocument()
protected abstract int doReadInt32()
protected abstract long doReadInt64()
protected abstract Decimal128 doReadDecimal128()
protected abstract String doReadJavaScript()
protected abstract String doReadJavaScriptWithScope()
protected abstract void doReadMaxKey()
protected abstract void doReadMinKey()
protected abstract void doReadNull()
protected abstract ObjectId doReadObjectId()
protected abstract BsonRegularExpression doReadRegularExpression()
protected abstract BsonDbPointer doReadDBPointer()
protected abstract void doReadStartArray()
protected abstract void doReadStartDocument()
protected abstract String doReadString()
protected abstract String doReadSymbol()
protected abstract BsonTimestamp doReadTimestamp()
protected abstract void doReadUndefined()
protected abstract void doSkipName()
protected abstract void doSkipValue()
public BsonBinary readBinaryData()
BsonReader
readBinaryData
in interface BsonReader
public byte peekBinarySubType()
BsonReader
peekBinarySubType
in interface BsonReader
BsonReader.mark()
public int peekBinarySize()
BsonReader
peekBinarySize
in interface BsonReader
BsonReader.mark()
public boolean readBoolean()
BsonReader
readBoolean
in interface BsonReader
public abstract BsonType readBsonType()
BsonReader
readBsonType
in interface BsonReader
public long readDateTime()
BsonReader
readDateTime
in interface BsonReader
public double readDouble()
BsonReader
readDouble
in interface BsonReader
public void readEndArray()
BsonReader
readEndArray
in interface BsonReader
public void readEndDocument()
BsonReader
readEndDocument
in interface BsonReader
public int readInt32()
BsonReader
readInt32
in interface BsonReader
public long readInt64()
BsonReader
readInt64
in interface BsonReader
public Decimal128 readDecimal128()
BsonReader
readDecimal128
in interface BsonReader
public String readJavaScript()
BsonReader
readJavaScript
in interface BsonReader
public String readJavaScriptWithScope()
BsonReader
readJavaScriptWithScope
in interface BsonReader
public void readMaxKey()
BsonReader
readMaxKey
in interface BsonReader
public void readMinKey()
BsonReader
readMinKey
in interface BsonReader
public void readNull()
BsonReader
readNull
in interface BsonReader
public ObjectId readObjectId()
BsonReader
readObjectId
in interface BsonReader
ObjectId
valuepublic BsonRegularExpression readRegularExpression()
BsonReader
readRegularExpression
in interface BsonReader
public BsonDbPointer readDBPointer()
BsonReader
readDBPointer
in interface BsonReader
public void readStartArray()
BsonReader
readStartArray
in interface BsonReader
public void readStartDocument()
BsonReader
readStartDocument
in interface BsonReader
public String readString()
BsonReader
readString
in interface BsonReader
public String readSymbol()
BsonReader
readSymbol
in interface BsonReader
public BsonTimestamp readTimestamp()
BsonReader
readTimestamp
in interface BsonReader
public void readUndefined()
BsonReader
readUndefined
in interface BsonReader
public void skipName()
BsonReader
skipName
in interface BsonReader
public void skipValue()
BsonReader
skipValue
in interface BsonReader
public BsonBinary readBinaryData(String name)
BsonReader
readBinaryData
in interface BsonReader
name
- The name of the element.public boolean readBoolean(String name)
BsonReader
readBoolean
in interface BsonReader
name
- The name of the element.public long readDateTime(String name)
BsonReader
readDateTime
in interface BsonReader
name
- The name of the element.public double readDouble(String name)
BsonReader
readDouble
in interface BsonReader
name
- The name of the element.public int readInt32(String name)
BsonReader
readInt32
in interface BsonReader
name
- The name of the element.public long readInt64(String name)
BsonReader
readInt64
in interface BsonReader
name
- The name of the element.public Decimal128 readDecimal128(String name)
BsonReader
readDecimal128
in interface BsonReader
name
- The name of the element.public String readJavaScript(String name)
BsonReader
readJavaScript
in interface BsonReader
name
- The name of the element.public String readJavaScriptWithScope(String name)
BsonReader
readJavaScriptWithScope
in interface BsonReader
name
- The name of the element.public void readMaxKey(String name)
BsonReader
readMaxKey
in interface BsonReader
name
- The name of the element.public void readMinKey(String name)
BsonReader
readMinKey
in interface BsonReader
name
- The name of the element.public String readName()
BsonReader
readName
in interface BsonReader
public void readName(String name)
BsonReader
readName
in interface BsonReader
name
- The name of the element.public void readNull(String name)
BsonReader
readNull
in interface BsonReader
name
- The name of the element.public ObjectId readObjectId(String name)
BsonReader
readObjectId
in interface BsonReader
name
- The name of the element.public BsonRegularExpression readRegularExpression(String name)
BsonReader
readRegularExpression
in interface BsonReader
name
- The name of the element.public BsonDbPointer readDBPointer(String name)
BsonReader
readDBPointer
in interface BsonReader
name
- The name of the element.public String readString(String name)
BsonReader
readString
in interface BsonReader
name
- The name of the element.public String readSymbol(String name)
BsonReader
readSymbol
in interface BsonReader
name
- The name of the element.public BsonTimestamp readTimestamp(String name)
BsonReader
readTimestamp
in interface BsonReader
name
- The name of the element.public void readUndefined(String name)
BsonReader
readUndefined
in interface BsonReader
name
- The name of the element.protected void throwInvalidContextType(String methodName, BsonContextType actualContextType, BsonContextType... validContextTypes)
methodName
- The name of the method.actualContextType
- The actual ContextType.validContextTypes
- The valid ContextTypes.BsonInvalidOperationException
- when the method called is not valid for the current ContextType.protected void throwInvalidState(String methodName, AbstractBsonReader.State... validStates)
methodName
- The name of the method.validStates
- The valid states.BsonInvalidOperationException
- when the method called is not valid for the current state.protected void verifyBSONType(String methodName, BsonType requiredBsonType)
methodName
- The name of the method calling this one.requiredBsonType
- The required BSON type.protected void verifyName(String expectedName)
expectedName
- The expected name.BsonSerializationException
- when the name read is not the expected nameprotected void checkPreconditions(String methodName, BsonType type)
methodName
- the name of the current method, which will indicate the field being readtype
- the type of this fieldprotected AbstractBsonReader.Context getContext()
protected void setContext(AbstractBsonReader.Context context)
context
- the current context.protected AbstractBsonReader.State getNextState()
State
to transition to, based on the AbstractBsonReader.Context
of this reader.