Class FLValue
- java.lang.Object
-
- com.couchbase.lite.internal.fleece.FLValue
-
public class FLValue extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description FLValue(long handle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.Object>asArray()booleanasBool()Returns a value coerced to boolean.byte[]asData()Returns the exact contents of a data value, or null for all other types.java.util.Map<java.lang.String,java.lang.Object>asDict()If a FLValue represents an array, returns it cast to FLDict, else nullptr.doubleasDouble()Returns a value coerced to a 64-bit floating point number.FLDictasFLDict()Returns the contents as a dictionary.floatasFloat()Returns a value coerced to a 32-bit floating point number.longasInt()Returns a value coerced to an integer.java.lang.ObjectasObject()Return an object of the appropriate type.java.lang.StringasString()Returns the exact contents of a string value, or null for all other types.<T> java.util.List<T>asTypedArray()longasUnsigned()Returns a value coerced to an unsigned integer.static FLValuefromData(byte[] data)static FLValuefromData(FLSliceResult slice)static java.lang.StringgetJSONForJSON5(java.lang.String json5)Converts valid JSON5 to JSON.intgetType()Returns the data type of an arbitrary Value.booleanisDouble()Is this a 64-bit floating-point value?booleanisInteger()Is this value an integer?booleanisNumber()Is this value a number?booleanisUnsigned()Returns true if the value is non-nullptr and represents an _unsigned_ integer that can only be represented natively as a `uint64_t`.java.lang.StringtoJSON()Returns the json representation.java.lang.StringtoJSON5()Returns the string representation.static java.lang.ObjecttoObject(FLValue flValue)java.lang.StringtoStr()Returns the string representation.
-
-
-
Method Detail
-
fromData
@Nullable public static FLValue fromData(@Nullable FLSliceResult slice)
-
getJSONForJSON5
@Nullable public static java.lang.String getJSONForJSON5(@Nullable java.lang.String json5) throws LiteCoreExceptionConverts valid JSON5 to JSON.- Parameters:
json5- String- Returns:
- JSON String
- Throws:
LiteCoreException- on parse failure
-
fromData
@NonNull public static FLValue fromData(@NonNull byte[] data)
-
toObject
@Nullable public static java.lang.Object toObject(@NonNull FLValue flValue)
-
getType
public int getType()
Returns the data type of an arbitrary Value.- Returns:
- int (FLValueType)
-
isNumber
public boolean isNumber()
Is this value a number?- Returns:
- true if value is a number
-
isInteger
public boolean isInteger()
Is this value an integer?- Returns:
- true if value is a number
-
isUnsigned
public boolean isUnsigned()
Returns true if the value is non-nullptr and represents an _unsigned_ integer that can only be represented natively as a `uint64_t`.- Returns:
- boolean
-
isDouble
public boolean isDouble()
Is this a 64-bit floating-point value?- Returns:
- true if value is a double
-
toStr
@Nullable public java.lang.String toStr()
Returns the string representation.- Returns:
- string rep
-
toJSON
@Nullable public java.lang.String toJSON()
Returns the json representation.- Returns:
- json rep
-
toJSON5
@Nullable public java.lang.String toJSON5()
Returns the string representation.- Returns:
- json5 rep
-
asData
@NonNull public byte[] asData()
Returns the exact contents of a data value, or null for all other types.- Returns:
- byte[]
-
asBool
public boolean asBool()
Returns a value coerced to boolean.- Returns:
- boolean
-
asInt
public long asInt()
Returns a value coerced to an integer. NOTE: litecore treats integer with 2^64. So this JNI method returns long value- Returns:
- long
-
asUnsigned
public long asUnsigned()
Returns a value coerced to an unsigned integer.- Returns:
- long
-
asFloat
public float asFloat()
Returns a value coerced to a 32-bit floating point number.- Returns:
- float
-
asDouble
public double asDouble()
Returns a value coerced to a 64-bit floating point number.- Returns:
- double
-
asString
@NonNull public java.lang.String asString()
Returns the exact contents of a string value, or null for all other types. !!! If we are out of memory or the string cannot be decoded, we just lose it- Returns:
- String
-
asArray
@NonNull public java.util.List<java.lang.Object> asArray()
-
asTypedArray
@NonNull public <T> java.util.List<T> asTypedArray()
-
asFLDict
@NonNull public FLDict asFLDict()
Returns the contents as a dictionary.- Returns:
- String
-
asDict
@NonNull public java.util.Map<java.lang.String,java.lang.Object> asDict()
If a FLValue represents an array, returns it cast to FLDict, else nullptr.- Returns:
- long (FLDict)
-
asObject
@Nullable public java.lang.Object asObject()
Return an object of the appropriate type.- Returns:
- Object
-
-