public class BSON
extends java.lang.Object
Transformer
Modifier and Type | Field and Description |
---|---|
static byte |
ARRAY |
static byte |
B_BINARY |
static byte |
B_FUNC |
static byte |
B_GENERAL |
static byte |
B_UUID |
static byte |
BINARY |
static byte |
BOOLEAN |
static byte |
CODE |
static byte |
CODE_W_SCOPE |
static byte |
DATE |
static byte |
EOO |
static byte |
MAXKEY |
static byte |
MINKEY |
static byte |
NULL |
static byte |
NUMBER |
static byte |
NUMBER_INT |
static byte |
NUMBER_LONG |
static byte |
OBJECT |
static byte |
OID |
static byte |
REF |
static byte |
REGEX |
static byte |
STRING |
static byte |
SYMBOL |
static byte |
TIMESTAMP |
static byte |
UNDEFINED |
Constructor and Description |
---|
BSON() |
Modifier and Type | Method and Description |
---|---|
static void |
addDecodingHook(java.lang.Class<?> clazz,
Transformer transformer)
Registers a
Transformer to use when decoding a specific class from BSON. |
static void |
addEncodingHook(java.lang.Class<?> clazz,
Transformer transformer)
Registers a
Transformer to use to encode a specific class into BSON. |
static java.lang.Object |
applyDecodingHooks(java.lang.Object objectToDecode)
Transforms the
objectToDecode using all transformers registered for the class of this object. |
static java.lang.Object |
applyEncodingHooks(java.lang.Object objectToEncode)
Transforms the
objectToEncode using all transformers registered for the class of this object. |
static void |
clearAllHooks()
Remove all decoding and encoding hooks for all classes.
|
static void |
clearDecodingHooks()
Clears all decoding hooks.
|
static void |
clearEncodingHooks()
Clears all encoding hooks.
|
static BSONObject |
decode(byte[] bytes)
Decodes a BSON byte array into a DBObject instance.
|
static byte[] |
encode(BSONObject doc)
Encodes a DBObject as a BSON byte array.
|
static java.util.List<Transformer> |
getDecodingHooks(java.lang.Class<?> clazz)
Returns the decoding hook(s) associated with the specific class
|
static java.util.List<Transformer> |
getEncodingHooks(java.lang.Class<?> clazz)
Returns the encoding hook(s) associated with the specified class.
|
static boolean |
hasDecodeHooks()
Gets whether any decoding transformers have been registered for any classes.
|
static boolean |
hasEncodeHooks()
Gets whether any encoding transformers have been registered for any classes.
|
static int |
regexFlag(char c)
Converts a regular expression modifier from the database into Java regular expression flags.
|
static java.lang.String |
regexFlags(int flags)
Converts Java regular expression flags into regular expression modifiers from the database.
|
static int |
regexFlags(java.lang.String s)
Converts a sequence of regular expression modifiers from the database into Java regular expression flags.
|
static void |
removeDecodingHook(java.lang.Class<?> clazz,
Transformer transformer)
Remove a specific encoding hook for a specific class.
|
static void |
removeDecodingHooks(java.lang.Class<?> clazz)
Remove all decoding hooks for a specific class.
|
static void |
removeEncodingHook(java.lang.Class<?> clazz,
Transformer transformer)
Remove a specific encoding hook for a specific class.
|
static void |
removeEncodingHooks(java.lang.Class<?> clazz)
Remove all encoding hooks for a specific class.
|
static int |
toInt(java.lang.Object number)
Provides an integer representation of Boolean or Number.
|
public static final byte EOO
public static final byte NUMBER
public static final byte STRING
public static final byte OBJECT
public static final byte ARRAY
public static final byte BINARY
public static final byte UNDEFINED
public static final byte OID
public static final byte BOOLEAN
public static final byte DATE
public static final byte NULL
public static final byte REGEX
public static final byte REF
public static final byte CODE
public static final byte SYMBOL
public static final byte CODE_W_SCOPE
public static final byte NUMBER_INT
public static final byte TIMESTAMP
public static final byte NUMBER_LONG
public static final byte MINKEY
public static final byte MAXKEY
public static final byte B_GENERAL
public static final byte B_FUNC
public static final byte B_BINARY
public static final byte B_UUID
public static boolean hasEncodeHooks()
public static boolean hasDecodeHooks()
public static void addEncodingHook(java.lang.Class<?> clazz, Transformer transformer)
Transformer
to use to encode a specific class into BSON.clazz
- the class to be transformed during encodingtransformer
- the transformer to use during encodingpublic static void addDecodingHook(java.lang.Class<?> clazz, Transformer transformer)
Transformer
to use when decoding a specific class from BSON. This class will be one of the basic types supported
by BSON.clazz
- the class to be transformed during decodingtransformer
- the transformer to use during decodingpublic static java.lang.Object applyEncodingHooks(java.lang.Object objectToEncode)
objectToEncode
using all transformers registered for the class of this object.objectToEncode
- the object being written to BSON.public static java.lang.Object applyDecodingHooks(java.lang.Object objectToDecode)
objectToDecode
using all transformers registered for the class of this object.objectToDecode
- the BSON object to decodepublic static java.util.List<Transformer> getEncodingHooks(java.lang.Class<?> clazz)
clazz
- the class to fetch the encoding hooks forpublic static void clearEncodingHooks()
public static void removeEncodingHooks(java.lang.Class<?> clazz)
clazz
- the class to remove all the decoding hooks forpublic static void removeEncodingHook(java.lang.Class<?> clazz, Transformer transformer)
transformer
passed as the parameter must be equals
to the
transformer to remove.clazz
- the class to remove the encoding hook fortransformer
- the specific encoding hook to remove.public static java.util.List<Transformer> getDecodingHooks(java.lang.Class<?> clazz)
clazz
- the class to fetch the decoding hooks forpublic static void clearDecodingHooks()
public static void removeDecodingHooks(java.lang.Class<?> clazz)
clazz
- the class to remove all the decoding hooks forpublic static void removeDecodingHook(java.lang.Class<?> clazz, Transformer transformer)
transformer
passed as the parameter must be equals
to the
transformer to remove.clazz
- the class to remove the decoding hook fortransformer
- the specific decoding hook to remove.public static void clearAllHooks()
public static byte[] encode(BSONObject doc)
doc
- the document to encodepublic static BSONObject decode(byte[] bytes)
bytes
- a document encoded as BSONpublic static int regexFlags(java.lang.String s)
s
- regular expression modifiersjava.lang.IllegalArgumentException
- If sequence contains invalid flags.public static int regexFlag(char c)
c
- regular expression modifierjava.lang.IllegalArgumentException
- If sequence contains invalid flags.public static java.lang.String regexFlags(int flags)
flags
- the Java flagsjava.lang.IllegalArgumentException
- if some flags couldn't be recognized.public static int toInt(java.lang.Object number)
Boolean
, then 1
for true
will be
returned or @{code 0} otherwise. If argument is Number
, then Number.intValue()
will be called.number
- the number to convert to an intjava.lang.IllegalArgumentException
- if the argument is null
or not Boolean
or Number
Copyright © 2010 - 2020 Adobe. All Rights Reserved