Package com.mongodb

Class LazyDBObject

  • All Implemented Interfaces:
    DBObject, BSONObject


    @Immutable
    public class LazyDBObject
    extends LazyBSONObject
    implements DBObject
    An immutable DBObject backed by a byte buffer that lazily provides keys and values on request. This is useful for transferring BSON documents between servers when you don't want to pay the performance penalty of encoding or decoding them fully.
    • Constructor Detail

      • LazyDBObject

        public LazyDBObject​(byte[] bytes,
                            LazyBSONCallback callback)
        Construct an instance.
        Parameters:
        bytes - the raw bytes
        callback - the callback to use to construct nested values
      • LazyDBObject

        public LazyDBObject​(byte[] bytes,
                            int offset,
                            LazyBSONCallback callback)
        Construct an instance.
        Parameters:
        bytes - the raw bytes
        offset - the offset into the raw bytes
        callback - the callback to use to construct nested values
    • Method Detail

      • markAsPartialObject

        public void markAsPartialObject​()
        Description copied from interface: DBObject
        If this object was retrieved with only some fields (using a field filter) this method will be called to mark it as such.
        Specified by:
        markAsPartialObject in interface DBObject
      • isPartialObject

        public boolean isPartialObject​()
        Description copied from interface: DBObject
        Whether DBObject.markAsPartialObject() was ever called only matters if you are going to upsert and do not want to risk losing fields.
        Specified by:
        isPartialObject in interface DBObject
        Returns:
        true if this has been marked as a partial object
      • toString

        public String toString​()
        Returns a JSON serialization of this object
        Overrides:
        toString in class Object
        Returns:
        JSON serialization