|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.Bytes
com.mongodb.ByteEncoder
public class ByteEncoder
Serializes a DBObject
into a string that can be sent to the database.
There is a pool of available encoders. Create a new one as follows:
ByteEncoder encoder = ByteEncoder.get(); // try forever until an encoder is available
Each key/value pair in the DBObject
is encoded in the following format:
<type (For example:byte
)><name (String
)><0 (byte
)><data (serialized data)>
<NUMBER
><name>0<double>// NUMBER = 1
<STRING
><name>0<len><string>0// STRING = 2
Field Summary |
---|
Fields inherited from class com.mongodb.Bytes |
---|
_utf8, MAX_STRING, ORDER, QUERYOPTION_NOTIMEOUT, QUERYOPTION_OPLOGREPLAY, QUERYOPTION_SLAVEOK, QUERYOPTION_TAILABLE |
Method Summary | |
---|---|
protected void |
done()
Resets and returns this encoder to the pool. |
protected void |
flip()
Switches the encoder from being write-only to being read-only. |
static ByteEncoder |
get()
Fetches a new ByteEncoder from the pool of available ByteEncoder s. |
byte[] |
getBytes()
Returns the bytes in the bytebuffer. |
protected void |
putBinary(String name,
byte[] data)
|
protected void |
putBinary(String name,
DBBinary val)
|
protected int |
putBoolean(String name,
Boolean b)
|
protected int |
putCodeWScope(String name,
CodeWScope code)
|
protected int |
putDate(String name,
Date d)
|
protected int |
putDBPointer(String name,
String ns,
ObjectId oid)
|
protected void |
putDBRef(String name,
DBRefBase ref)
|
protected int |
putNull(String name)
|
protected int |
putNumber(String name,
Number n)
|
int |
putObject(DBObject o)
Encodes a DBObject . |
protected int |
putObjectId(String name,
ObjectId oid)
|
protected int |
putString(String name,
String s)
|
protected int |
putSymbol(String name,
DBSymbol s)
|
protected int |
putTimestamp(String name,
DBTimestamp ts)
|
protected int |
putUndefined(String name)
|
protected void |
reset()
Returns encoder to its starting state, ready to encode an object. |
Methods inherited from class com.mongodb.Bytes |
---|
addDecodingHook, addEncodingHook, applyDecodingHooks, applyEncodingHooks, clearAllHooks, decode, encode, getFlag, getType, patternFlags, patternFlags |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ByteEncoder get()
ByteEncoder
from the pool of available ByteEncoder
s.
ByteEncoder
protected void done()
public byte[] getBytes()
protected void reset()
protected void flip()
public int putObject(DBObject o)
DBObject
.
This is for the higher level api calls
o
- the object to encode
protected int putNull(String name)
protected int putUndefined(String name)
protected int putTimestamp(String name, DBTimestamp ts)
protected int putCodeWScope(String name, CodeWScope code)
protected int putBoolean(String name, Boolean b)
protected int putDate(String name, Date d)
protected int putNumber(String name, Number n)
protected void putBinary(String name, byte[] data)
protected void putBinary(String name, DBBinary val)
protected int putSymbol(String name, DBSymbol s)
protected int putString(String name, String s)
protected int putObjectId(String name, ObjectId oid)
protected int putDBPointer(String name, String ns, ObjectId oid)
protected void putDBRef(String name, DBRefBase ref)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |