Package uk.ac.ebi.utils.ids
Class IdUtils
java.lang.Object
uk.ac.ebi.utils.ids.IdUtils
Utilities about management of identifiers.
- Author:
- brandizi
- Date:
- 28 Aug 2015
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
static String
hashUriSignature
(String sig) Takes a string that is supposed to represent the identifier of a resource and turns it into an opaque compact and URI-compatible representation.static String
Uses suitable default for splitRegEx ("[#/]")static String
Uses a suitable default for replacementRegEx ("[\\s\\+\\-\\:\\.\\?]").static String
Splits a URL based on the splitRegEx expression and returns the last fragment of it, which usually correspond to an identifer to an accession (such as a class name in OWL/RDF-S).static String
Same asurlEncode(String)
, for the reverse operation, based onURLDecoder
.static String
InvokesURLEncoder.encode(String, String)
with UTF-8 encoding and wraps the generated exception with anIllegalArgumentException
.
-
Constructor Details
-
IdUtils
public IdUtils()
-
-
Method Details
-
createCompactUUID
- Returns:
- an UUID-based new unique identifier, which is also turned into a readable and size-optimised string.
This is based on encoding the 16 bytes returned by
UUID.randomUUID()
in BASE64 format, which yields a 24 character string, where the last two are always '==' padding characters, hence these are removed and a final 22-character result is returned. This is the best compromise that we know between size, readability and portability across non-binary formats.
-
hashUriSignature
Takes a string that is supposed to represent the identifier of a resource and turns it into an opaque compact and URI-compatible representation. At the moment it hashes the parameter (via MD5) and converts the hash into lower-case hexadecimal. -
urlEncode
InvokesURLEncoder.encode(String, String)
with UTF-8 encoding and wraps the generated exception with anIllegalArgumentException
.- Returns:
- null if the parameter is null, or the URL-encoded string.
-
urlDecode
Same asurlEncode(String)
, for the reverse operation, based onURLDecoder
. -
iri2id
Splits a URL based on the splitRegEx expression and returns the last fragment of it, which usually correspond to an identifer to an accession (such as a class name in OWL/RDF-S). That fragment is also passed tourlDecode(String)
and characters matching replacementRegEx are all replaced by '_' (if the parameter is non-null). Returns null if the IRI is null or its trimmed version is empty. -
iri2id
Uses a suitable default for replacementRegEx ("[\\s\\+\\-\\:\\.\\?]"). -
iri2id
Uses suitable default for splitRegEx ("[#/]")
-