Class JsonLdUtils


  • public class JsonLdUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int MAX_CONTEXT_URLS  
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonLdUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.Object clone​(java.lang.Object value)  
      (package private) static int compareShortestLeast​(java.lang.String a, java.lang.String b)
      Compares two strings first based on length and then lexicographically.
      (package private) static boolean compareValues​(java.lang.Object v1, java.lang.Object v2)
      Compares two JSON-LD values for equality.
      static java.lang.Boolean deepCompare​(java.lang.Object v1, java.lang.Object v2)  
      static java.lang.Boolean deepCompare​(java.lang.Object v1, java.lang.Object v2, java.lang.Boolean listOrderMatters)  
      static boolean deepContains​(java.util.List<java.lang.Object> values, java.lang.Object value)  
      (package private) static void fillNodesToPrune​(java.lang.Object input, java.util.Map<java.lang.String,​java.lang.Object> toPrune)
      Gets the objects on which we'll prune the blank node ID
      static boolean isAbsoluteIri​(java.lang.String value)  
      (package private) static java.lang.Boolean isArray​(java.lang.Object v)
      Returns true if the given value is a JSON-LD Array
      (package private) static boolean isBlankNode​(java.lang.Object v)
      Returns true if the given value is a blank node.
      (package private) static boolean isKeyword​(java.lang.Object key)
      Returns whether or not the given value is a keyword (or a keyword alias).
      (package private) static java.lang.Boolean isList​(java.lang.Object v)
      Returns true if the given value is a JSON-LD List
      (package private) static boolean isNode​(java.lang.Object v)
      Returns true if the given value is a subject with properties.
      (package private) static boolean isNodeReference​(java.lang.Object v)
      Returns true if the given value is a subject reference.
      (package private) static java.lang.Boolean isObject​(java.lang.Object v)
      Returns true if the given value is a JSON-LD Object
      static boolean isRelativeIri​(java.lang.String value)  
      (package private) static java.lang.Boolean isString​(java.lang.Object v)
      Returns true if the given value is a JSON-LD string
      (package private) static java.lang.Boolean isValue​(java.lang.Object v)
      Returns true if the given value is a JSON-LD value
      (package private) static void laxMergeValue​(java.util.Map<java.lang.String,​java.lang.Object> obj, java.lang.String key, java.lang.Object value)  
      (package private) static void mergeValue​(java.util.Map<java.lang.String,​java.lang.Object> obj, java.lang.String key, java.lang.Object value)  
      (package private) static void pruneBlankNodes​(java.lang.Object input)
      Removes the @id member of each node object where the member value is a blank node identifier which appears only once in any property value within input.
      (package private) static java.lang.Object removePreserve​(Context ctx, java.lang.Object input, JsonLdOptions opts)
      Removes the @preserve keywords as the last step of the framing algorithm.
      • Methods inherited from class java.lang.Object

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

      • JsonLdUtils

        public JsonLdUtils()
    • Method Detail

      • isKeyword

        static boolean isKeyword​(java.lang.Object key)
        Returns whether or not the given value is a keyword (or a keyword alias).
        Parameters:
        v - the value to check.
        Returns:
        true if the value is a keyword, false if not.
      • deepCompare

        public static java.lang.Boolean deepCompare​(java.lang.Object v1,
                                                    java.lang.Object v2,
                                                    java.lang.Boolean listOrderMatters)
      • deepCompare

        public static java.lang.Boolean deepCompare​(java.lang.Object v1,
                                                    java.lang.Object v2)
      • deepContains

        public static boolean deepContains​(java.util.List<java.lang.Object> values,
                                           java.lang.Object value)
      • mergeValue

        static void mergeValue​(java.util.Map<java.lang.String,​java.lang.Object> obj,
                               java.lang.String key,
                               java.lang.Object value)
      • laxMergeValue

        static void laxMergeValue​(java.util.Map<java.lang.String,​java.lang.Object> obj,
                                  java.lang.String key,
                                  java.lang.Object value)
      • isAbsoluteIri

        public static boolean isAbsoluteIri​(java.lang.String value)
      • isNode

        static boolean isNode​(java.lang.Object v)
        Returns true if the given value is a subject with properties.
        Parameters:
        v - the value to check.
        Returns:
        true if the value is a subject with properties, false if not.
      • isNodeReference

        static boolean isNodeReference​(java.lang.Object v)
        Returns true if the given value is a subject reference.
        Parameters:
        v - the value to check.
        Returns:
        true if the value is a subject reference, false if not.
      • isRelativeIri

        public static boolean isRelativeIri​(java.lang.String value)
      • removePreserve

        static java.lang.Object removePreserve​(Context ctx,
                                               java.lang.Object input,
                                               JsonLdOptions opts)
                                        throws JsonLdError
        Removes the @preserve keywords as the last step of the framing algorithm.
        Parameters:
        ctx - the active context used to compact the input.
        input - the framed, compacted output.
        options - the compaction options used.
        Returns:
        the resulting output.
        Throws:
        JsonLdError
      • pruneBlankNodes

        static void pruneBlankNodes​(java.lang.Object input)
        Removes the @id member of each node object where the member value is a blank node identifier which appears only once in any property value within input.
        Parameters:
        input - the framed output before compaction
      • fillNodesToPrune

        static void fillNodesToPrune​(java.lang.Object input,
                                     java.util.Map<java.lang.String,​java.lang.Object> toPrune)
        Gets the objects on which we'll prune the blank node ID
        Parameters:
        input - the framed output before compaction
        toPrune - the resulting object.
      • compareShortestLeast

        static int compareShortestLeast​(java.lang.String a,
                                        java.lang.String b)
        Compares two strings first based on length and then lexicographically.
        Parameters:
        a - the first string.
        b - the second string.
        Returns:
        -1 if a < b, 1 if a > b, 0 if a == b.
      • compareValues

        static boolean compareValues​(java.lang.Object v1,
                                     java.lang.Object v2)
        Compares two JSON-LD values for equality. Two JSON-LD values will be considered equal if: 1. They are both primitives of the same type and value. 2. They are both @values with the same @value, @type, and @language, OR 3. They both have @ids they are the same.
        Parameters:
        v1 - the first value.
        v2 - the second value.
        Returns:
        true if v1 and v2 are considered equal, false if not.
      • isBlankNode

        static boolean isBlankNode​(java.lang.Object v)
        Returns true if the given value is a blank node.
        Parameters:
        v - the value to check.
        Returns:
        true if the value is a blank node, false if not.
      • clone

        static java.lang.Object clone​(java.lang.Object value)
      • isArray

        static java.lang.Boolean isArray​(java.lang.Object v)
        Returns true if the given value is a JSON-LD Array
        Parameters:
        v - the value to check.
        Returns:
      • isList

        static java.lang.Boolean isList​(java.lang.Object v)
        Returns true if the given value is a JSON-LD List
        Parameters:
        v - the value to check.
        Returns:
      • isObject

        static java.lang.Boolean isObject​(java.lang.Object v)
        Returns true if the given value is a JSON-LD Object
        Parameters:
        v - the value to check.
        Returns:
      • isValue

        static java.lang.Boolean isValue​(java.lang.Object v)
        Returns true if the given value is a JSON-LD value
        Parameters:
        v - the value to check.
        Returns:
      • isString

        static java.lang.Boolean isString​(java.lang.Object v)
        Returns true if the given value is a JSON-LD string
        Parameters:
        v - the value to check.
        Returns: