Class UrlUtils

java.lang.Object
org.codehaus.mojo.javacc.UrlUtils

class UrlUtils extends Object
Assists in handling of URLs.
Version:
$Id: UrlUtils.java 7084 2008-05-30 08:01:52Z bentmann $
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    The protocol prefix for "file:" URLs.
    private static final String
    The protocol prefix for "jar:" URLs.
    private static final String
    The protocol prefix for "jar:file:" URLs.
    private static final Charset
    The UTF-8 character set, used to decode octets in URLs.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Decodes the specified URL as per RFC 3986, i.e.
    static File
    getResourceRoot(URL url, String resource)
    Gets the absolute filesystem path to the class path root for the specified resource.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • UrlUtils

      UrlUtils()
  • Method Details

    • getResourceRoot

      public static File getResourceRoot(URL url, String resource)
      Gets the absolute filesystem path to the class path root for the specified resource. The root is either a JAR file or a directory with loose class files. If the URL does not use a supported protocol, an exception will be thrown.
      Parameters:
      url - The URL to the resource, may be null.
      resource - The name of the resource, must not be null.
      Returns:
      The absolute filesystem path to the class path root of the resource or null if the input URL was null.
    • decodeUrl

      public static String decodeUrl(String url)
      Decodes the specified URL as per RFC 3986, i.e. transforms percent-encoded octets to characters by decoding with the UTF-8 character set. This function is primarily intended for usage with URL which unfortunately does not enforce proper URLs. As such, this method will leniently accept invalid characters or malformed percent-encoded octets and simply pass them literally through to the result string. Except for rare edge cases, this will make unencoded URLs pass through unaltered.
      Parameters:
      url - The URL to decode, may be null.
      Returns:
      The decoded URL or null if the input was null.