Package org.bson

Class BSON

  • Direct Known Subclasses:
    Bytes

    @Deprecated
    public class BSON
    extends java.lang.Object
    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:
    Transformer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte ARRAY
      Deprecated.
       
      static byte B_BINARY
      Deprecated.
       
      static byte B_FUNC
      Deprecated.
       
      static byte B_GENERAL
      Deprecated.
       
      static byte B_UUID
      Deprecated.
       
      static byte BINARY
      Deprecated.
       
      static byte BOOLEAN
      Deprecated.
       
      static byte CODE
      Deprecated.
       
      static byte CODE_W_SCOPE
      Deprecated.
       
      static byte DATE
      Deprecated.
       
      static byte EOO
      Deprecated.
       
      static byte MAXKEY
      Deprecated.
       
      static byte MINKEY
      Deprecated.
       
      static byte NULL
      Deprecated.
       
      static byte NUMBER
      Deprecated.
       
      static byte NUMBER_INT
      Deprecated.
       
      static byte NUMBER_LONG
      Deprecated.
       
      static byte OBJECT
      Deprecated.
       
      static byte OID
      Deprecated.
       
      static byte REF
      Deprecated.
       
      static byte REGEX
      Deprecated.
       
      static byte STRING
      Deprecated.
       
      static byte SYMBOL
      Deprecated.
       
      static byte TIMESTAMP
      Deprecated.
       
      static byte UNDEFINED
      Deprecated.
       
    • Constructor Summary

      Constructors 
      Constructor Description
      BSON()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void addDecodingHook​(java.lang.Class<?> clazz, Transformer transformer)
      Deprecated.
      Registers a Transformer to use when decoding a specific class from BSON.
      static void addEncodingHook​(java.lang.Class<?> clazz, Transformer transformer)
      Deprecated.
      Registers a Transformer to use to encode a specific class into BSON.
      static java.lang.Object applyDecodingHooks​(java.lang.Object objectToDecode)
      Deprecated.
      Transforms the objectToDecode using all transformers registered for the class of this object.
      static java.lang.Object applyEncodingHooks​(java.lang.Object objectToEncode)
      Deprecated.
      Transforms the objectToEncode using all transformers registered for the class of this object.
      static void clearAllHooks()
      Deprecated.
      Remove all decoding and encoding hooks for all classes.
      static void clearDecodingHooks()
      Deprecated.
      Clears all decoding hooks.
      static void clearEncodingHooks()
      Deprecated.
      Clears all encoding hooks.
      static BSONObject decode​(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 java.util.List<Transformer> getDecodingHooks​(java.lang.Class<?> clazz)
      Deprecated.
      Returns the decoding hook(s) associated with the specific class
      static java.util.List<Transformer> getEncodingHooks​(java.lang.Class<?> clazz)
      Deprecated.
      Returns the encoding hook(s) associated with the specified class.
      static boolean hasDecodeHooks()
      Deprecated.
      Gets whether any decoding transformers have been registered for any classes.
      static boolean hasEncodeHooks()
      Deprecated.
      Gets whether any encoding transformers have been registered for any classes.
      static int regexFlag​(char c)
      Deprecated.
      Converts a regular expression modifier from the database into Java regular expression flags.
      static java.lang.String regexFlags​(int flags)
      Deprecated.
      Converts Java regular expression flags into regular expression modifiers from the database.
      static int regexFlags​(java.lang.String s)
      Deprecated.
      Converts a sequence of regular expression modifiers from the database into Java regular expression flags.
      static void removeDecodingHook​(java.lang.Class<?> clazz, Transformer transformer)
      Deprecated.
      Remove a specific encoding hook for a specific class.
      static void removeDecodingHooks​(java.lang.Class<?> clazz)
      Deprecated.
      Remove all decoding hooks for a specific class.
      static void removeEncodingHook​(java.lang.Class<?> clazz, Transformer transformer)
      Deprecated.
      Remove a specific encoding hook for a specific class.
      static void removeEncodingHooks​(java.lang.Class<?> clazz)
      Deprecated.
      Remove all encoding hooks for a specific class.
      static int toInt​(java.lang.Object number)
      Deprecated.
      Provides an integer representation of Boolean or Number.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BSON

        public BSON()
        Deprecated.
    • Method Detail

      • 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

        public static void addEncodingHook​(java.lang.Class<?> clazz,
                                           Transformer transformer)
        Deprecated.
        Registers a Transformer to use to encode a specific class into BSON.
        Parameters:
        clazz - the class to be transformed during encoding
        transformer - the transformer to use during encoding
      • addDecodingHook

        public static void addDecodingHook​(java.lang.Class<?> clazz,
                                           Transformer transformer)
        Deprecated.
        Registers a Transformer to 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 decoding
        transformer - the transformer to use during decoding
      • applyEncodingHooks

        public static java.lang.Object applyEncodingHooks​(java.lang.Object objectToEncode)
        Deprecated.
        Transforms the objectToEncode using all transformers registered for the class of this object.
        Parameters:
        objectToEncode - the object being written to BSON.
        Returns:
        the transformed object
      • applyDecodingHooks

        public static java.lang.Object applyDecodingHooks​(java.lang.Object objectToDecode)
        Deprecated.
        Transforms the objectToDecode using all transformers registered for the class of this object.
        Parameters:
        objectToDecode - the BSON object to decode
        Returns:
        the transformed object
      • getEncodingHooks

        public static java.util.List<Transformer> getEncodingHooks​(java.lang.Class<?> clazz)
        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

        public static void removeEncodingHooks​(java.lang.Class<?> clazz)
        Deprecated.
        Remove all encoding hooks for a specific class.
        Parameters:
        clazz - the class to remove all the decoding hooks for
      • removeEncodingHook

        public static void removeEncodingHook​(java.lang.Class<?> clazz,
                                              Transformer transformer)
        Deprecated.
        Remove a specific encoding hook for a specific class. The transformer passed as the parameter must be equals to the transformer to remove.
        Parameters:
        clazz - the class to remove the encoding hook for
        transformer - the specific encoding hook to remove.
      • getDecodingHooks

        public static java.util.List<Transformer> getDecodingHooks​(java.lang.Class<?> clazz)
        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

        public static void removeDecodingHooks​(java.lang.Class<?> clazz)
        Deprecated.
        Remove all decoding hooks for a specific class.
        Parameters:
        clazz - the class to remove all the decoding hooks for
      • removeDecodingHook

        public static void removeDecodingHook​(java.lang.Class<?> clazz,
                                              Transformer transformer)
        Deprecated.
        Remove a specific encoding hook for a specific class. The transformer passed as the parameter must be equals to the transformer to remove.
        Parameters:
        clazz - the class to remove the decoding hook for
        transformer - the specific decoding hook to remove.
      • clearAllHooks

        public static void clearAllHooks()
        Deprecated.
        Remove all decoding and encoding hooks for all classes.
      • encode

        public static byte[] encode​(BSONObject doc)
        Deprecated.
        Encodes a DBObject as a BSON byte array.
        Parameters:
        doc - the document to encode
        Returns:
        the document encoded as BSON
      • decode

        public static BSONObject decode​(byte[] bytes)
        Deprecated.
        Decodes a BSON byte array into a DBObject instance.
        Parameters:
        bytes - a document encoded as BSON
        Returns:
        the document as a DBObject
      • regexFlags

        public static int regexFlags​(java.lang.String s)
        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:
        java.lang.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:
        java.lang.IllegalArgumentException - If sequence contains invalid flags.
      • regexFlags

        public static java.lang.String regexFlags​(int flags)
        Deprecated.
        Converts Java regular expression flags into regular expression modifiers from the database.
        Parameters:
        flags - the Java flags
        Returns:
        the Java flags
        Throws:
        java.lang.IllegalArgumentException - if some flags couldn't be recognized.
      • toInt

        public static int toInt​(java.lang.Object number)
        Deprecated.
        Provides an integer representation of Boolean or Number. If argument is Boolean, then 1 for true will be returned or @{code 0} otherwise. If argument is Number, then Number.intValue() will be called.
        Parameters:
        number - the number to convert to an int
        Returns:
        integer value
        Throws:
        java.lang.IllegalArgumentException - if the argument is null or not Boolean or Number