Package org.bson
Class BasicBSONDecoder
java.lang.Object
org.bson.BasicBSONDecoder
- All Implemented Interfaces:
BSONDecoder
Basic implementation of BSONDecoder interface that creates BasicBSONObject instances
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
decode
(byte[] bytes, BSONCallback callback) Decode a single BSON object into the given callback from the given byte array.int
decode
(InputStream in, BSONCallback callback) Decode a single BSON object into the given callback from the given input stream.static UuidRepresentation
Gets the defaultUuidRepresentation
to use when decoding BSON binary values.readObject
(byte[] bytes) Read a single BSON object from the given bytes.Read a single BSON object from the given input stream.static void
setDefaultUuidRepresentation
(UuidRepresentation uuidRepresentation) Sets the global (JVM-wide)UuidRepresentation
to use when decoding BSON binary values with subtypes of eitherBsonBinarySubType.UUID_STANDARD
orBsonBinarySubType.UUID_LEGACY
.
-
Constructor Details
-
BasicBSONDecoder
public BasicBSONDecoder()
-
-
Method Details
-
setDefaultUuidRepresentation
Sets the global (JVM-wide)UuidRepresentation
to use when decoding BSON binary values with subtypes of eitherBsonBinarySubType.UUID_STANDARD
orBsonBinarySubType.UUID_LEGACY
.If the
BsonBinarySubType
of the value to be decoded matches the binary subtype of theUuidRepresentation
, then the value will be decoded to an instance ofUUID
, according to the semantics of theUuidRepresentation
. Otherwise, it will be decoded to an instance ofBinary
.Defaults to
UuidRepresentation.JAVA_LEGACY
. If set toUuidRepresentation.UNSPECIFIED
, attempting to decode any UUID will throw aBSONException
.- Parameters:
uuidRepresentation
- the uuid representation, which may not be null- Since:
- 4.7
- See Also:
-
getDefaultUuidRepresentation
Gets the defaultUuidRepresentation
to use when decoding BSON binary values.If unset, the default is
UuidRepresentation.JAVA_LEGACY
.- Returns:
- the uuid representation, which may not be null
- Since:
- 4.7
- See Also:
-
readObject
Description copied from interface:BSONDecoder
Read a single BSON object from the given bytes.- Specified by:
readObject
in interfaceBSONDecoder
- Parameters:
bytes
- the bytes in BSON format- Returns:
- the BSON object for the given bytes
-
readObject
Description copied from interface:BSONDecoder
Read a single BSON object from the given input stream.- Specified by:
readObject
in interfaceBSONDecoder
- Parameters:
in
- the input stream in BSON format- Returns:
- the BSON object for the given bytes
- Throws:
IOException
- if there's a problem reading the object from theInputStream
-
decode
Description copied from interface:BSONDecoder
Decode a single BSON object into the given callback from the given byte array.- Specified by:
decode
in interfaceBSONDecoder
- Parameters:
bytes
- the bytes in BSON formatcallback
- the callback- Returns:
- the number of bytes in the BSON object
-
decode
Description copied from interface:BSONDecoder
Decode a single BSON object into the given callback from the given input stream.- Specified by:
decode
in interfaceBSONDecoder
- Parameters:
in
- the input stream in BSON formatcallback
- the callback- Returns:
- the number of bytes read from the input stream
- Throws:
IOException
- if there's a problem reading from theInputStream
-