Package org.apache.tomcat.util.buf
Class UriUtil
java.lang.Object
org.apache.tomcat.util.buf.UriUtil
Utility class for working with URIs and URLs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic URL
buildJarSafeUrl
(File file) static URL
buildJarUrl
(File jarFile) static URL
buildJarUrl
(File jarFile, String entryPath) static URL
buildJarUrl
(String fileUrlString) static URL
buildJarUrl
(String fileUrlString, String entryPath) static String
static boolean
hasScheme
(CharSequence uri) Determine if a URI string has ascheme
component.static boolean
isAbsoluteURI
(String path) Does the provided path start withfile:/
or<protocol>://
.static URI
Replicates the behaviour ofURI.resolve(String)
and adds support for URIs of the formjar:file:/...
.static URL
Convert a URL of the formwar:file:...
tojar:file:...
.
-
Method Details
-
hasScheme
Determine if a URI string has ascheme
component.- Parameters:
uri
- The URI to test- Returns:
true
if a scheme is present, otherwise {code @false}
-
buildJarUrl
- Throws:
MalformedURLException
-
buildJarUrl
- Throws:
MalformedURLException
-
buildJarUrl
- Throws:
MalformedURLException
-
buildJarUrl
- Throws:
MalformedURLException
-
buildJarSafeUrl
- Throws:
MalformedURLException
-
warToJar
Convert a URL of the formwar:file:...
tojar:file:...
.- Parameters:
warUrl
- The WAR URL to convert- Returns:
- The equivalent JAR URL
- Throws:
MalformedURLException
- If the conversion fails
-
getWarSeparator
-
isAbsoluteURI
Does the provided path start withfile:/
or<protocol>://
.- Parameters:
path
- The path to test- Returns:
true
if the supplied path starts with once of the recognised sequences.
-
resolve
Replicates 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:
MalformedURLException
- If the base URI cannot be converted to a URLURISyntaxException
- If the resulting URL cannot be converted to a URI
-