BSONObject
LazyBSONList
, LazyDBObject
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.Constructor | Description |
---|---|
LazyBSONObject(byte[] bytes,
int offset,
LazyBSONCallback callback) |
Construct an instance.
|
LazyBSONObject(byte[] bytes,
LazyBSONCallback callback) |
Construct an instance.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
containsField(String s) |
Checks if this object contains a field with the given name.
|
boolean |
containsKey(String key) |
Deprecated.
|
Set<Map.Entry<String,Object>> |
entrySet() |
Gets the entry set for all the key/value pairs in this
BSONObject . |
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() |
Gets the raw bytes.
|
protected int |
getOffset() |
Gets the offset into the raw bytes representing the start of the document
|
int |
hashCode() |
|
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(Map m) |
Always throws
UnsupportedOperationException . |
void |
putAll(BSONObject o) |
Always throws
UnsupportedOperationException . |
Object |
removeField(String key) |
Always throws
UnsupportedOperationException . |
Map |
toMap() |
Returns a map representing this BSONObject.
|
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 valuesprotected int getOffset()
protected byte[] getBytes()
public Object get(String key)
BSONObject
get
in interface BSONObject
key
- The name of the field fetch@Deprecated public boolean containsKey(String key)
BSONObject
containsKey
in interface BSONObject
key
- 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 boolean isEmpty()
BSONObject
.public int getBSONSize()
public int pipe(OutputStream os) throws IOException
os
- the output streamIOException
- any IOException thrown by the output streampublic Set<Map.Entry<String,Object>> entrySet()
BSONObject
. The returned set is immutable.public Object put(String key, Object v)
UnsupportedOperationException
.put
in interface BSONObject
key
- Name to setv
- Corresponding valueUnsupportedOperationException
- the object is read onlypublic void putAll(BSONObject o)
UnsupportedOperationException
.putAll
in interface BSONObject
o
- the objectUnsupportedOperationException
- the object is read onlypublic void putAll(Map m)
UnsupportedOperationException
.putAll
in interface BSONObject
m
- the mapUnsupportedOperationException
- the object is read onlypublic Object removeField(String key)
UnsupportedOperationException
.removeField
in interface BSONObject
key
- The name of the field to removeUnsupportedOperationException
- the object is read onlypublic Map toMap()
BSONObject
toMap
in interface BSONObject