public class BsonUtils extends Object
Constructor and Description |
---|
BsonUtils() |
Modifier and Type | Method and Description |
---|---|
static ObjectId |
readObjectId(byte[] bytes)
The BSON specification (or rather the MongoDB
documentation) defines the structure of this data:
"A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a 3-byte counter. |
static ObjectId |
readObjectId(String bytesInHex)
Read the
ObjectId from the hexadecimal string representation of the ObjectId. |
static String |
regexFlagsFor(int flags) |
static String |
regexFlagsFor(Pattern pattern) |
static int |
regexFlagsFrom(String flags) |
static boolean |
valuesAreEqual(Object thisValue,
Object thatValue) |
static void |
writeObjectId(ObjectId id,
byte[] b)
Write the 12-byte representation of the ObjectId per the BSON specification (or rather the MongoDB documentation).
|
public static int regexFlagsFrom(String flags)
public static String regexFlagsFor(int flags)
public static ObjectId readObjectId(byte[] bytes)
"A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte
machine id, a 2-byte process id, and a 3-byte counter. Note that the timestamp and counter fields must be stored
big endian unlike the rest of BSON. This is because they are compared byte-by-byte and we want to ensure a mostly
increasing order."
bytes
- public static ObjectId readObjectId(String bytesInHex)
ObjectId
from the hexadecimal string representation of the ObjectId.bytesInHex
- the hexadecimal identifierpublic static void writeObjectId(ObjectId id, byte[] b)
id
- the ObjectId; may not be nullb
- the bytes into which the object ID should be writtenCopyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.