|
||||||||||
| 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 | |
|---|---|
(package private) ByteBuffer |
_buf
|
(package private) static SimplePool<ByteEncoder> |
_pool
|
(package private) static Set<String> |
BAD_GLOBALS
|
(package private) static boolean |
DEBUG
|
| Fields inherited from class com.mongodb.Bytes |
|---|
_decodingHooks, _encodingHooks, _utf8, ARRAY, B_BINARY, B_FUNC, BINARY, BOOLEAN, CODE, CODE_W_SCOPE, COLLECTION_REF_ID, CONNECTIONS_PER_HOST, D, DATE, EOO, LOGGER, MAX_OBJECT_SIZE, MAX_STRING, MAXKEY, MINKEY, NO_REF_HACK, NULL, NUM_ENCODERS, NUMBER, NUMBER_INT, NUMBER_LONG, OBJECT, OID, ORDER, REF, REGEX, STRING, SYMBOL, TIMESTAMP, UNDEFINED |
| Method Summary | |
|---|---|
(package private) boolean |
_dontRefContains(Object o)
|
(package private) int |
_put(String name)
|
(package private) void |
_putValueString(String s)
|
static boolean |
dbOnlyField(Object o)
Whether a given field is generated by the db for use by the db |
static boolean |
dbOnlyField(String s)
Whether a given field is generated by the db for use by the db |
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 ByteEncoders. |
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 |
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, cameFromDB, clearAllHooks, getFlag, getType, patternFlags, patternFlags |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final boolean DEBUG
static final Set<String> BAD_GLOBALS
static final SimplePool<ByteEncoder> _pool
final ByteBuffer _buf
| Method Detail |
|---|
public static boolean dbOnlyField(Object o)
o - an object to check
public static boolean dbOnlyField(String s)
s - a string to check
public static ByteEncoder get()
ByteEncoder from the pool of available ByteEncoders.
ByteEncoderprotected 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 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)
void _putValueString(String s)
int _put(String name)
boolean _dontRefContains(Object o)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||