Package oracle.nosql.driver.values
Class BinaryValue
java.lang.Object
oracle.nosql.driver.values.FieldValue
oracle.nosql.driver.values.BinaryValue
- All Implemented Interfaces:
Comparable<FieldValue>
A
FieldValue
instance representing a binary value. Instances of
BinaryValue are only created by construction or returned by data operations.
They will never be directly created by parsing JSON. On input a Base64
encoded string can be accepted as a binary type if the database type is
binary for the field. When represented as JSON this object is encoded
as Base64 using encodeBase64(byte[])
.-
Nested Class Summary
Nested classes/interfaces inherited from class oracle.nosql.driver.values.FieldValue
FieldValue.Type
-
Constructor Summary
ConstructorDescriptionBinaryValue
(byte[] value) Creates a new instance.BinaryValue
(String value) Creates a new instance from a Base64 encoded string. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(FieldValue other) Returns 0 if the two values are equal in terms of length and byte content, otherwise it returns -1.static byte[]
decodeBase64
(String binString) Decode the specified Base64 string into a byte array.static String
encodeBase64
(byte[] buffer) Encode the specified byte array into a Base64 encoded string.boolean
getType()
Returns the type of the objectbyte[]
getValue()
Returns the binary value of this objectint
hashCode()
toJson
(JsonOptions options) Returns a quoted string of the value as Base64.Methods inherited from class oracle.nosql.driver.values.FieldValue
asArray, asBinary, asBoolean, asDouble, asInteger, asJsonNull, asLong, asMap, asNull, asNumber, asString, asTimestamp, castAsDouble, createFromJson, createFromJson, createFromJson, getBinary, getBoolean, getDouble, getInt, getLong, getNumber, getSerializedSize, getString, getTimestamp, isAnyNull, isArray, isAtomic, isBinary, isBoolean, isDouble, isInteger, isJsonNull, isLong, isMap, isNull, isNumber, isNumeric, isString, isTimestamp, toJson, toString
-
Constructor Details
-
BinaryValue
public BinaryValue(byte[] value) Creates a new instance.- Parameters:
value
- the value to use
-
BinaryValue
Creates a new instance from a Base64 encoded string.- Parameters:
value
- the value to use- Throws:
IllegalArgumentException
- if the value is not a valid Base64 encoded value.
-
-
Method Details
-
getType
Description copied from class:FieldValue
Returns the type of the object- Specified by:
getType
in classFieldValue
- Returns:
- the type
-
getValue
public byte[] getValue()Returns the binary value of this object- Returns:
- the binary value
-
compareTo
Returns 0 if the two values are equal in terms of length and byte content, otherwise it returns -1. -
toJson
Returns a quoted string of the value as Base64.- Overrides:
toJson
in classFieldValue
- Parameters:
options
- configurable options used to affect the JSON output format of some data types. May be null.- Returns:
- a quoted, Base64-encoded string encoded using
encodeBase64(byte[])
.
-
equals
-
hashCode
public int hashCode() -
encodeBase64
Encode the specified byte array into a Base64 encoded string. This string can be decoded usingdecodeBase64(java.lang.String)
.- Parameters:
buffer
- the input buffer- Returns:
- the encoded string
-
decodeBase64
Decode the specified Base64 string into a byte array. The string must have been encoded usingencodeBase64(byte[])
or the same algorithm.- Parameters:
binString
- the encoded input string- Returns:
- the decoded array
- Throws:
IllegalArgumentException
- if the value is not a valid Base64 encoded value.
-