Class AbstractJsonProvider

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getArrayIndex​(java.lang.Object obj, int idx)
      Extracts a value from an array
      java.lang.Object getArrayIndex​(java.lang.Object obj, int idx, boolean unwrap)
      Extracts a value from an array
      java.lang.Object getMapValue​(java.lang.Object obj, java.lang.String key)
      Extracts a value from an map
      java.util.Collection<java.lang.String> getPropertyKeys​(java.lang.Object obj)
      Returns the keys from the given object
      boolean isArray​(java.lang.Object obj)
      checks if object is an array
      boolean isMap​(java.lang.Object obj)
      checks if object is a map (i.e.
      int length​(java.lang.Object obj)
      Get the length of an array or object
      void removeProperty​(java.lang.Object obj, java.lang.Object key)
      Removes a value in an object or array
      void setArrayIndex​(java.lang.Object array, int index, java.lang.Object newValue)
      Sets a value in an array.
      void setProperty​(java.lang.Object obj, java.lang.Object key, java.lang.Object value)
      Sets a value in an object
      java.lang.Iterable<? extends java.lang.Object> toIterable​(java.lang.Object obj)
      Converts given array to an Iterable
      java.lang.Object unwrap​(java.lang.Object obj)
      Extracts a value from a wrapper object.
      • Methods inherited from class java.lang.Object

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

      • AbstractJsonProvider

        public AbstractJsonProvider()
    • Method Detail

      • isArray

        public boolean isArray​(java.lang.Object obj)
        checks if object is an array
        Specified by:
        isArray in interface JsonProvider
        Parameters:
        obj - object to check
        Returns:
        true if obj is an array
      • getArrayIndex

        public java.lang.Object getArrayIndex​(java.lang.Object obj,
                                              int idx)
        Extracts a value from an array
        Specified by:
        getArrayIndex in interface JsonProvider
        Parameters:
        obj - an array
        idx - index
        Returns:
        the entry at the given index
      • getArrayIndex

        public final java.lang.Object getArrayIndex​(java.lang.Object obj,
                                                    int idx,
                                                    boolean unwrap)
        Description copied from interface: JsonProvider
        Extracts a value from an array
        Specified by:
        getArrayIndex in interface JsonProvider
        Parameters:
        obj - an array
        idx - index
        unwrap - should provider specific data type be unwrapped
        Returns:
        the entry at the given index
      • setArrayIndex

        public void setArrayIndex​(java.lang.Object array,
                                  int index,
                                  java.lang.Object newValue)
        Description copied from interface: JsonProvider
        Sets a value in an array. If the array is too small, the provider is supposed to enlarge it.
        Specified by:
        setArrayIndex in interface JsonProvider
        Parameters:
        array - an array
        index - index
        newValue - the new value
      • getMapValue

        public java.lang.Object getMapValue​(java.lang.Object obj,
                                            java.lang.String key)
        Extracts a value from an map
        Specified by:
        getMapValue in interface JsonProvider
        Parameters:
        obj - a map
        key - property key
        Returns:
        the map entry or JsonProvider.UNDEFINED for missing properties
      • setProperty

        public void setProperty​(java.lang.Object obj,
                                java.lang.Object key,
                                java.lang.Object value)
        Sets a value in an object
        Specified by:
        setProperty in interface JsonProvider
        Parameters:
        obj - an object
        key - a String key
        value - the value to set
      • removeProperty

        public void removeProperty​(java.lang.Object obj,
                                   java.lang.Object key)
        Removes a value in an object or array
        Specified by:
        removeProperty in interface JsonProvider
        Parameters:
        obj - an array or an object
        key - a String key or a numerical index to remove
      • isMap

        public boolean isMap​(java.lang.Object obj)
        checks if object is a map (i.e. no array)
        Specified by:
        isMap in interface JsonProvider
        Parameters:
        obj - object to check
        Returns:
        true if the object is a map
      • getPropertyKeys

        public java.util.Collection<java.lang.String> getPropertyKeys​(java.lang.Object obj)
        Returns the keys from the given object
        Specified by:
        getPropertyKeys in interface JsonProvider
        Parameters:
        obj - an object
        Returns:
        the keys for an object
      • length

        public int length​(java.lang.Object obj)
        Get the length of an array or object
        Specified by:
        length in interface JsonProvider
        Parameters:
        obj - an array or an object
        Returns:
        the number of entries in the array or object
      • toIterable

        public java.lang.Iterable<? extends java.lang.Object> toIterable​(java.lang.Object obj)
        Converts given array to an Iterable
        Specified by:
        toIterable in interface JsonProvider
        Parameters:
        obj - an array
        Returns:
        an Iterable that iterates over the entries of an array
      • unwrap

        public java.lang.Object unwrap​(java.lang.Object obj)
        Description copied from interface: JsonProvider
        Extracts a value from a wrapper object. For JSON providers that to not wrap values, this will usually be the object itself.
        Specified by:
        unwrap in interface JsonProvider
        Parameters:
        obj - a value holder object
        Returns:
        the unwrapped value.