Package org.codehaus.mojo.javacc
Class UrlUtils
- java.lang.Object
-
- org.codehaus.mojo.javacc.UrlUtils
-
class UrlUtils extends java.lang.ObjectAssists 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 java.lang.StringFILEThe protocol prefix for "file:" URLs.private static java.lang.StringJARThe protocol prefix for "jar:" URLs.private static java.lang.StringJAR_FILEThe protocol prefix for "jar:file:" URLs.private static java.nio.charset.CharsetUTF8The UTF-8 character set, used to decode octets in URLs.
-
Constructor Summary
Constructors Constructor Description UrlUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdecodeUrl(java.lang.String url)Decodes the specified URL as per RFC 3986, i.e.static java.io.FilegetResourceRoot(java.net.URL url, java.lang.String resource)Gets the absolute filesystem path to the class path root for the specified resource.
-
-
-
Field Detail
-
UTF8
private static final java.nio.charset.Charset UTF8
The UTF-8 character set, used to decode octets in URLs.
-
JAR
private static final java.lang.String JAR
The protocol prefix for "jar:" URLs.- See Also:
- Constant Field Values
-
FILE
private static final java.lang.String FILE
The protocol prefix for "file:" URLs.- See Also:
- Constant Field Values
-
JAR_FILE
private static final java.lang.String JAR_FILE
The protocol prefix for "jar:file:" URLs.- See Also:
- Constant Field Values
-
-
Method Detail
-
getResourceRoot
public static java.io.File getResourceRoot(java.net.URL url, java.lang.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 benull.resource- The name of the resource, must not benull.- Returns:
- The absolute filesystem path to the class path root of the resource or
nullif the input URL wasnull.
-
decodeUrl
public static java.lang.String decodeUrl(java.lang.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 withURLwhich 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 benull.- Returns:
- The decoded URL or
nullif the input wasnull.
-
-