Class FLValue
- java.lang.Object
-
- com.couchbase.lite.internal.fleece.FLValue
-
public class FLValue extends Object
-
-
Constructor Summary
Constructors Constructor Description FLValue(long handle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Object>
asArray()
boolean
asBool()
Returns a value coerced to boolean.byte[]
asData()
Returns the exact contents of a data value, or null for all other types.Map<String,Object>
asDict()
If a FLValue represents an array, returns it cast to FLDict, else nullptr.double
asDouble()
Returns a value coerced to a 64-bit floating point number.FLDict
asFLDict()
Returns the contents as a dictionary.float
asFloat()
Returns a value coerced to a 32-bit floating point number.long
asInt()
Returns a value coerced to an integer.Object
asObject()
Return an object of the appropriate type.String
asString()
Returns the exact contents of a string value, or null for all other types.<T> List<T>
asTypedArray()
long
asUnsigned()
Returns a value coerced to an unsigned integer.static FLValue
fromData(byte[] data)
static FLValue
fromData(FLSliceResult slice)
static String
getJSONForJSON5(String json5)
Converts valid JSON5 to JSON.int
getType()
Returns the data type of an arbitrary Value.boolean
isDouble()
Is this a 64-bit floating-point value?boolean
isInteger()
Is this value an integer?boolean
isNumber()
Is this value a number?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`.String
toJSON()
Returns the json representation.String
toJSON5()
Returns the string representation.static Object
toObject(FLValue flValue)
String
toStr()
Returns the string representation.
-
-
-
Method Detail
-
fromData
@Nullable public static FLValue fromData(@Nullable FLSliceResult slice)
-
getJSONForJSON5
@Nullable public static String getJSONForJSON5(@Nullable String json5) throws LiteCoreException
Converts valid JSON5 to JSON.- Parameters:
json5
- String- Returns:
- JSON String
- Throws:
LiteCoreException
- on parse failure
-
fromData
@NonNull public static FLValue fromData(@NonNull byte[] data)
-
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 String toStr()
Returns the string representation.- Returns:
- string rep
-
toJSON
@Nullable public String toJSON()
Returns the json representation.- Returns:
- json rep
-
toJSON5
@Nullable public 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 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
-
asTypedArray
@NonNull public <T> List<T> asTypedArray()
-
asFLDict
@NonNull public FLDict asFLDict()
Returns the contents as a dictionary.- Returns:
- String
-
asDict
@NonNull public Map<String,Object> asDict()
If a FLValue represents an array, returns it cast to FLDict, else nullptr.- Returns:
- long (FLDict)
-
asObject
@Nullable public Object asObject()
Return an object of the appropriate type.- Returns:
- Object
-
-