Package org.bson

Class BasicBSONCallback

    • Constructor Summary

      Constructors 
      Constructor Description
      BasicBSONCallback()
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void  name,  value)
      Puts a new value into the document.
      arrayDone()
      Called the end of the array, and returns the completed array.
      void arrayStart()
      Signals the start of a BSON array.
      void  name)
      Signals the start of a BSON array, with its field name.
      BSONObject create()
      Factory method for creating a new BSONObject.
      BSONObject create​(boolean array, <> path)
      Helper method to create either a BSON Object or a BSON List depending upon whether the array parameter is true or not.
      BSONCallback createBSONCallback()
      Factory method for BSONCallbacks.
      protected BSONObject createList()
      Factory method for creating a new BSON List.
      protected BSONObject cur()
      Gets the current value
      protected curName()
      Gets the name of the current field
      get()
      Returns the finished top-level Document.
      void  name, byte type, byte[] data)
      Called when reading a field with a BsonType.BINARY value.
      void  name, byte[] data)
      Deprecated.
      void  name, boolean value)
      Called when reading a field with a BsonType.BOOLEAN value.
      void  name,  code)
      Called when reading a field with a BsonType.JAVASCRIPT value.
      void  name,  code,  scope)
      Called when reading a field with a BsonType.JAVASCRIPT_WITH_SCOPE value.
      void  name, long millis)
      Called when reading a field with a BsonType.DATE_TIME value.
      void  name,  namespace, ObjectId id)
      Invoked when BSONDecoder encountered a BsonType.DB_POINTER type field in a byte sequence.
      void  name, Decimal128 value)
      Called when reading a field with a BsonType.DECIMAL128 value.
      void  name, double value)
      Called when reading a field with a BsonType.DOUBLE value.
      void  name, int value)
      Called when reading a field with a BsonType.INT32 value.
      void  name, long value)
      Called when reading a field with a BsonType.INT64 value.
      void  name)
      Called when reading a field with a BsonType.MAX_KEY value.
      void  name)
      Called when reading a field with a BsonType.MIN_KEY value.
      void  name)
      Called when reading a BSON field that exists but has a null value.
      void  name, ObjectId id)
      Called when reading a field with a BsonType.OBJECT_ID value.
      void  name,  pattern,  flags)
      Called when reading a field with a BsonType.REGULAR_EXPRESSION value.
      void  name,  value)
      Called when reading a field with a BsonType.STRING value.
      void  name,  value)
      Called when reading a field with a BsonType.SYMBOL value.
      void  name, int time, int increment)
      Called when reading a field with a BsonType.TIMESTAMP value.
      void  name)
      Called when reading a field with a BsonType.UNDEFINED value.
      void  name, long part1, long part2)
      Called when reading a field with a value.
      protected boolean isStackEmpty()
      Returns whether this is the top level or not
      objectDone()
      Called at the end of the document/array, and returns this object.
      void objectStart()
      Signals the start of a BSON document, which usually maps onto some Java object.
      void  name)
      Signals the start of a BSON document, which usually maps onto some Java object.
      void reset()
      Resets the callback, clearing all state.
      protected void  root)
      Sets the root document for this position
      • Methods inherited from class java.lang.

        , , , , , , , , , ,
    • Constructor Detail

      • BasicBSONCallback

        public BasicBSONCallback()
        Creates a new instance.
    • Method Detail

      • get

        public  get()
        Description copied from interface: BSONCallback
        Returns the finished top-level Document.
        Specified by:
        get in interface BSONCallback
        Returns:
        the top level document read from the database.
      • create

        public BSONObject create()
        Factory method for creating a new BSONObject.
        Returns:
        a new BasicBSONObject.
      • createList

        protected BSONObject createList()
        Factory method for creating a new BSON List.
        Returns:
        a new BasicBSONList.
      • create

        public BSONObject create​(boolean array,
                                 <> path)
        Helper method to create either a BSON Object or a BSON List depending upon whether the array parameter is true or not.
        Parameters:
        array - set to true to create a new BSON List, otherwise will create a new BSONObject
        path - a list of field names to navigate to this field in the document
        Returns:
        the new BSONObject
      • objectStart

        public void objectStart()
        Description copied from interface: BSONCallback
        Signals the start of a BSON document, which usually maps onto some Java object.
        Specified by:
        objectStart in interface BSONCallback
      • objectStart

        public void objectStart​( name)
        Description copied from interface: BSONCallback
        Signals the start of a BSON document, which usually maps onto some Java object.
        Specified by:
        objectStart in interface BSONCallback
        Parameters:
        name - the field name of the document.
      • objectDone

        public  objectDone()
        Description copied from interface: BSONCallback
        Called at the end of the document/array, and returns this object.
        Specified by:
        objectDone in interface BSONCallback
        Returns:
        the Object that has been read from this section of the document.
      • arrayStart

        public void arrayStart()
        Description copied from interface: BSONCallback
        Signals the start of a BSON array.
        Specified by:
        arrayStart in interface BSONCallback
      • arrayStart

        public void arrayStart​( name)
        Description copied from interface: BSONCallback
        Signals the start of a BSON array, with its field name.
        Specified by:
        arrayStart in interface BSONCallback
        Parameters:
        name - the name of this array field
      • arrayDone

        public  arrayDone()
        Description copied from interface: BSONCallback
        Called the end of the array, and returns the completed array.
        Specified by:
        arrayDone in interface BSONCallback
        Returns:
        an Object representing the array that has been read from this section of the document.
      • gotNull

        public void gotNull​( name)
        Description copied from interface: BSONCallback
        Called when reading a BSON field that exists but has a null value.
        Specified by:
        gotNull in interface BSONCallback
        Parameters:
        name - the name of the field
        See Also:
        BsonType.NULL
      • gotMinKey

        public void gotMinKey​( name)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.MIN_KEY value.
        Specified by:
        gotMinKey in interface BSONCallback
        Parameters:
        name - the name of the field
      • gotMaxKey

        public void gotMaxKey​( name)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.MAX_KEY value.
        Specified by:
        gotMaxKey in interface BSONCallback
        Parameters:
        name - the name of the field
      • gotBoolean

        public void gotBoolean​( name,
                               boolean value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.BOOLEAN value.
        Specified by:
        gotBoolean in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotDouble

        public void gotDouble​( name,
                              double value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.DOUBLE value.
        Specified by:
        gotDouble in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotInt

        public void gotInt​( name,
                           int value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.INT32 value.
        Specified by:
        gotInt in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotLong

        public void gotLong​( name,
                            long value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.INT64 value.
        Specified by:
        gotLong in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotDate

        public void gotDate​( name,
                            long millis)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.DATE_TIME value.
        Specified by:
        gotDate in interface BSONCallback
        Parameters:
        name - the name of the field
        millis - the date and time in milliseconds
      • gotRegex

        public void gotRegex​( name,
                              pattern,
                              flags)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.REGULAR_EXPRESSION value.
        Specified by:
        gotRegex in interface BSONCallback
        Parameters:
        name - the name of the field
        pattern - the regex pattern
        flags - the optional flags for the regular expression
      • gotString

        public void gotString​( name,
                               value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.STRING value.
        Specified by:
        gotString in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotSymbol

        public void gotSymbol​( name,
                               value)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.SYMBOL value.
        Specified by:
        gotSymbol in interface BSONCallback
        Parameters:
        name - the name of the field
        value - the field's value
      • gotTimestamp

        public void gotTimestamp​( name,
                                 int time,
                                 int increment)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.TIMESTAMP value.
        Specified by:
        gotTimestamp in interface BSONCallback
        Parameters:
        name - the name of the field
        time - the time in seconds since epoch
        increment - an incrementing ordinal for operations within a given second
      • gotDBRef

        public void gotDBRef​( name,
                              namespace,
                             ObjectId id)
        Description copied from interface: BSONCallback
        Invoked when BSONDecoder encountered a BsonType.DB_POINTER type field in a byte sequence.
        Specified by:
        gotDBRef in interface BSONCallback
        Parameters:
        name - the name of the field
        namespace - the namespace to which reference is pointing to
        id - the if of the object to which reference is pointing to
      • gotBinaryArray

        public void gotBinaryArray​( name,
                                   byte[] data)
        Deprecated.
        Description copied from interface: BSONCallback
        This method is not used.
        Specified by:
        gotBinaryArray in interface BSONCallback
        Parameters:
        name - the name of the field
        data - the field's value
      • gotBinary

        public void gotBinary​( name,
                              byte type,
                              byte[] data)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.BINARY value. Note that binary values have a subtype, which may determine how the value is processed.
        Specified by:
        gotBinary in interface BSONCallback
        Parameters:
        name - the name of the field
        type - one of the binary subtypes: BsonBinarySubType
        data - the field's value
      • gotUUID

        public void gotUUID​( name,
                            long part1,
                            long part2)
        Description copied from interface: BSONCallback
        Called when reading a field with a value. This is a binary value of subtype BsonBinarySubType.UUID_LEGACY
        Specified by:
        gotUUID in interface BSONCallback
        Parameters:
        name - the name of the field
        part1 - the first part of the UUID
        part2 - the second part of the UUID
      • gotCode

        public void gotCode​( name,
                             code)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.JAVASCRIPT value.
        Specified by:
        gotCode in interface BSONCallback
        Parameters:
        name - the name of the field
        code - the JavaScript code
      • gotCodeWScope

        public void gotCodeWScope​( name,
                                   code,
                                   scope)
        Description copied from interface: BSONCallback
        Called when reading a field with a BsonType.JAVASCRIPT_WITH_SCOPE value.
        Specified by:
        gotCodeWScope in interface BSONCallback
        Parameters:
        name - the name of the field
        code - the JavaScript code
        scope - a document representing the scope for the code
      • _put

        protected void _put​( name,
                             value)
        Puts a new value into the document.
        Parameters:
        name - the name of the field
        value - the value
      • cur

        protected BSONObject cur()
        Gets the current value
        Returns:
        the current value
      • curName

        protected  curName()
        Gets the name of the current field
        Returns:
        the name of the current field.
      • setRoot

        protected void setRoot​( root)
        Sets the root document for this position
        Parameters:
        root - the new root document
      • isStackEmpty

        protected boolean isStackEmpty()
        Returns whether this is the top level or not
        Returns:
        true if there's nothing on the stack, and this is the top level of the document.
      • reset

        public void reset()
        Description copied from interface: BSONCallback
        Resets the callback, clearing all state.
        Specified by:
        reset in interface BSONCallback