Package org.bson
Class BSON
java.lang.Object
org.bson.BSON
- Direct Known Subclasses:
Bytes
Deprecated.
there is no replacement for this class
Contains byte representations of all the BSON types (see the BSON Specification). Also
supports the registration of encoding and decoding hooks to transform BSON types during encoding or decoding.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated.static final byteDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDecodingHook(Class<?> clazz, Transformer transformer) Deprecated.Registers aTransformerto use when decoding a specific class from BSON.static voidaddEncodingHook(Class<?> clazz, Transformer transformer) Deprecated.Registers aTransformerto use to encode a specific class into BSON.static ObjectapplyDecodingHooks(Object objectToDecode) Deprecated.Transforms theobjectToDecodeusing all transformers registered for the class of this object.static ObjectapplyEncodingHooks(Object objectToEncode) Deprecated.Transforms theobjectToEncodeusing all transformers registered for the class of this object.static voidDeprecated.Remove all decoding and encoding hooks for all classes.static voidDeprecated.Clears all decoding hooks.static voidDeprecated.Clears all encoding hooks.static BSONObjectdecode(byte[] bytes) Deprecated.Decodes a BSON byte array into a DBObject instance.static byte[]encode(BSONObject doc) Deprecated.Encodes a DBObject as a BSON byte array.static List<Transformer> getDecodingHooks(Class<?> clazz) Deprecated.Returns the decoding hook(s) associated with the specific classstatic List<Transformer> getEncodingHooks(Class<?> clazz) Deprecated.Returns the encoding hook(s) associated with the specified class.static booleanDeprecated.Gets whether any decoding transformers have been registered for any classes.static booleanDeprecated.Gets whether any encoding transformers have been registered for any classes.static intregexFlag(char c) Deprecated.Converts a regular expression modifier from the database into Java regular expression flags.static StringregexFlags(int flags) Deprecated.Converts Java regular expression flags into regular expression modifiers from the database.static intregexFlags(String s) Deprecated.Converts a sequence of regular expression modifiers from the database into Java regular expression flags.static voidremoveDecodingHook(Class<?> clazz, Transformer transformer) Deprecated.Remove a specific encoding hook for a specific class.static voidremoveDecodingHooks(Class<?> clazz) Deprecated.Remove all decoding hooks for a specific class.static voidremoveEncodingHook(Class<?> clazz, Transformer transformer) Deprecated.Remove a specific encoding hook for a specific class.static voidremoveEncodingHooks(Class<?> clazz) Deprecated.Remove all encoding hooks for a specific class.static intDeprecated.Provides an integer representation of Boolean or Number.
-
Field Details
-
EOO
public static final byte EOODeprecated.- See Also:
-
NUMBER
public static final byte NUMBERDeprecated.- See Also:
-
STRING
public static final byte STRINGDeprecated.- See Also:
-
OBJECT
public static final byte OBJECTDeprecated.- See Also:
-
ARRAY
public static final byte ARRAYDeprecated.- See Also:
-
BINARY
public static final byte BINARYDeprecated.- See Also:
-
UNDEFINED
public static final byte UNDEFINEDDeprecated.- See Also:
-
OID
public static final byte OIDDeprecated.- See Also:
-
BOOLEAN
public static final byte BOOLEANDeprecated.- See Also:
-
DATE
public static final byte DATEDeprecated.- See Also:
-
NULL
public static final byte NULLDeprecated.- See Also:
-
REGEX
public static final byte REGEXDeprecated.- See Also:
-
REF
public static final byte REFDeprecated.- See Also:
-
CODE
public static final byte CODEDeprecated.- See Also:
-
SYMBOL
public static final byte SYMBOLDeprecated.- See Also:
-
CODE_W_SCOPE
public static final byte CODE_W_SCOPEDeprecated.- See Also:
-
NUMBER_INT
public static final byte NUMBER_INTDeprecated.- See Also:
-
TIMESTAMP
public static final byte TIMESTAMPDeprecated.- See Also:
-
NUMBER_LONG
public static final byte NUMBER_LONGDeprecated.- See Also:
-
MINKEY
public static final byte MINKEYDeprecated.- See Also:
-
MAXKEY
public static final byte MAXKEYDeprecated.- See Also:
-
B_GENERAL
public static final byte B_GENERALDeprecated.- See Also:
-
B_FUNC
public static final byte B_FUNCDeprecated.- See Also:
-
B_BINARY
public static final byte B_BINARYDeprecated.- See Also:
-
B_UUID
public static final byte B_UUIDDeprecated.- See Also:
-
-
Constructor Details
-
BSON
public BSON()Deprecated.
-
-
Method Details
-
hasEncodeHooks
public static boolean hasEncodeHooks()Deprecated.Gets whether any encoding transformers have been registered for any classes.- Returns:
- true if any encoding hooks have been registered.
-
hasDecodeHooks
public static boolean hasDecodeHooks()Deprecated.Gets whether any decoding transformers have been registered for any classes.- Returns:
- true if any decoding hooks have been registered.
-
addEncodingHook
Deprecated.Registers aTransformerto use to encode a specific class into BSON.- Parameters:
clazz- the class to be transformed during encodingtransformer- the transformer to use during encoding
-
addDecodingHook
Deprecated.Registers aTransformerto use when decoding a specific class from BSON. This class will be one of the basic types supported by BSON.- Parameters:
clazz- the class to be transformed during decodingtransformer- the transformer to use during decoding
-
applyEncodingHooks
Deprecated.Transforms theobjectToEncodeusing all transformers registered for the class of this object.- Parameters:
objectToEncode- the object being written to BSON.- Returns:
- the transformed object
-
applyDecodingHooks
Deprecated.Transforms theobjectToDecodeusing all transformers registered for the class of this object.- Parameters:
objectToDecode- the BSON object to decode- Returns:
- the transformed object
-
getEncodingHooks
Deprecated.Returns the encoding hook(s) associated with the specified class.- Parameters:
clazz- the class to fetch the encoding hooks for- Returns:
- a List of encoding transformers that apply to the given class
-
clearEncodingHooks
public static void clearEncodingHooks()Deprecated.Clears all encoding hooks. -
removeEncodingHooks
Deprecated.Remove all encoding hooks for a specific class.- Parameters:
clazz- the class to remove all the decoding hooks for
-
removeEncodingHook
Deprecated.Remove a specific encoding hook for a specific class. Thetransformerpassed as the parameter must beequalsto the transformer to remove.- Parameters:
clazz- the class to remove the encoding hook fortransformer- the specific encoding hook to remove.
-
getDecodingHooks
Deprecated.Returns the decoding hook(s) associated with the specific class- Parameters:
clazz- the class to fetch the decoding hooks for- Returns:
- a List of all the decoding Transformers that apply to the given class
-
clearDecodingHooks
public static void clearDecodingHooks()Deprecated.Clears all decoding hooks. -
removeDecodingHooks
Deprecated.Remove all decoding hooks for a specific class.- Parameters:
clazz- the class to remove all the decoding hooks for
-
removeDecodingHook
Deprecated.Remove a specific encoding hook for a specific class. Thetransformerpassed as the parameter must beequalsto the transformer to remove.- Parameters:
clazz- the class to remove the decoding hook fortransformer- the specific decoding hook to remove.
-
clearAllHooks
public static void clearAllHooks()Deprecated.Remove all decoding and encoding hooks for all classes. -
encode
Deprecated.Encodes a DBObject as a BSON byte array.- Parameters:
doc- the document to encode- Returns:
- the document encoded as BSON
-
decode
Deprecated.Decodes a BSON byte array into a DBObject instance.- Parameters:
bytes- a document encoded as BSON- Returns:
- the document as a DBObject
-
regexFlags
Deprecated.Converts a sequence of regular expression modifiers from the database into Java regular expression flags.- Parameters:
s- regular expression modifiers- Returns:
- the Java flags
- Throws:
IllegalArgumentException- If sequence contains invalid flags.
-
regexFlag
public static int regexFlag(char c) Deprecated.Converts a regular expression modifier from the database into Java regular expression flags.- Parameters:
c- regular expression modifier- Returns:
- the Java flags
- Throws:
IllegalArgumentException- If sequence contains invalid flags.
-
regexFlags
Deprecated.Converts Java regular expression flags into regular expression modifiers from the database.- Parameters:
flags- the Java flags- Returns:
- the Java flags
- Throws:
IllegalArgumentException- if some flags couldn't be recognized.
-
toInt
Deprecated.Provides an integer representation of Boolean or Number. If argument isBoolean, then1fortruewill be returned or @{code 0} otherwise. If argument isNumber, thenNumber.intValue()will be called.- Parameters:
number- the number to convert to an int- Returns:
- integer value
- Throws:
IllegalArgumentException- if the argument isnullor notBooleanorNumber
-