public class BsonParser extends Object implements CookJsonParser
Due to the fact that BSON has a lot of types that are MongoDB specific, only the following types are supported by this JsonParser.
JsonParser.Event| Constructor and Description |
|---|
BsonParser(InputStream is) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
BigDecimal |
getBigDecimal() |
int |
getBinaryFormat()
Gets the binary format for storing byte[].
|
byte[] |
getBytes()
Returns the
byte[] value if the parser state is
JsonParser.Event.VALUE_STRING and the data is actually a binary data. |
JsonParser.Event |
getEvent()
Gets the current event.
|
int |
getInt() |
JsonLocation |
getLocation() |
long |
getLong() |
String |
getString() |
JsonValue |
getValue()
Based on the current event, retrieve the JsonValue.
|
boolean |
hasNext() |
boolean |
isBinary()
Returns true if the current JSON value at the current parser state is
actually a binary data.
|
boolean |
isIntegralNumber() |
boolean |
isRootAsArray()
Gets the status of treating root as array.
|
JsonParser.Event |
next() |
void |
setBinaryFormat(int binaryFormat)
Sets the binary format for storing byte[].
|
void |
setRootAsArray(boolean b)
Treats the root as Array rather than Document.
|
public BsonParser(InputStream is)
public boolean hasNext()
hasNext in interface JsonParserpublic JsonParser.Event getEvent()
CookJsonParsergetEvent in interface CookJsonParserpublic JsonValue getValue()
CookJsonParserIn case of START_OBJECT and START_ARRAY, JsonObject and JsonArray objects are returned. This feature is to allow the mixing of streaming and model based APIs.
getValue in interface CookJsonParserpublic JsonParser.Event next()
next in interface JsonParserpublic String getString()
getString in interface JsonParserpublic boolean isBinary()
CookJsonParserisBinary in interface CookJsonParserpublic byte[] getBytes()
CookJsonParserbyte[] value if the parser state is
JsonParser.Event.VALUE_STRING and the data is actually a binary data.getBytes in interface CookJsonParserpublic boolean isIntegralNumber()
isIntegralNumber in interface JsonParserpublic int getInt()
getInt in interface JsonParserpublic long getLong()
getLong in interface JsonParserpublic BigDecimal getBigDecimal()
getBigDecimal in interface JsonParserpublic JsonLocation getLocation()
getLocation in interface JsonParserpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface JsonParserpublic boolean isRootAsArray()
public void setRootAsArray(boolean b)
By default, the root is treated as Document (Object in JSON). With this flag set, the root is treated as array, and field names are ignored as the result.
b - true or false.public int getBinaryFormat()
It is one of BinaryFormat.BINARY_FORMAT_BASE64 and
BinaryFormat.BINARY_FORMAT_HEX.
public void setBinaryFormat(int binaryFormat)
It is one of BinaryFormat.BINARY_FORMAT_BASE64 and
BinaryFormat.BINARY_FORMAT_HEX.
binaryFormat - the binary formatCopyright © 2016. All rights reserved.