Class URIUtil

java.lang.Object
aQute.libg.uri.URIUtil

public final class URIUtil extends Object
  • Field Details

    • WINDOWS_FILE_PATTERN

      private static final Pattern WINDOWS_FILE_PATTERN
    • EMPTYURI

      private static final URI EMPTYURI
  • Constructor Details

    • URIUtil

      public URIUtil()
  • Method Details

    • resolve

      public static URI resolve(URI baseURI, String reference) throws URISyntaxException
      Resolves a URI reference against a base URI. Work-around for bugs in java.net.URI (e.g.http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535)
      Parameters:
      baseURI -
      reference -
      Returns:
      the resolved URI
      Throws:
      URISyntaxException
    • pathFromURI

      public static Optional<Path> pathFromURI(String uriString)
      Attempts to fetch a path on the file system for the given URI string. Tries a few more tricks than the standard method of Paths.get(new URI(uriString)) - it can handle plain paths, and also nested URI pseudo-schemes like reference: and jar:. Examples:
      • /path/to/file => /path/to/file
      • reference:file:/path/to/file => /path/to/file
      • jar:file:/path/to/file.jar!/some/contained/element => /path/to/file.jar
      • http://server/path/to/file => null
      Parameters:
      uriString - The URI string for which we are attempting to construct a path.
      Returns:
      The method's best guess as to which file on the local filesystem this URI refers, or an empty Optional if it's invalid or not a local filesystem URI.
    • pathFromURI

      public static Optional<Path> pathFromURI(URI uri)
      Attempts to fetch a path on the file system for the given URI. Tries a few more tricks than the standard method of Paths.get(uri) - it can handle plain paths, and also nested URI pseudo-schemes like reference: and jar:. Examples:
      • /path/to/file => /path/to/file
      • reference:file:/path/to/file => /path/to/file
      • jar:file:/path/to/file.jar!/some/contained/element => /path/to/file.jar
      • http://server/path/to/file => null
      Parameters:
      uri - The URI for which we are attempting to construct a path.
      Returns:
      The method's best guess as to which file on the local filesystem this URI refers, or an empty Optional if it's invalid or not a local filesystem URI.
    • pathFromURI

      private static Optional<Path> pathFromURI(String uriString, URI uri)
    • isRemote

      public static boolean isRemote(URI uri)
      Answer if the given URL is on the local system or remote
    • getDefaultPort

      public static int getDefaultPort(String scheme)
    • encodePath

      public static String encodePath(String path)
    • isPathAllowed

      static boolean isPathAllowed(int b)
    • isAlphanum

      static boolean isAlphanum(int b)
    • decode

      public static String decode(String source)