Class Bson

java.lang.Object
com.codename1.backend.mongo.Bson

public final class Bson extends Object

BSON, the binary document format MongoDB stores and speaks.

Java BSON
Double, Float double
String string
Map embedded document (key order kept)
List, Object[] array
byte[] binary, generic subtype
ObjectId ObjectId
Boolean boolean
Date UTC datetime
null null
Integer, Short, Byte int32
Long int64

Decoding reads documents into LinkedHashMap, arrays into ArrayList, a timestamp as its Long and a Decimal128 as its sixteen raw bytes in a Bson.Decimal128Bytes; other legacy types are refused.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A Decimal128 value, kept as the sixteen little-endian bytes the server sent: this runtime has no BigDecimal to decode it into.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map
    decode(byte[] data)
    The document these bytes hold.
    static Map
    decode(byte[] data, int offset, int length)
    The document at offset, which must span exactly length bytes.
    static byte[]
    encode(Map document)
    One document as BSON.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • encode

      public static byte[] encode(Map document)
      One document as BSON.
    • decode

      public static Map decode(byte[] data) throws IOException
      The document these bytes hold.
      Throws:
      IOException
    • decode

      public static Map decode(byte[] data, int offset, int length) throws IOException
      The document at offset, which must span exactly length bytes.
      Throws:
      IOException