Package org.bson

Class BsonValue

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      BsonArray asArray()
      Gets this value as a BsonArray if it is one, otherwise throws exception
      BsonBinary asBinary()
      Gets this value as a BsonBinary if it is one, otherwise throws exception
      BsonBoolean asBoolean()
      Gets this value as a BsonBoolean if it is one, otherwise throws exception
      BsonDateTime asDateTime()
      Gets this value as a BsonDateTime if it is one, otherwise throws exception
      BsonDbPointer asDBPointer()
      Gets this value as a BsonDbPointer if it is one, otherwise throws exception
      BsonDecimal128 asDecimal128()
      Gets this value as a BsonDecimal128 if it is one, otherwise throws exception
      BsonDocument asDocument()
      Gets this value as a BsonDocument if it is one, otherwise throws exception
      BsonDouble asDouble()
      Gets this value as a BsonDouble if it is one, otherwise throws exception
      BsonInt32 asInt32()
      Gets this value as a BsonInt32 if it is one, otherwise throws exception
      BsonInt64 asInt64()
      Gets this value as a BsonInt64 if it is one, otherwise throws exception
      BsonJavaScript asJavaScript()
      Gets this value as a BsonJavaScript if it is one, otherwise throws exception
      BsonJavaScriptWithScope asJavaScriptWithScope()
      Gets this value as a BsonJavaScriptWithScope if it is one, otherwise throws exception
      BsonNumber asNumber()
      Gets this value as a BsonNumber if it is one, otherwise throws exception
      BsonObjectId asObjectId()
      Gets this value as an BsonObjectId if it is one, otherwise throws exception
      BsonRegularExpression asRegularExpression()
      Gets this value as a BsonRegularExpression if it is one, otherwise throws exception
      BsonString asString()
      Gets this value as a BsonString if it is one, otherwise throws exception
      BsonSymbol asSymbol()
      Gets this value as a BsonSymbol if it is one, otherwise throws exception
      BsonTimestamp asTimestamp()
      Gets this value as a BsonTimestamp if it is one, otherwise throws exception
      abstract BsonType getBsonType()
      Gets the BSON type of this value.
      boolean isArray()
      Returns true if this is a BsonArray, false otherwise.
      boolean isBinary()
      Returns true if this is a BsonBinary, false otherwise.
      boolean isBoolean()
      Returns true if this is a BsonBoolean, false otherwise.
      boolean isDateTime()
      Returns true if this is a BsonDateTime, false otherwise.
      boolean isDBPointer()
      Returns true if this is a BsonDbPointer, false otherwise.
      boolean isDecimal128()
      Returns true if this is a BsonDecimal128, false otherwise.
      boolean isDocument()
      Returns true if this is a BsonDocument, false otherwise.
      boolean isDouble()
      Returns true if this is a BsonDouble, false otherwise.
      boolean isInt32()
      Returns true if this is a BsonInt32, false otherwise.
      boolean isInt64()
      Returns true if this is a BsonInt64, false otherwise.
      boolean isJavaScript()
      Returns true if this is a BsonJavaScript, false otherwise.
      boolean isJavaScriptWithScope()
      Returns true if this is a BsonJavaScriptWithScope, false otherwise.
      boolean isNull()
      Returns true if this is a BsonNull, false otherwise.
      boolean isNumber()
      Returns true if this is a BsonNumber, false otherwise.
      boolean isObjectId()
      Returns true if this is an BsonObjectId, false otherwise.
      boolean isRegularExpression()
      Returns true if this is a BsonRegularExpression, false otherwise.
      boolean isString()
      Returns true if this is a BsonString, false otherwise.
      boolean isSymbol()
      Returns true if this is a BsonSymbol, false otherwise.
      boolean isTimestamp()
      Returns true if this is a BsonTimestamp, false otherwise.
      • Methods inherited from class java.lang.Object

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

      • getBsonType

        public abstract BsonType getBsonType()
        Gets the BSON type of this value.
        Returns:
        the BSON type, which may not be null (but may be BSONType.NULL)
      • asDocument

        public BsonDocument asDocument()
        Gets this value as a BsonDocument if it is one, otherwise throws exception
        Returns:
        a BsonDocument
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asArray

        public BsonArray asArray()
        Gets this value as a BsonArray if it is one, otherwise throws exception
        Returns:
        a BsonArray
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asString

        public BsonString asString()
        Gets this value as a BsonString if it is one, otherwise throws exception
        Returns:
        a BsonString
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asNumber

        public BsonNumber asNumber()
        Gets this value as a BsonNumber if it is one, otherwise throws exception
        Returns:
        a BsonNumber
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asInt32

        public BsonInt32 asInt32()
        Gets this value as a BsonInt32 if it is one, otherwise throws exception
        Returns:
        a BsonInt32
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asInt64

        public BsonInt64 asInt64()
        Gets this value as a BsonInt64 if it is one, otherwise throws exception
        Returns:
        a BsonInt64
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asDecimal128

        public BsonDecimal128 asDecimal128()
        Gets this value as a BsonDecimal128 if it is one, otherwise throws exception
        Returns:
        a BsonDecimal128
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
        Since:
        3.4
      • asDouble

        public BsonDouble asDouble()
        Gets this value as a BsonDouble if it is one, otherwise throws exception
        Returns:
        a BsonDouble
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asBoolean

        public BsonBoolean asBoolean()
        Gets this value as a BsonBoolean if it is one, otherwise throws exception
        Returns:
        a BsonBoolean
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asObjectId

        public BsonObjectId asObjectId()
        Gets this value as an BsonObjectId if it is one, otherwise throws exception
        Returns:
        an BsonObjectId
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asDBPointer

        public BsonDbPointer asDBPointer()
        Gets this value as a BsonDbPointer if it is one, otherwise throws exception
        Returns:
        an BsonDbPointer
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asTimestamp

        public BsonTimestamp asTimestamp()
        Gets this value as a BsonTimestamp if it is one, otherwise throws exception
        Returns:
        an BsonTimestamp
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asBinary

        public BsonBinary asBinary()
        Gets this value as a BsonBinary if it is one, otherwise throws exception
        Returns:
        an BsonBinary
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asDateTime

        public BsonDateTime asDateTime()
        Gets this value as a BsonDateTime if it is one, otherwise throws exception
        Returns:
        an BsonDateTime
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asSymbol

        public BsonSymbol asSymbol()
        Gets this value as a BsonSymbol if it is one, otherwise throws exception
        Returns:
        an BsonSymbol
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asRegularExpression

        public BsonRegularExpression asRegularExpression()
        Gets this value as a BsonRegularExpression if it is one, otherwise throws exception
        Returns:
        an BsonRegularExpression
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asJavaScript

        public BsonJavaScript asJavaScript()
        Gets this value as a BsonJavaScript if it is one, otherwise throws exception
        Returns:
        a BsonJavaScript
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • asJavaScriptWithScope

        public BsonJavaScriptWithScope asJavaScriptWithScope()
        Gets this value as a BsonJavaScriptWithScope if it is one, otherwise throws exception
        Returns:
        a BsonJavaScriptWithScope
        Throws:
        BsonInvalidOperationException - if this value is not of the expected type
      • isNull

        public boolean isNull()
        Returns true if this is a BsonNull, false otherwise.
        Returns:
        true if this is a BsonNull, false otherwise
      • isDocument

        public boolean isDocument()
        Returns true if this is a BsonDocument, false otherwise.
        Returns:
        true if this is a BsonDocument, false otherwise
      • isArray

        public boolean isArray()
        Returns true if this is a BsonArray, false otherwise.
        Returns:
        true if this is a BsonArray, false otherwise
      • isString

        public boolean isString()
        Returns true if this is a BsonString, false otherwise.
        Returns:
        true if this is a BsonString, false otherwise
      • isNumber

        public boolean isNumber()
        Returns true if this is a BsonNumber, false otherwise.
        Returns:
        true if this is a BsonNumber, false otherwise
      • isInt32

        public boolean isInt32()
        Returns true if this is a BsonInt32, false otherwise.
        Returns:
        true if this is a BsonInt32, false otherwise
      • isInt64

        public boolean isInt64()
        Returns true if this is a BsonInt64, false otherwise.
        Returns:
        true if this is a BsonInt64, false otherwise
      • isDecimal128

        public boolean isDecimal128()
        Returns true if this is a BsonDecimal128, false otherwise.
        Returns:
        true if this is a BsonDecimal128, false otherwise
        Since:
        3.4
      • isDouble

        public boolean isDouble()
        Returns true if this is a BsonDouble, false otherwise.
        Returns:
        true if this is a BsonDouble, false otherwise
      • isBoolean

        public boolean isBoolean()
        Returns true if this is a BsonBoolean, false otherwise.
        Returns:
        true if this is a BsonBoolean, false otherwise
      • isObjectId

        public boolean isObjectId()
        Returns true if this is an BsonObjectId, false otherwise.
        Returns:
        true if this is an BsonObjectId, false otherwise
      • isDBPointer

        public boolean isDBPointer()
        Returns true if this is a BsonDbPointer, false otherwise.
        Returns:
        true if this is a BsonDbPointer, false otherwise
      • isTimestamp

        public boolean isTimestamp()
        Returns true if this is a BsonTimestamp, false otherwise.
        Returns:
        true if this is a BsonTimestamp, false otherwise
      • isBinary

        public boolean isBinary()
        Returns true if this is a BsonBinary, false otherwise.
        Returns:
        true if this is a BsonBinary, false otherwise
      • isDateTime

        public boolean isDateTime()
        Returns true if this is a BsonDateTime, false otherwise.
        Returns:
        true if this is a BsonDateTime, false otherwise
      • isSymbol

        public boolean isSymbol()
        Returns true if this is a BsonSymbol, false otherwise.
        Returns:
        true if this is a BsonSymbol, false otherwise
      • isRegularExpression

        public boolean isRegularExpression()
        Returns true if this is a BsonRegularExpression, false otherwise.
        Returns:
        true if this is a BsonRegularExpression, false otherwise
      • isJavaScript

        public boolean isJavaScript()
        Returns true if this is a BsonJavaScript, false otherwise.
        Returns:
        true if this is a BsonJavaScript, false otherwise
      • isJavaScriptWithScope

        public boolean isJavaScriptWithScope()
        Returns true if this is a BsonJavaScriptWithScope, false otherwise.
        Returns:
        true if this is a BsonJavaScriptWithScope, false otherwise