Class IRILib

java.lang.Object
org.apache.jena.atlas.lib.IRILib

public class IRILib extends Object
Operations related to IRIs.

The encoding operations are for Linked Data use, not network encoding - e.g. use URLEncoder.encode(java.lang.String) or org.apache.http.client.utilsURLEncodedUtils for encoding query string name/value pairs for the network.

  • Constructor Details

    • IRILib

      public IRILib()
  • Method Details

    • fileToIRI

      public static String fileToIRI(File f)
      Return a string that is an IRI for the filename.
    • filenameToIRI

      public static String filenameToIRI(String fn)
      Create a string that is a IRI for the filename.
      • The file name may already have file:.
      • The file name may be relative.
      • Encode using the rules for a path (e.g. ':' and'/' do not get encoded)
      • Non-IRI characters get %-encoded.
    • IRIToFilename

      public static String IRIToFilename(String iri)
      Convert a file: IRI to a filename
    • encodeUriComponent

      public static String encodeUriComponent(String string)
      Encode using the rules for a component (e.g. ':' and '/' get encoded) Apply to a name/value of a query string. Does not encode non-ASCII characters
    • encodeUriQueryFrag

      public static String encodeUriQueryFrag(String string)
      Encode using the rules for a query string or fragment (e.g. ':' and '/' do not encoded). It does not encode non-ASCII characters. '?' is not encoded - in RFC 3986, the first '?' triggers the query part but it is then a legal, character.
    • decodeUriQueryFrag

      public static String decodeUriQueryFrag(String string)
    • encodeFileURL

      public static String encodeFileURL(String string)
      Encode using the rules for a file: URL. Does not encode non-ASCII characters
    • encodeUriPath

      public static String encodeUriPath(String uri)
      Encode using the rules for a path (e.g. ':' and '/' do not get encoded)
    • encodeNonASCII

      public static String encodeNonASCII(String string)
    • containsNonASCII

      public static boolean containsNonASCII(String string)
    • decodeHex

      public static String decodeHex(String string)
      Decode a string that may have %-encoded sequences.

      This function will reverse encodeNonASCII(String), encodeUriPath(String), encodeFileURL(String) and encodeUriComponent(String). It will not decode '+' used for space (application/x-www-form-urlencoded).