Class IdUtils

java.lang.Object
uk.ac.ebi.utils.ids.IdUtils

public class IdUtils extends Object
Utilities about management of identifiers.
Author:
brandizi
Date:
28 Aug 2015
  • Constructor Details

    • IdUtils

      public IdUtils()
  • Method Details

    • createCompactUUID

      public static String 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

      public 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. At the moment it hashes the parameter (via MD5) and converts the hash into lower-case hexadecimal.
    • urlEncode

      public static String urlEncode(String queryStringUrl)
      Invokes URLEncoder.encode(String, String) with UTF-8 encoding and wraps the generated exception with an IllegalArgumentException.
      Returns:
      null if the parameter is null, or the URL-encoded string.
    • urlDecode

      public static String urlDecode(String url)
      Same as urlEncode(String), for the reverse operation, based on URLDecoder.
    • iri2id

      public static String iri2id(String iri, String splitRegEx, String replacementRegEx)
      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 to urlDecode(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

      public static String iri2id(String iri, String splitRegEx)
      Uses a suitable default for replacementRegEx ("[\\s\\+\\-\\:\\.\\?]").
    • iri2id

      public static String iri2id(String iri)
      Uses suitable default for splitRegEx ("[#/]")