Class Extensions

  • All Implemented Interfaces:
    IFreeMap<URI,​Object>

    public class Extensions
    extends Object
    implements IFreeMap<URI,​Object>
    A wrapper object for using xAPI Extensions. The extension JSON data is stored in a combination of LinkedHashMap and ArrayList depending on the JSON elements. It can be accessed directly or through a JSONPath API.
    • Constructor Detail

      • Extensions

        public Extensions​(Map<URI,​Object> input)
    • Method Detail

      • put

        public void put​(URI key,
                        Object value)
        Sets an entry in the Extensions Map
        Specified by:
        put in interface IFreeMap<URI,​Object>
        Parameters:
        key - the URI key of the extension
        value - The Collections API representation of the JSON Data
      • get

        public Object get​(URI key)
        Retrieve extension data
        Specified by:
        get in interface IFreeMap<URI,​Object>
        Parameters:
        key - The URI key of the extension
        Returns:
        The Collections API representation of the JSON Data
      • read

        public <T> T read​(URI key,
                          String jsonPathExpression,
                          Class<T> typeKey)
        Attempt a JSONPath query of the Extension data.
        Type Parameters:
        T - The type that the query is expecting to convert the results to
        Parameters:
        key - The URI key of the extension in which to perform the query
        jsonPathExpression - A JSONPath query to perform in the Extension data
        typeKey - The typereference for the type that the query is expecting to retrieve
        Returns:
        Object of type T that is the result of deserialization from the query
      • read

        public <T> T read​(String key,
                          String jsonPathExpression,
                          Class<T> typeKey)
                   throws IllegalArgumentException
        Attempt a JSONPath query of the Extension data.
        Type Parameters:
        T - The type that the query is expecting to convert the results to
        Parameters:
        key - The IRI String key of the extension in which to perform the query
        jsonPathExpression - A JSONPath query to perform in the Extension data
        typeKey - The typereference for the type that the query is expecting to retrieve
        Returns:
        Object of type T that is the result of deserialization from the query
        Throws:
        IllegalArgumentException
      • remove

        public void remove​(URI key)
        Remove an extension by IRI key
        Specified by:
        remove in interface IFreeMap<URI,​Object>
        Parameters:
        key - the URI key of the extension to remove
      • getKeys

        public Set<URI> getKeys()
        Returns a set of all IRI Extension keys
        Specified by:
        getKeys in interface IFreeMap<URI,​Object>
        Returns:
        Set of IRI keys
      • getMap

        public Map<URI,​Object> getMap()
        Returns the full raw Extension Map as a HashMap<URI, Object>
        Specified by:
        getMap in interface IFreeMap<URI,​Object>
        Returns:
        The raw Extensions Map