public class createHashUri
The createHashUri class implements a custom filter function for ARQ that
takes a list of arbitrary inputs and creates from them a new URI. It
does this by converting the items to strings, combining those into a
single string, and applying a cryptographic hash to the result.
To use this function in a SPARQL query, first declare a prefix like so
(the final period is significant!):
Then in the WHERE clause of your query, add a LET construct such as this:
LET ( ?newUri := ext:createHashUri("http://example.org/foo/", ?x, ?y, ?z) )
This will cause the variable ?newUri to be bound to a hash URI created
from ?x, ?y, and ?z. The resulting URI will look like the following:
If an unbound variable is included in the list of items to hash, it will be
handled correctly, in the sense that a "null" placeholder will be inserted
into hash computation. However, the query writer must take care to ensure
that unbound variables will not result in a nonsensical URI. For instance,
if all of the items in the list were unbound variables, then the resulting
URI would not likely be a unique identifier of anything.
Note that because the class name will appear in SPARQL queries as a
function, the class name begins with a lower case letter in opposition
to the usual coding conventions for Java.
The filter function parameters are (in order):
(1) A base URI to which the hash will be appended, and
(2) One or more items to hash.