public class LazyBSONObject extends Object implements BSONObject
BSONObject
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.Modifier and Type | Class and Description |
---|---|
class |
LazyBSONObject.LazyBSONKeySet
Deprecated.
This class is NOT a part of public API and will be dropped in 3.x versions.
|
Modifier and Type | Field and Description |
---|---|
protected LazyBSONCallback |
_callback
Deprecated.
This field is NOT a part of public API and will be dropped in 3.x versions.
|
protected int |
_doc_start_offset
Deprecated.
Please use
getOffset() instead. |
protected BSONByteBuffer |
_input
Deprecated.
Please use
getBytes() to access underlying bytes. |
Constructor and Description |
---|
LazyBSONObject(BSONByteBuffer buffer,
int offset,
LazyBSONCallback callback)
Deprecated.
use
LazyBSONObject(byte[], int, LazyBSONCallback) instead |
LazyBSONObject(BSONByteBuffer buffer,
LazyBSONCallback callback)
Deprecated.
use
LazyBSONObject(byte[], LazyBSONCallback) instead |
LazyBSONObject(byte[] bytes,
int offset,
LazyBSONCallback callback)
Construct an instance.
|
LazyBSONObject(byte[] bytes,
LazyBSONCallback callback)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsField(String s)
Checks if this object contains a field with the given name.
|
boolean |
containsKey(String s)
Deprecated.
|
Set<Map.Entry<String,Object>> |
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()
Gets the size in bytes of the BSON document.
|
protected byte[] |
getBytes() |
protected int |
getElementBSONSize(int offset)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
protected byte |
getElementType(int offset)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
protected Object |
getElementValue(org.bson.LazyBSONObject.ElementRecord record)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
protected int |
getOffset() |
int |
hashCode() |
protected boolean |
isElementEmpty(int offset)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
boolean |
isEmpty()
Gets whether this is an empty
BSONObject . |
Set<String> |
keySet()
Returns this object's fields' names
|
int |
pipe(OutputStream os)
Pipe the raw bytes into the given output stream.
|
Object |
put(String key,
Object v)
Always throws
UnsupportedOperationException . |
void |
putAll(BSONObject o)
Always throws
UnsupportedOperationException . |
void |
putAll(Map m)
Always throws
UnsupportedOperationException . |
Object |
removeField(String key)
Always throws
UnsupportedOperationException . |
protected int |
sizeCString(int offset)
Deprecated.
This method is NOT a part of public API and will be dropped in 3.x versions.
|
Map |
toMap()
Returns a map representing this BSONObject.
|
String |
toString()
Returns a JSON serialization of this object
|
@Deprecated protected final int _doc_start_offset
getOffset()
instead.@Deprecated protected final BSONByteBuffer _input
getBytes()
to access underlying bytes.@Deprecated protected final LazyBSONCallback _callback
public LazyBSONObject(byte[] bytes, LazyBSONCallback callback)
bytes
- the raw bytescallback
- the callback to use to construct nested valuespublic LazyBSONObject(byte[] bytes, int offset, LazyBSONCallback callback)
bytes
- the raw bytesoffset
- the offset into the raw bytes representing the start of the documentcallback
- the callback to use to construct nested values@Deprecated public LazyBSONObject(BSONByteBuffer buffer, LazyBSONCallback callback)
LazyBSONObject(byte[], LazyBSONCallback)
instead@Deprecated public LazyBSONObject(BSONByteBuffer buffer, int offset, LazyBSONCallback callback)
LazyBSONObject(byte[], int, LazyBSONCallback)
insteadpublic Object put(String key, Object v)
UnsupportedOperationException
.put
in interface BSONObject
key
- Name to setv
- Corresponding valueUnsupportedOperationException
public void putAll(BSONObject o)
UnsupportedOperationException
.putAll
in interface BSONObject
o
- the objectUnsupportedOperationException
public void putAll(Map m)
UnsupportedOperationException
.putAll
in interface BSONObject
m
- the mapUnsupportedOperationException
public Object get(String key)
BSONObject
get
in interface BSONObject
key
- The name of the field fetchpublic Map toMap()
BSONObject
toMap
in interface BSONObject
public Object removeField(String key)
UnsupportedOperationException
.removeField
in interface BSONObject
key
- The name of the field to removeUnsupportedOperationException
@Deprecated public boolean containsKey(String s)
BSONObject
containsKey
in interface BSONObject
s
- the key to checkpublic boolean containsField(String s)
BSONObject
containsField
in interface BSONObject
s
- Field name for which to checkpublic Set<String> keySet()
BSONObject
keySet
in interface BSONObject
public Set<Map.Entry<String,Object>> entrySet()
@Deprecated protected boolean isElementEmpty(int offset)
public boolean isEmpty()
BSONObject
.public int getBSONSize()
public int pipe(OutputStream os) throws IOException
os
- the output streamIOException
- any IOException thrown by the output stream@Deprecated protected byte getElementType(int offset)
@Deprecated protected int getElementBSONSize(int offset)
@Deprecated protected int sizeCString(int offset)
offset
- the offset into the buffer@Deprecated protected Object getElementValue(org.bson.LazyBSONObject.ElementRecord record)
protected int getOffset()
protected byte[] getBytes()