@Internal public final class BsonReaderDecoder extends AbstractStreamDecoder
Decoder
.AbstractStreamDecoder.TokenType, AbstractStreamDecoder.ValueDecoder<R>
Constructor and Description |
---|
BsonReaderDecoder(org.bson.BsonReader bsonReader) |
Modifier and Type | Method and Description |
---|---|
protected void |
backFromChild(AbstractStreamDecoder child)
Called when the old child has finished processing and returns control of the stream to the parent.
|
protected java.lang.String |
coerceScalarToString()
Decode any non-null scalar value (number, string or boolean) to its string representation.
|
protected AbstractStreamDecoder |
createChildDecoder()
Create a new child decoder using
AbstractStreamDecoder(AbstractStreamDecoder) . |
java.io.IOException |
createDeserializationException(java.lang.String message,
java.lang.Object invalidValue)
Creates an exception for the given message.
|
protected AbstractStreamDecoder.TokenType |
currentToken() |
Decoder |
decodeBuffer()
Buffer the whole subtree of this value and return it as a new
Decoder . |
<T> T |
decodeCustom(org.bson.codecs.Decoder<T> decoder,
org.bson.codecs.DecoderContext context) |
org.bson.types.Decimal128 |
decodeDecimal128()
Decodes
Decimal128 . |
org.bson.types.ObjectId |
decodeObjectId()
Decodes
ObjectId . |
protected java.lang.Number |
getBestNumber()
Decode the current
AbstractStreamDecoder.TokenType.NUMBER value as a Number value. |
protected java.math.BigDecimal |
getBigDecimal()
Decode the current
AbstractStreamDecoder.TokenType.NUMBER value as a BigDecimal value. |
protected java.math.BigInteger |
getBigInteger()
Decode the current
AbstractStreamDecoder.TokenType.NUMBER value as a BigInteger value. |
protected boolean |
getBoolean()
Decode the current
AbstractStreamDecoder.TokenType.BOOLEAN value. |
protected java.lang.String |
getCurrentKey()
Get the current object field name.
|
protected double |
getDouble()
Decode the current
AbstractStreamDecoder.TokenType.NUMBER value as a double value. |
protected long |
getLong()
Decode the current
AbstractStreamDecoder.TokenType.NUMBER value as a long value. |
protected void |
nextToken()
Move to the next token.
|
protected void |
skipChildren()
If we are at a
AbstractStreamDecoder.TokenType.START_OBJECT or AbstractStreamDecoder.TokenType.START_ARRAY , skip to the matching
AbstractStreamDecoder.TokenType.END_OBJECT or AbstractStreamDecoder.TokenType.END_ARRAY . |
decodeArbitrary, decodeArray, decodeBigDecimal, decodeBigInteger, decodeBoolean, decodeByte, decodeChar, decodeCustom, decodeCustom, decodeDouble, decodeFloat, decodeInt, decodeKey, decodeLong, decodeNull, decodeNumber, decodeObject, decodeShort, decodeString, finishStructure, getBestNumberNode, getInteger, hasNextArrayValue, skipValue, unexpectedToken
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, decodeArray, decodeObject
protected void backFromChild(AbstractStreamDecoder child) throws java.io.IOException
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.END_ARRAY
or AbstractStreamDecoder.TokenType.END_OBJECT
. However we AbstractStreamDecoder.currentToken()
may hold an outdated value until AbstractStreamDecoder.nextToken()
is called, which this method does.backFromChild
in class AbstractStreamDecoder
child
- The now-invalid child decoder.java.io.IOException
- if an unrecoverable error occursprotected void nextToken()
AbstractStreamDecoder
nextToken
in class AbstractStreamDecoder
protected java.lang.String getCurrentKey()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.KEY
.getCurrentKey
in class AbstractStreamDecoder
protected java.lang.String coerceScalarToString() throws java.io.IOException
AbstractStreamDecoder
coerceScalarToString
in class AbstractStreamDecoder
java.io.IOException
- if an unrecoverable error occursprotected AbstractStreamDecoder createChildDecoder()
AbstractStreamDecoder
AbstractStreamDecoder(AbstractStreamDecoder)
.createChildDecoder
in class AbstractStreamDecoder
protected boolean getBoolean()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.BOOLEAN
value. Called for no other token type.getBoolean
in class AbstractStreamDecoder
protected long getLong()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.NUMBER
value as a long value. Called for no other token type.getLong
in class AbstractStreamDecoder
protected double getDouble()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.NUMBER
value as a double value. Called for no other token type.getDouble
in class AbstractStreamDecoder
protected java.math.BigInteger getBigInteger()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.NUMBER
value as a BigInteger
value. Called for no other token type.getBigInteger
in class AbstractStreamDecoder
protected java.math.BigDecimal getBigDecimal()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.NUMBER
value as a BigDecimal
value. Called for no other token type.getBigDecimal
in class AbstractStreamDecoder
protected java.lang.Number getBestNumber()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.NUMBER
value as a Number
value. Called for no other token type.getBestNumber
in class AbstractStreamDecoder
protected void skipChildren()
AbstractStreamDecoder
AbstractStreamDecoder.TokenType.START_OBJECT
or AbstractStreamDecoder.TokenType.START_ARRAY
, skip to the matching
AbstractStreamDecoder.TokenType.END_OBJECT
or AbstractStreamDecoder.TokenType.END_ARRAY
. Else, do nothing.skipChildren
in class AbstractStreamDecoder
protected AbstractStreamDecoder.TokenType currentToken()
currentToken
in class AbstractStreamDecoder
public java.io.IOException createDeserializationException(java.lang.String message, java.lang.Object invalidValue)
Decoder
message
- The message, never null
invalidValue
- The invalid value. Can be null
.null
public org.bson.types.Decimal128 decodeDecimal128() throws java.io.IOException
Decimal128
.java.io.IOException
public org.bson.types.ObjectId decodeObjectId() throws java.io.IOException
ObjectId
.java.io.IOException
public <T> T decodeCustom(org.bson.codecs.Decoder<T> decoder, org.bson.codecs.DecoderContext context) throws java.io.IOException
java.io.IOException
public Decoder decodeBuffer() throws java.io.IOException
Decoder
Decoder
. The returned Decoder
can
be used independently to this Decoder
. This means actual parsing of the subtree can be delayed.
The returned Decoder
should behave identically to this Decoder
. This means that for example
decoder.decodeDouble()
should be equivalent to decoder.decodeBuffer().decodeDouble()
.
decodeBuffer
in interface Decoder
decodeBuffer
in class AbstractStreamDecoder
java.io.IOException
- If an unrecoverable error occurs