Package org.bson

Class LazyBSONCallback

java.lang.Object
org.bson.EmptyBSONCallback
org.bson.LazyBSONCallback
All Implemented Interfaces:
BSONCallback

public class LazyBSONCallback extends EmptyBSONCallback
A BSONCallback for creation of LazyBSONObject and LazyBSONList instances.
  • Constructor Details

    • LazyBSONCallback

      public LazyBSONCallback()
  • Method Details

    • reset

      public void reset()
      Description copied from interface: BSONCallback
      Resets the callback, clearing all state.
      Specified by:
      reset in interface BSONCallback
      Overrides:
      reset in class EmptyBSONCallback
    • get

      public Object get()
      Description copied from interface: BSONCallback
      Returns the finished top-level Document.
      Specified by:
      get in interface BSONCallback
      Overrides:
      get in class EmptyBSONCallback
      Returns:
      the top level document read from the database.
    • gotBinary

      public void gotBinary(String name, byte type, byte[] data)
      Description copied from interface: BSONCallback
      Called when reading a field with a BsonType.BINARY value. Note that binary values have a subtype, which may determine how the value is processed.
      Specified by:
      gotBinary in interface BSONCallback
      Overrides:
      gotBinary in class EmptyBSONCallback
      Parameters:
      name - the name of the field
      type - one of the binary subtypes: BsonBinarySubType
      data - the field's value
    • createObject

      public Object createObject(byte[] bytes, int offset)
      Create a LazyBSONObject instance from the given bytes starting from the given offset.
      Parameters:
      bytes - the raw BSON bytes
      offset - the offset into the bytes
      Returns:
      the LazyBSONObject
    • createArray

      public List createArray(byte[] bytes, int offset)
      Create a LazyBSONList from the given bytes starting from the given offset.
      Parameters:
      bytes - the raw BSON bytes
      offset - the offset into the bytes
      Returns:
      the LazyBSONList
    • createDBRef

      public Object createDBRef(String ns, ObjectId id)
      This is a factory method pattern to create appropriate objects for BSON type DBPointer(0x0c).
      Parameters:
      ns - the namespace of the reference
      id - the identifier of the reference
      Returns:
      object to be used as reference representation