Package org.bson.json
Class JsonReader
- java.lang.Object
-
- org.bson.AbstractBsonReader
-
- org.bson.json.JsonReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BsonReader
public class JsonReader extends AbstractBsonReader
Reads a JSON in one of the following modes:- Strict mode that conforms to the JSON RFC specifications.
- JavaScript mode that that most JavaScript interpreters can process
- Shell mode that the mongo shell can process. This is also called "extended" JavaScript format.
- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJsonReader.Contextprotected classJsonReader.Mark-
Nested classes/interfaces inherited from class org.bson.AbstractBsonReader
AbstractBsonReader.State
-
-
Constructor Summary
Constructors Constructor Description JsonReader(String json)Constructs a new instance with the given JSON string.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected intdoPeekBinarySize()Handles the logic to peek at the binary size.protected bytedoPeekBinarySubType()Handles the logic to peek at the binary subtype.protected BsonBinarydoReadBinaryData()Handles the logic to read binary dataprotected booleandoReadBoolean()Handles the logic to read booleansprotected longdoReadDateTime()Handles the logic to read date timeprotected BsonDbPointerdoReadDBPointer()Handles the logic to read a DBPointerDecimal128doReadDecimal128()Handles the logic to read Decimal128protected doubledoReadDouble()Handles the logic to read doublesprotected voiddoReadEndArray()Handles the logic when reading the end of an arrayprotected voiddoReadEndDocument()Handles the logic when reading the end of a documentprotected intdoReadInt32()Handles the logic to read 32 bit intsprotected longdoReadInt64()Handles the logic to read 64 bit intsprotected StringdoReadJavaScript()Handles the logic to read Javascript functionsprotected StringdoReadJavaScriptWithScope()Handles the logic to read scoped Javascript functionsprotected voiddoReadMaxKey()Handles the logic to read a Max keyprotected voiddoReadMinKey()Handles the logic to read a Min keyprotected voiddoReadNull()Handles the logic to read a null valueprotected ObjectIddoReadObjectId()Handles the logic to read an ObjectIdprotected BsonRegularExpressiondoReadRegularExpression()Handles the logic to read a regular expressionprotected voiddoReadStartArray()Handles the logic to read the start of an arrayprotected voiddoReadStartDocument()Handles the logic to read the start of a documentprotected StringdoReadString()Handles the logic to read a Stringprotected StringdoReadSymbol()Handles the logic to read a Symbolprotected BsonTimestampdoReadTimestamp()Handles the logic to read a timestampprotected voiddoReadUndefined()Handles the logic to read an Undefined valueprotected voiddoSkipName()Handles any logic required to skip the name (reader must be positioned on a name).protected voiddoSkipValue()Handles any logic required to skip the value (reader must be positioned on a value).protected JsonReader.ContextgetContext()Get the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.BsonReaderMarkgetMark()Gets a mark representing the current state of the reader.voidmark()Deprecated.BsonTypereadBsonType()Reads a BSONType from the reader.voidreset()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
-
JsonReader
public JsonReader(String json)
Constructs a new instance with the given JSON string.- Parameters:
json- A string representation of a JSON.
-
-
Method Detail
-
doReadBinaryData
protected BsonBinary doReadBinaryData()
Description copied from class:AbstractBsonReaderHandles the logic to read binary data- Specified by:
doReadBinaryDatain classAbstractBsonReader- Returns:
- the BsonBinary value
-
doPeekBinarySubType
protected byte doPeekBinarySubType()
Description copied from class:AbstractBsonReaderHandles the logic to peek at the binary subtype.- Specified by:
doPeekBinarySubTypein classAbstractBsonReader- Returns:
- the binary subtype
-
doPeekBinarySize
protected int doPeekBinarySize()
Description copied from class:AbstractBsonReaderHandles the logic to peek at the binary size.- Specified by:
doPeekBinarySizein classAbstractBsonReader- Returns:
- the binary size
-
doReadBoolean
protected boolean doReadBoolean()
Description copied from class:AbstractBsonReaderHandles the logic to read booleans- Specified by:
doReadBooleanin classAbstractBsonReader- Returns:
- the boolean value
-
readBsonType
public BsonType readBsonType()
Description copied from interface:BsonReaderReads a BSONType from the reader.- Specified by:
readBsonTypein interfaceBsonReader- Specified by:
readBsonTypein classAbstractBsonReader- Returns:
- A BSONType.
-
doReadDecimal128
public Decimal128 doReadDecimal128()
Description copied from class:AbstractBsonReaderHandles the logic to read Decimal128- Specified by:
doReadDecimal128in classAbstractBsonReader- Returns:
- the Decimal128 value
-
doReadDateTime
protected long doReadDateTime()
Description copied from class:AbstractBsonReaderHandles the logic to read date time- Specified by:
doReadDateTimein classAbstractBsonReader- Returns:
- the long value
-
doReadDouble
protected double doReadDouble()
Description copied from class:AbstractBsonReaderHandles the logic to read doubles- Specified by:
doReadDoublein classAbstractBsonReader- Returns:
- the double value
-
doReadEndArray
protected void doReadEndArray()
Description copied from class:AbstractBsonReaderHandles the logic when reading the end of an array- Specified by:
doReadEndArrayin classAbstractBsonReader
-
doReadEndDocument
protected void doReadEndDocument()
Description copied from class:AbstractBsonReaderHandles the logic when reading the end of a document- Specified by:
doReadEndDocumentin classAbstractBsonReader
-
doReadInt32
protected int doReadInt32()
Description copied from class:AbstractBsonReaderHandles the logic to read 32 bit ints- Specified by:
doReadInt32in classAbstractBsonReader- Returns:
- the int value
-
doReadInt64
protected long doReadInt64()
Description copied from class:AbstractBsonReaderHandles the logic to read 64 bit ints- Specified by:
doReadInt64in classAbstractBsonReader- Returns:
- the long value
-
doReadJavaScript
protected String doReadJavaScript()
Description copied from class:AbstractBsonReaderHandles the logic to read Javascript functions- Specified by:
doReadJavaScriptin classAbstractBsonReader- Returns:
- the String value
-
doReadJavaScriptWithScope
protected String doReadJavaScriptWithScope()
Description copied from class:AbstractBsonReaderHandles the logic to read scoped Javascript functions- Specified by:
doReadJavaScriptWithScopein classAbstractBsonReader- Returns:
- the String value
-
doReadMaxKey
protected void doReadMaxKey()
Description copied from class:AbstractBsonReaderHandles the logic to read a Max key- Specified by:
doReadMaxKeyin classAbstractBsonReader
-
doReadMinKey
protected void doReadMinKey()
Description copied from class:AbstractBsonReaderHandles the logic to read a Min key- Specified by:
doReadMinKeyin classAbstractBsonReader
-
doReadNull
protected void doReadNull()
Description copied from class:AbstractBsonReaderHandles the logic to read a null value- Specified by:
doReadNullin classAbstractBsonReader
-
doReadObjectId
protected ObjectId doReadObjectId()
Description copied from class:AbstractBsonReaderHandles the logic to read an ObjectId- Specified by:
doReadObjectIdin classAbstractBsonReader- Returns:
- the ObjectId value
-
doReadRegularExpression
protected BsonRegularExpression doReadRegularExpression()
Description copied from class:AbstractBsonReaderHandles the logic to read a regular expression- Specified by:
doReadRegularExpressionin classAbstractBsonReader- Returns:
- the BsonRegularExpression value
-
doReadDBPointer
protected BsonDbPointer doReadDBPointer()
Description copied from class:AbstractBsonReaderHandles the logic to read a DBPointer- Specified by:
doReadDBPointerin classAbstractBsonReader- Returns:
- the BsonDbPointer value
-
doReadStartArray
protected void doReadStartArray()
Description copied from class:AbstractBsonReaderHandles the logic to read the start of an array- Specified by:
doReadStartArrayin classAbstractBsonReader
-
doReadStartDocument
protected void doReadStartDocument()
Description copied from class:AbstractBsonReaderHandles the logic to read the start of a document- Specified by:
doReadStartDocumentin classAbstractBsonReader
-
doReadString
protected String doReadString()
Description copied from class:AbstractBsonReaderHandles the logic to read a String- Specified by:
doReadStringin classAbstractBsonReader- Returns:
- the String value
-
doReadSymbol
protected String doReadSymbol()
Description copied from class:AbstractBsonReaderHandles the logic to read a Symbol- Specified by:
doReadSymbolin classAbstractBsonReader- Returns:
- the String value
-
doReadTimestamp
protected BsonTimestamp doReadTimestamp()
Description copied from class:AbstractBsonReaderHandles the logic to read a timestamp- Specified by:
doReadTimestampin classAbstractBsonReader- Returns:
- the BsonTimestamp value
-
doReadUndefined
protected void doReadUndefined()
Description copied from class:AbstractBsonReaderHandles the logic to read an Undefined value- Specified by:
doReadUndefinedin classAbstractBsonReader
-
doSkipName
protected void doSkipName()
Description copied from class:AbstractBsonReaderHandles any logic required to skip the name (reader must be positioned on a name).- Specified by:
doSkipNamein classAbstractBsonReader
-
doSkipValue
protected void doSkipValue()
Description copied from class:AbstractBsonReaderHandles any logic required to skip the value (reader must be positioned on a value).- Specified by:
doSkipValuein classAbstractBsonReader
-
mark
@Deprecated public void mark()
Deprecated.Description copied from interface:BsonReaderCreates 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:BsonReaderGets a mark representing the current state of the reader.- Returns:
- the mark
-
reset
@Deprecated public void reset()
Deprecated.Description copied from interface:BsonReaderGo back to the state at the last mark and removes the mark
-
getContext
protected JsonReader.Context getContext()
Description copied from class:AbstractBsonReaderGet the context, which will indicate which state the reader is in, for example which part of a document it's currently reading.- Overrides:
getContextin classAbstractBsonReader- Returns:
- the context
-
-