Package org.apache.tomcat.util.buf
Class UriUtil
- java.lang.Object
-
- org.apache.tomcat.util.buf.UriUtil
-
public final class UriUtil extends java.lang.ObjectUtility class for working with URIs and URLs.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.URLbuildJarSafeUrl(java.io.File file)static java.net.URLbuildJarUrl(java.io.File jarFile)static java.net.URLbuildJarUrl(java.io.File jarFile, java.lang.String entryPath)static java.net.URLbuildJarUrl(java.lang.String fileUrlString)static java.net.URLbuildJarUrl(java.lang.String fileUrlString, java.lang.String entryPath)static java.lang.StringgetWarSeparator()static booleanhasScheme(java.lang.CharSequence uri)Determine if a URI string has aschemecomponent.static booleanisAbsoluteURI(java.lang.String path)Does the provided path start withfile:/or<protocol>://.static java.net.URIresolve(java.net.URI base, java.lang.String target)Replicates the behaviour ofURI.resolve(String)and adds support for URIs of the formjar:file:/....static java.net.URLwarToJar(java.net.URL warUrl)Convert a URL of the formwar:file:...tojar:file:....
-
-
-
Method Detail
-
hasScheme
public static boolean hasScheme(java.lang.CharSequence uri)
Determine if a URI string has aschemecomponent.- Parameters:
uri- The URI to test- Returns:
trueif a scheme is present, otherwise {code @false}
-
buildJarUrl
public static java.net.URL buildJarUrl(java.io.File jarFile) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
buildJarUrl
public static java.net.URL buildJarUrl(java.io.File jarFile, java.lang.String entryPath) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
buildJarUrl
public static java.net.URL buildJarUrl(java.lang.String fileUrlString) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
buildJarUrl
public static java.net.URL buildJarUrl(java.lang.String fileUrlString, java.lang.String entryPath) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
buildJarSafeUrl
public static java.net.URL buildJarSafeUrl(java.io.File file) throws java.net.MalformedURLException- Throws:
java.net.MalformedURLException
-
warToJar
public static java.net.URL warToJar(java.net.URL warUrl) throws java.net.MalformedURLExceptionConvert a URL of the formwar:file:...tojar:file:....- Parameters:
warUrl- The WAR URL to convert- Returns:
- The equivalent JAR URL
- Throws:
java.net.MalformedURLException- If the conversion fails
-
getWarSeparator
public static java.lang.String getWarSeparator()
-
isAbsoluteURI
public static boolean isAbsoluteURI(java.lang.String path)
Does the provided path start withfile:/or<protocol>://.- Parameters:
path- The path to test- Returns:
trueif the supplied path starts with once of the recognised sequences.
-
resolve
public static java.net.URI resolve(java.net.URI base, java.lang.String target) throws java.net.MalformedURLException, java.net.URISyntaxExceptionReplicates the behaviour ofURI.resolve(String)and adds support for URIs of the formjar:file:/....- Parameters:
base- The base URI to resolve againsttarget- The path to resolve- Returns:
- The resulting URI as per
URI.resolve(String) - Throws:
java.net.MalformedURLException- If the base URI cannot be converted to a URLjava.net.URISyntaxException- If the resulting URL cannot be converted to a URI
-
-