Class 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()  
      boolean asBool()
      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.
      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.
      java.lang.Object asObject()
      Return an object of the appropriate type.
      java.lang.String asString()
      Returns the exact contents of a string value, or null for all other types.
      <T> java.util.List<T> asTypedArray()  
      long asUnsigned()
      Returns a value coerced to an unsigned integer.
      static FLValue fromData​(byte[] data)  
      static FLValue fromData​(FLSliceResult slice)  
      static java.lang.String getJSONForJSON5​(java.lang.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`.
      java.lang.String toJSON()
      Returns the json representation.
      java.lang.String toJSON5()
      Returns the string representation.
      static java.lang.Object toObject​(FLValue flValue)  
      java.lang.String toStr()
      Returns the string representation.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FLValue

        public FLValue​(long handle)
    • Method Detail

      • getJSONForJSON5

        @Nullable
        public static java.lang.String getJSONForJSON5​(@Nullable
                                                       java.lang.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 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