Class FLValue


  • public class FLValue
    extends Object
    • Constructor Detail

      • FLValue

        public FLValue​(long handle)
    • Method Detail

      • 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)
      • toObject

        @Nullable
        public static 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 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
      • asArray

        @NonNull
        public List<Object> asArray()
      • 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