Class JsonObject
- java.lang.Object
-
- com.couchbase.client.java.document.json.JsonValue
-
- com.couchbase.client.java.document.json.JsonObject
-
- All Implemented Interfaces:
Serializable
public class JsonObject extends JsonValue implements Serializable
Represents a JSON object that can be stored and loaded from Couchbase Server. If boxed return values are unboxed, the calling code needs to make sure to handle potentialNullPointerException
s. TheJsonObject
is backed by aMap
and is intended to work similar to it API wise, but to only allow to store such objects which can be represented by JSON.- Since:
- 2.0
- Author:
- Michael Nitschinger, Simon Baslé
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENCRYPTION_PREFIX
Encryption prefix
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearEncryptionPaths()
Clear the encryption pathsboolean
containsKey(String name)
Checks if theJsonObject
contains the field name.boolean
containsValue(Object value)
Checks if theJsonObject
contains the value.static JsonObject
create()
Creates a emptyJsonObject
.static JsonObject
empty()
Creates a emptyJsonObject
.Map<String,String>
encryptionPathInfo()
Get the encryption list to merge path with parentboolean
equals(Object o)
static JsonObject
from(Map<String,?> mapData)
Constructs aJsonObject
from aMap<String, ?>
.static JsonObject
fromJson(String s)
Static method to create aJsonObject
from a JSONString
.Object
get(String name)
Retrieves the (potential null) content and not casting its type.Object
getAndDecrypt(String name, String providerName)
Retrieve and decrypt content and not casting its type Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc.JsonArray
getAndDecryptArray(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toJsonArray
.BigDecimal
getAndDecryptBigDecimal(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toBigDecimal
.BigInteger
getAndDecryptBigInteger(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toBigInteger
.Boolean
getAndDecryptBoolean(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toBoolean
.Double
getAndDecryptDouble(String name, String providerName)
Retrieves the value from the field name and casts it toDouble
.Integer
getAndDecryptInt(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toInteger
.Long
getAndDecryptLong(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toLong
.Number
getAndDecryptNumber(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toNumber
.JsonObject
getAndDecryptObject(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toJsonObject
.String
getAndDecryptString(String name, String providerName)
Retrieves the decrypted value from the field name and casts it toString
.JsonArray
getArray(String name)
Retrieves the value from the field name and casts it toJsonArray
.BigDecimal
getBigDecimal(String name)
Retrieves the value from the field name and casts it toBigDecimal
.BigInteger
getBigInteger(String name)
Retrieves the value from the field name and casts it toBigInteger
.Boolean
getBoolean(String name)
Retrieves the value from the field name and casts it toBoolean
.CryptoManager
getCryptoManager()
Get the encryption configuration for decryptionDouble
getDouble(String name)
Retrieves the value from the field name and casts it toDouble
.Integer
getInt(String name)
Retrieves the value from the field name and casts it toInteger
.Long
getLong(String name)
Retrieves the value from the field name and casts it toLong
.Set<String>
getNames()
Returns a set of field names on theJsonObject
.Number
getNumber(String name)
Retrieves the value from the field name and casts it toNumber
.JsonObject
getObject(String name)
Retrieves the value from the field name and casts it toJsonObject
.String
getString(String name)
Retrieves the value from the field name and casts it toString
.int
hashCode()
boolean
isEmpty()
Returns true if theJsonObject
is empty, false otherwise.boolean
isEncrypted(String name)
Returns true if the field is encrypted.JsonObject
put(String name, boolean value)
Stores aBoolean
value identified by the field name.JsonObject
put(String name, double value)
Stores aDouble
value identified by the field name.JsonObject
put(String name, int value)
Stores aInteger
value identified by the field name.JsonObject
put(String name, long value)
Stores aLong
value identified by the field name.JsonObject
put(String name, JsonArray value)
Stores aJsonArray
value identified by the field name.JsonObject
put(String name, JsonObject value)
Stores aJsonObject
value identified by the field name.JsonObject
put(String name, Number value)
Stores aNumber
value identified by the field name.JsonObject
put(String name, Object value)
Stores aObject
value identified by the field name.JsonObject
put(String name, String value)
Stores aString
value identified by the field name.JsonObject
put(String name, List<?> value)
Stores aJsonArray
value identified by the field name.JsonObject
put(String name, Map<String,?> value)
Attempt to convert aMap
to aJsonObject
value and store it, identified by the field name.JsonObject
putAndEncrypt(String name, boolean value, String providerName)
Stores aBoolean
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, double value, String providerName)
Stores aDouble
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, int value, String providerName)
Stores aInteger
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, long value, String providerName)
Stores aLong
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, JsonArray value, String providerName)
Stores aJsonArray
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, JsonObject value, String providerName)
Stores aJsonObject
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, Number value, String providerName)
Stores aNumber
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, Object value, String providerName)
Stores theObject
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, String value, String providerName)
Stores aString
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, List<?> value, String providerName)
Stores aJsonArray
value as encrypted identified by the field name.JsonObject
putAndEncrypt(String name, Map<String,?> value, String providerName)
Attempt to convert aMap
to aJsonObject
value and store it, as encrypted identified by the field name.JsonObject
putNull(String name)
Store a null value identified by the field's name.JsonObject
putNullAndEncrypt(String name, String providerName)
Store a null value as encrypted identified by the field's name.JsonObject
removeKey(String name)
Removes an entry from theJsonObject
.void
setCryptoManager(CryptoManager cryptoManager)
Set the encryption configuration for decryptionint
size()
The size of theJsonObject
.Map<String,Object>
toDecryptedMap(String providerName)
Transforms theJsonObject
into aMap
.String
toDecryptedString(String providerName)
Converts theJsonObject
into its decrypted JSON string representation.Map<String,Object>
toMap()
Transforms theJsonObject
into aMap
.String
toString()
Converts theJsonObject
into its JSON string representation.
-
-
-
Field Detail
-
ENCRYPTION_PREFIX
public static final String ENCRYPTION_PREFIX
Encryption prefix- See Also:
- Constant Field Values
-
-
Method Detail
-
empty
public static JsonObject empty()
Creates a emptyJsonObject
.- Returns:
- a empty
JsonObject
.
-
create
public static JsonObject create()
Creates a emptyJsonObject
.- Returns:
- a empty
JsonObject
.
-
from
public static JsonObject from(Map<String,?> mapData)
Constructs aJsonObject
from aMap<String, ?>
. This is only possible if the given Map is well formed, that is it contains non null keys, and all values are of a supported type. A null input Map or null key will lead to aNullPointerException
being thrown. If any unsupported value is present in the Map, anIllegalArgumentException
will be thrown. *Sub Maps and Lists* If possible, Maps and Lists contained in mapData will be converted to JsonObject and JsonArray respectively. However, same restrictions apply. Any non-convertible collection will raise aClassCastException
. If the sub-conversion raises an exception (like an IllegalArgumentException) then it is put as cause for the ClassCastException.- Parameters:
mapData
- the Map to convert to a JsonObject- Returns:
- the resulting JsonObject
- Throws:
IllegalArgumentException
- in case one or more unsupported values are presentNullPointerException
- in case a null map is provided or if it contains a null keyClassCastException
- if map contains a sub-Map or sub-List not supported (see above)
-
fromJson
public static JsonObject fromJson(String s)
Static method to create aJsonObject
from a JSONString
. The string is expected to be a valid JSON object representation (eg. starting with a '{').- Parameters:
s
- the JSON String to convert to aJsonObject
.- Returns:
- the corresponding
JsonObject
. - Throws:
IllegalArgumentException
- if the conversion cannot be done.
-
put
public JsonObject put(String name, Object value)
Stores aObject
value identified by the field name. Note that the value is checked and aIllegalArgumentException
is thrown if not supported.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, Object value, String providerName)
Stores theObject
value as encrypted identified by the field name. Note that the value is checked and aIllegalArgumentException
is thrown if not supported. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
get
public Object get(String name)
Retrieves the (potential null) content and not casting its type.- Parameters:
name
- the key of the field.- Returns:
- the value of the field, or null if it does not exist.
-
getAndDecrypt
public Object getAndDecrypt(String name, String providerName) throws Exception
Retrieve and decrypt content and not casting its type Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the key of the fieldproviderName
- the crypto algorithm provider name- Returns:
- the value of the field, or null if it does not exist
- Throws:
Exception
-
put
public JsonObject put(String name, String value)
Stores aString
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, String value, String providerName)
Stores aString
value as encrypted identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- the crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getString
public String getString(String name)
Retrieves the value from the field name and casts it toString
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptString
public String getAndDecryptString(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toString
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- the crypto provider name for decryption.- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, int value)
Stores aInteger
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, int value, String providerName)
Stores aInteger
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getInt
public Integer getInt(String name)
Retrieves the value from the field name and casts it toInteger
. Note that if value was stored as another numerical type, some truncation or rounding may occur.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptInt
@Committed public Integer getAndDecryptInt(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toInteger
. Note that if value was stored as another numerical type, some truncation or rounding may occur.- Parameters:
name
- the name of the field.providerName
- crypto provider name for decryption.- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, long value)
Stores aLong
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, long value, String providerName)
Stores aLong
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getLong
public Long getLong(String name)
Retrieves the value from the field name and casts it toLong
. Note that if value was stored as another numerical type, some truncation or rounding may occur.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptLong
public Long getAndDecryptLong(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toLong
. Note that if value was stored as another numerical type, some truncation or rounding may occur. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- the crypto provider name for decryption- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, double value)
Stores aDouble
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, double value, String providerName)
Stores aDouble
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getDouble
public Double getDouble(String name)
Retrieves the value from the field name and casts it toDouble
. Note that if value was stored as another numerical type, some truncation or rounding may occur.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptDouble
public Double getAndDecryptDouble(String name, String providerName) throws Exception
Retrieves the value from the field name and casts it toDouble
. Note that if value was stored as another numerical type, some truncation or rounding may occur. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- the crypto provider name for decryption- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, boolean value)
Stores aBoolean
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, boolean value, String providerName)
Stores aBoolean
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getBoolean
public Boolean getBoolean(String name)
Retrieves the value from the field name and casts it toBoolean
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptBoolean
public Boolean getAndDecryptBoolean(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toBoolean
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- the provider name of the field.- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, JsonObject value)
Stores aJsonObject
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, JsonObject value, String providerName)
Stores aJsonObject
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
put
public JsonObject put(String name, Map<String,?> value)
Attempt to convert aMap
to aJsonObject
value and store it, identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
. - See Also:
from(Map)
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, Map<String,?> value, String providerName)
Attempt to convert aMap
to aJsonObject
value and store it, as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
. - See Also:
from(Map)
-
getObject
public JsonObject getObject(String name)
Retrieves the value from the field name and casts it toJsonObject
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptObject
public JsonObject getAndDecryptObject(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toJsonObject
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- Crypto provider name for decryption- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
put
public JsonObject put(String name, JsonArray value)
Stores aJsonArray
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, JsonArray value, String providerName)
Stores aJsonArray
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- the crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
put
public JsonObject put(String name, Number value)
Stores aNumber
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, Number value, String providerName)
Stores aNumber
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
put
public JsonObject put(String name, List<?> value)
Stores aJsonArray
value identified by the field name.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.- Returns:
- the
JsonObject
.
-
putAndEncrypt
public JsonObject putAndEncrypt(String name, List<?> value, String providerName)
Stores aJsonArray
value as encrypted identified by the field name. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the JSON field.value
- the value of the JSON field.providerName
- the crypto provider name for encryption.- Returns:
- the
JsonObject
.
-
getArray
public JsonArray getArray(String name)
Retrieves the value from the field name and casts it toJsonArray
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptArray
public JsonArray getAndDecryptArray(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toJsonArray
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- crypto provider name for decryption.- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
getBigInteger
public BigInteger getBigInteger(String name)
Retrieves the value from the field name and casts it toBigInteger
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptBigInteger
public BigInteger getAndDecryptBigInteger(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toBigInteger
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- crypto provider name for decryption.- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
getBigDecimal
public BigDecimal getBigDecimal(String name)
Retrieves the value from the field name and casts it toBigDecimal
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptBigDecimal
public BigDecimal getAndDecryptBigDecimal(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toBigDecimal
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- crypto provider for decryption- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
getNumber
public Number getNumber(String name)
Retrieves the value from the field name and casts it toNumber
.- Parameters:
name
- the name of the field.- Returns:
- the result or null if it does not exist.
-
getAndDecryptNumber
public Number getAndDecryptNumber(String name, String providerName) throws Exception
Retrieves the decrypted value from the field name and casts it toNumber
. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the name of the field.providerName
- the crypto provider name for decryption- Returns:
- the result or null if it does not exist.
- Throws:
Exception
-
putNull
public JsonObject putNull(String name)
Store a null value identified by the field's name. This method is equivalent to callingput(String, Object)
with eitherJsonValue.NULL
or a null value explicitly cast to Object.- Parameters:
name
- The null field's name.- Returns:
- the
JsonObject
-
putNullAndEncrypt
public JsonObject putNullAndEncrypt(String name, String providerName)
Store a null value as encrypted identified by the field's name. This method is equivalent to callingput(String, Object)
with eitherJsonValue.NULL
or a null value explicitly cast to Object. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- The null field's name.providerName
- Crypto provider name for encryption.- Returns:
- the
JsonObject
-
removeKey
public JsonObject removeKey(String name)
Removes an entry from theJsonObject
.- Parameters:
name
- the name of the field to remove- Returns:
- the
JsonObject
-
getNames
public Set<String> getNames()
Returns a set of field names on theJsonObject
.- Returns:
- the set of names on the object.
-
isEmpty
public boolean isEmpty()
Returns true if theJsonObject
is empty, false otherwise.- Returns:
- true if empty, false otherwise.
-
toMap
public Map<String,Object> toMap()
Transforms theJsonObject
into aMap
. The resulting map is not backed by thisJsonObject
, and all sub-objects or sub-arrays (JsonArray
) are also recursively converted to maps and lists, respectively.- Returns:
- the content copied as a
Map
.
-
toDecryptedMap
public Map<String,Object> toDecryptedMap(String providerName) throws Exception
Transforms theJsonObject
into aMap
. The resulting map is not backed by thisJsonObject
, and all sub-objects or sub-arrays (JsonArray
) are also recursively converted to maps and lists, respectively. The encrypted values are decrypted. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.
-
containsKey
public boolean containsKey(String name)
Checks if theJsonObject
contains the field name.- Parameters:
name
- the name of the field.- Returns:
- true if its contained, false otherwise.
-
containsValue
public boolean containsValue(Object value)
Checks if theJsonObject
contains the value.- Parameters:
value
- the actual value.- Returns:
- true if its contained, false otherwise.
-
size
public int size()
The size of theJsonObject
.- Returns:
- the size.
-
isEncrypted
public boolean isEncrypted(String name)
Returns true if the field is encrypted. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Parameters:
name
- the key name of the field.
-
encryptionPathInfo
@Private public Map<String,String> encryptionPathInfo()
Get the encryption list to merge path with parent
-
clearEncryptionPaths
@Committed @Private public void clearEncryptionPaths()
Clear the encryption paths
-
setCryptoManager
@Private public void setCryptoManager(CryptoManager cryptoManager)
Set the encryption configuration for decryption
-
getCryptoManager
@Private public CryptoManager getCryptoManager()
Get the encryption configuration for decryption
-
toString
public String toString()
Converts theJsonObject
into its JSON string representation.- Overrides:
toString
in classObject
- Returns:
- the JSON string representing this
JsonObject
.
-
toDecryptedString
public String toDecryptedString(String providerName) throws Exception
Converts theJsonObject
into its decrypted JSON string representation. Note: Use of the Field Level Encryption functionality provided in the com.couchbase.client.encryption namespace provided by Couchbase is subject to the Couchbase Inc. Enterprise Subscription License Agreement at https://www.couchbase.com/ESLA-11132015.- Returns:
- the decrypted JSON string representing this
JsonObject
. - Throws:
Exception
-
-