Package org.bson
Class BsonValue
java.lang.Object
org.bson.BsonValue
- Direct Known Subclasses:
 BsonArray,BsonBinary,BsonBoolean,BsonDateTime,BsonDbPointer,BsonDocument,BsonJavaScript,BsonJavaScriptWithScope,BsonMaxKey,BsonMinKey,BsonNull,BsonNumber,BsonObjectId,BsonRegularExpression,BsonString,BsonSymbol,BsonTimestamp,BsonUndefined
Base class for any BSON type.
- Since:
 - 3.0
 
- 
Method Summary
Modifier and TypeMethodDescriptionasArray()Gets this value as a BsonArray if it is one, otherwise throws exceptionasBinary()Gets this value as a BsonBinary if it is one, otherwise throws exceptionGets this value as a BsonBoolean if it is one, otherwise throws exceptionGets this value as a BsonDateTime if it is one, otherwise throws exceptionGets this value as a BsonDbPointer if it is one, otherwise throws exceptionGets this value as a BsonDecimal128 if it is one, otherwise throws exceptionGets this value as a BsonDocument if it is one, otherwise throws exceptionasDouble()Gets this value as a BsonDouble if it is one, otherwise throws exceptionasInt32()Gets this value as a BsonInt32 if it is one, otherwise throws exceptionasInt64()Gets this value as a BsonInt64 if it is one, otherwise throws exceptionGets this value as aBsonJavaScriptif it is one, otherwise throws exceptionGets this value as a BsonJavaScriptWithScope if it is one, otherwise throws exceptionasNumber()Gets this value as a BsonNumber if it is one, otherwise throws exceptionGets this value as an BsonObjectId if it is one, otherwise throws exceptionGets this value as a BsonRegularExpression if it is one, otherwise throws exceptionasString()Gets this value as a BsonString if it is one, otherwise throws exceptionasSymbol()Gets this value as a BsonSymbol if it is one, otherwise throws exceptionGets this value as a BsonTimestamp if it is one, otherwise throws exceptionabstract BsonTypeGets the BSON type of this value.booleanisArray()Returns true if this is a BsonArray, false otherwise.booleanisBinary()Returns true if this is a BsonBinary, false otherwise.booleanReturns true if this is a BsonBoolean, false otherwise.booleanReturns true if this is a BsonDateTime, false otherwise.booleanReturns true if this is a BsonDbPointer, false otherwise.booleanReturns true if this is a BsonDecimal128, false otherwise.booleanReturns true if this is a BsonDocument, false otherwise.booleanisDouble()Returns true if this is a BsonDouble, false otherwise.booleanisInt32()Returns true if this is a BsonInt32, false otherwise.booleanisInt64()Returns true if this is a BsonInt64, false otherwise.booleanReturns true if this is a BsonJavaScript, false otherwise.booleanReturns true if this is a BsonJavaScriptWithScope, false otherwise.booleanisNull()Returns true if this is a BsonNull, false otherwise.booleanisNumber()Returns true if this is a BsonNumber, false otherwise.booleanReturns true if this is an BsonObjectId, false otherwise.booleanReturns true if this is a BsonRegularExpression, false otherwise.booleanisString()Returns true if this is a BsonString, false otherwise.booleanisSymbol()Returns true if this is a BsonSymbol, false otherwise.booleanReturns true if this is a BsonTimestamp, false otherwise. 
- 
Method Details
- 
getBsonType
Gets the BSON type of this value.- Returns:
 - the BSON type, which may not be null (but may be BSONType.NULL)
 
 - 
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Gets this value as aBsonJavaScriptif it is one, otherwise throws exception- Returns:
 - a BsonJavaScript
 - Throws:
 BsonInvalidOperationException- if this value is not of the expected type
 - 
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
 
 
 -