Class NormalizeUtils


  • class NormalizeUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<java.lang.String,​java.lang.Object> bnodes  
      private UniqueNamer namer  
      private JsonLdOptions options  
      private java.util.List<java.lang.Object> quads  
    • Constructor Summary

      Constructors 
      Constructor Description
      NormalizeUtils​(java.util.List<java.lang.Object> quads, java.util.Map<java.lang.String,​java.lang.Object> bnodes, UniqueNamer namer, JsonLdOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String encodeHex​(byte[] data)  
      private static java.lang.String getAdjacentBlankNodeName​(java.util.Map<java.lang.String,​java.lang.Object> node, java.lang.String id)
      A helper function that gets the blank node name from an RDF quad node (subject or object).
      java.lang.Object hashBlankNodes​(java.util.Collection<java.lang.String> unnamed_)  
      private static NormalizeUtils.HashResult hashPaths​(java.lang.String id, java.util.Map<java.lang.String,​java.lang.Object> bnodes, UniqueNamer namer, UniqueNamer pathNamer)
      Produces a hash for the paths of adjacent bnodes for a bnode, incorporating all information about its subgraph of bnodes.
      private static java.lang.String hashQuads​(java.lang.String id, java.util.Map<java.lang.String,​java.lang.Object> bnodes, UniqueNamer namer)
      Hashes all of the quads about a blank node.
      private static java.lang.String sha1hash​(java.util.Collection<java.lang.String> nquads)
      A helper class to sha1 hash all the strings in a collection
      • Methods inherited from class java.lang.Object

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

      • bnodes

        private final java.util.Map<java.lang.String,​java.lang.Object> bnodes
      • quads

        private final java.util.List<java.lang.Object> quads
    • Constructor Detail

      • NormalizeUtils

        public NormalizeUtils​(java.util.List<java.lang.Object> quads,
                              java.util.Map<java.lang.String,​java.lang.Object> bnodes,
                              UniqueNamer namer,
                              JsonLdOptions options)
    • Method Detail

      • hashBlankNodes

        public java.lang.Object hashBlankNodes​(java.util.Collection<java.lang.String> unnamed_)
                                        throws JsonLdError
        Throws:
        JsonLdError
      • hashPaths

        private static NormalizeUtils.HashResult hashPaths​(java.lang.String id,
                                                           java.util.Map<java.lang.String,​java.lang.Object> bnodes,
                                                           UniqueNamer namer,
                                                           UniqueNamer pathNamer)
        Produces a hash for the paths of adjacent bnodes for a bnode, incorporating all information about its subgraph of bnodes. This method will recursively pick adjacent bnode permutations that produce the lexicographically-least 'path' serializations.
        Parameters:
        id - the ID of the bnode to hash paths for.
        bnodes - the map of bnode quads.
        namer - the canonical bnode namer.
        pathNamer - the namer used to assign names to adjacent bnodes.
        callback - (err, result) called once the operation completes.
      • hashQuads

        private static java.lang.String hashQuads​(java.lang.String id,
                                                  java.util.Map<java.lang.String,​java.lang.Object> bnodes,
                                                  UniqueNamer namer)
        Hashes all of the quads about a blank node.
        Parameters:
        id - the ID of the bnode to hash quads for.
        bnodes - the mapping of bnodes to quads.
        namer - the canonical bnode namer.
        Returns:
        the new hash.
      • sha1hash

        private static java.lang.String sha1hash​(java.util.Collection<java.lang.String> nquads)
        A helper class to sha1 hash all the strings in a collection
        Parameters:
        nquads -
        Returns:
      • encodeHex

        private static java.lang.String encodeHex​(byte[] data)
      • getAdjacentBlankNodeName

        private static java.lang.String getAdjacentBlankNodeName​(java.util.Map<java.lang.String,​java.lang.Object> node,
                                                                 java.lang.String id)
        A helper function that gets the blank node name from an RDF quad node (subject or object). If the node is a blank node and its value does not match the given blank node ID, it will be returned.
        Parameters:
        node - the RDF quad node.
        id - the ID of the blank node to look next to.
        Returns:
        the adjacent blank node name or null if none was found.