public class

LazyBSONObject

extends Object
implements BSONObject
java.lang.Object
   ↳ org.bson.LazyBSONObject
Known Direct Subclasses
Known Indirect Subclasses

Summary

Nested Classes
class LazyBSONObject.LazyBSONKeySet  
Fields
protected final LazyBSONCallback _callback
protected final int _doc_start_offset
protected final BSONByteBuffer _input
Public Constructors
LazyBSONObject(byte[] data, LazyBSONCallback callback)
LazyBSONObject(byte[] data, int offset, LazyBSONCallback callback)
LazyBSONObject(BSONByteBuffer buffer, LazyBSONCallback callback)
LazyBSONObject(BSONByteBuffer buffer, int offset, LazyBSONCallback callback)
Public Methods
boolean containsField(String s)
Checks if this object contains a field with the given name.
boolean containsKey(String s)
Deprecated
Set<Entry<StringObject>> entrySet()
This method will be more efficient than using a combination of keySet() and get(String key)
boolean equals(Object o)
Object get(String key)
Gets a field from this object by a given name.
int getBSONSize()
int hashCode()
boolean isEmpty()
Set<String> keySet()
Returns this object's fields' names
void pipe(OutputStream os)
Object put(String key, Object v)
Sets a name/value pair in this object.
void putAll(Map m)
Sets all key/value pairs from a map into this object
void putAll(BSONObject o)
Sets all key/value pairs from an object into this object
Object removeField(String key)
Removes a field with a given name from this object.
Map toMap()
Returns a map representing this BSONObject.
String toString()
Returns a JSON serialization of this object
Protected Methods
int getElementBSONSize(int offset)
byte getElementType(int offset)
Object getElementValue(LazyBSONObject.ElementRecord record)
boolean isElementEmpty(int offset)
int sizeCString(int offset)
Returns the size of the BSON cstring at the given offset in the buffer
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.bson.BSONObject

Fields

protected final LazyBSONCallback _callback

protected final int _doc_start_offset

protected final BSONByteBuffer _input

Public Constructors

public LazyBSONObject (byte[] data, LazyBSONCallback callback)

public LazyBSONObject (byte[] data, int offset, LazyBSONCallback callback)

public LazyBSONObject (BSONByteBuffer buffer, LazyBSONCallback callback)

public LazyBSONObject (BSONByteBuffer buffer, int offset, LazyBSONCallback callback)

Public Methods

public boolean containsField (String s)

Checks if this object contains a field with the given name.

Parameters
s Field name for which to check
Returns
  • True if the field is present

public boolean containsKey (String s)

Deprecated

Returns
  • True if the key is present

public Set<Entry<StringObject>> entrySet ()

This method will be more efficient than using a combination of keySet() and get(String key)

Returns
  • the set of entries (key, value) in the document

public boolean equals (Object o)

public Object get (String key)

Gets a field from this object by a given name.

Parameters
key The name of the field fetch
Returns
  • The field, if found

public int getBSONSize ()

public int hashCode ()

public boolean isEmpty ()

public Set<String> keySet ()

Returns this object's fields' names

Returns
  • the set of all keys in the document

public void pipe (OutputStream os)

Throws
IOException

public Object put (String key, Object v)

Sets a name/value pair in this object.

Parameters
key Name to set
v Corresponding value
Returns
  • v

public void putAll (Map m)

Sets all key/value pairs from a map into this object

Parameters
m the map

public void putAll (BSONObject o)

Sets all key/value pairs from an object into this object

Parameters
o the object

public Object removeField (String key)

Removes a field with a given name from this object.

Parameters
key The name of the field to remove
Returns
  • The value removed from this object

public Map toMap ()

Returns a map representing this BSONObject.

Returns
  • the map

public String toString ()

Returns a JSON serialization of this object

Returns
  • JSON serialization

Protected Methods

protected int getElementBSONSize (int offset)

protected byte getElementType (int offset)

protected Object getElementValue (LazyBSONObject.ElementRecord record)

protected boolean isElementEmpty (int offset)

protected int sizeCString (int offset)

Returns the size of the BSON cstring at the given offset in the buffer

Parameters
offset the offset into the buffer
Returns
  • the size of the BSON cstring, including the null terminator