Package org.bson
Class BsonBinary
java.lang.Object
org.bson.BsonValue
org.bson.BsonBinary
A representation of the BSON Binary type. Note that for performance reasons instances of this class are not immutable,
so care should be taken to only modify the underlying byte array if you know what you're doing, or else make a defensive copy.
- Since:
- 3.0
-
Constructor Summary
ConstructorDescriptionBsonBinary
(byte[] data) Construct a new instance with the given data and the default sub-typeBsonBinary
(byte type, byte[] data) Construct a new instance with the given data and binary sub type.BsonBinary
(UUID uuid) Construct a Type 4 BsonBinary from the given UUID.BsonBinary
(UUID uuid, UuidRepresentation uuidRepresentation) Construct a new instance from the given UUID and UuidRepresentationBsonBinary
(BsonBinarySubType type, byte[] data) Construct a new instance with the given data and binary sub type. -
Method Summary
Modifier and TypeMethodDescriptionasUuid()
Returns the binary as a UUID.asUuid
(UuidRepresentation uuidRepresentation) Returns the binary as a UUID.boolean
Gets the BSON type of this value.byte[]
getData()
Gets the data of this Binary.byte
getType()
Gets the type of this Binary.int
hashCode()
toString()
Methods inherited from class org.bson.BsonValue
asArray, asBinary, asBoolean, asDateTime, asDBPointer, asDecimal128, asDocument, asDouble, asInt32, asInt64, asJavaScript, asJavaScriptWithScope, asNumber, asObjectId, asRegularExpression, asString, asSymbol, asTimestamp, isArray, isBinary, isBoolean, isDateTime, isDBPointer, isDecimal128, isDocument, isDouble, isInt32, isInt64, isJavaScript, isJavaScriptWithScope, isNull, isNumber, isObjectId, isRegularExpression, isString, isSymbol, isTimestamp
-
Constructor Details
-
BsonBinary
public BsonBinary(byte[] data) Construct a new instance with the given data and the default sub-type- Parameters:
data
- the data- See Also:
-
BsonBinary
Construct a new instance with the given data and binary sub type.- Parameters:
data
- the datatype
- the binary sub type- See Also:
-
BsonBinary
public BsonBinary(byte type, byte[] data) Construct a new instance with the given data and binary sub type.- Parameters:
data
- the datatype
- the binary sub type- See Also:
-
BsonBinary
Construct a Type 4 BsonBinary from the given UUID.- Parameters:
uuid
- the UUID- Since:
- 3.9
-
BsonBinary
Construct a new instance from the given UUID and UuidRepresentation- Parameters:
uuid
- the UUIDuuidRepresentation
- the UUID representation- Since:
- 3.9
-
-
Method Details
-
asUuid
Returns the binary as a UUID. The binary type must be 4.- Returns:
- the uuid
- Since:
- 3.9
-
asUuid
Returns the binary as a UUID.- Parameters:
uuidRepresentation
- the UUID representation- Returns:
- the uuid
- Since:
- 3.9
-
getBsonType
Description copied from class:BsonValue
Gets the BSON type of this value.- Specified by:
getBsonType
in classBsonValue
- Returns:
- the BSON type, which may not be null (but may be BSONType.NULL)
-
getType
public byte getType()Gets the type of this Binary.- Returns:
- the type
-
getData
public byte[] getData()Gets the data of this Binary.This method returns the internal copy of the byte array, so only modify the contents of the returned array if the intention is to change the state of this instance.
- Returns:
- the data
-
equals
-
hashCode
public int hashCode() -
toString
-