Package com.github.jsonldjava.core
Class NormalizeUtils
- java.lang.Object
-
- com.github.jsonldjava.core.NormalizeUtils
-
class NormalizeUtils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classNormalizeUtils.HashResultprivate static classNormalizeUtils.Permutator
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Object>bnodesprivate UniqueNamernamerprivate JsonLdOptionsoptionsprivate 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.StringencodeHex(byte[] data)private static java.lang.StringgetAdjacentBlankNodeName(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.ObjecthashBlankNodes(java.util.Collection<java.lang.String> unnamed_)private static NormalizeUtils.HashResulthashPaths(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.StringhashQuads(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.Stringsha1hash(java.util.Collection<java.lang.String> nquads)A helper class to sha1 hash all the strings in a collection
-
-
-
Field Detail
-
namer
private final UniqueNamer namer
-
bnodes
private final java.util.Map<java.lang.String,java.lang.Object> bnodes
-
quads
private final java.util.List<java.lang.Object> quads
-
options
private final JsonLdOptions options
-
-
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.
-
-