Class URIUtil
java.lang.Object
org.eclipse.jetty.util.URIUtil
- All Implemented Interfaces:
Cloneable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddEncodedPaths(String p1, String p2) Add two encoded URI path segments.static URIstatic StringaddPathQuery(String path, String query) Add a path and a query stringstatic StringAdd two Decoded URI path segments.static StringaddQueries(String query1, String query2) Combine two query strings into one.static voidappendSchemeHostPort(StringBuffer url, String scheme, String server, int port) Append scheme, host and port URI prefix, handling IPv6 address encoding and default portsstatic voidappendSchemeHostPort(StringBuilder url, String scheme, String server, int port) Append scheme, host and port URI prefix, handling IPv6 address encoding and default portsstatic StringcanonicalEncodedPath(String path) Convert a path to a cananonical form.static StringcanonicalPath(String path) Convert an encoded path to a canonical form.static StringcompactPath(String path) Convert a path to a compact form.private static StringdecodeISO88591Path(String path, int offset, int length) static StringdecodePath(String path) static StringdecodePath(String path, int offset, int length) static StringdecodeSpecific(String str, String charsToDecode) Decode a raw String and convert any specific URI encoded sequences into characters.static StringencodePath(String path) Encode a URI path.static StringBuilderencodePath(StringBuilder buf, String path) Encode a URI path.private static StringBuilderencodePath(StringBuilder buf, String path, int offset) Encode a URI path.static StringencodeSpaces(String str) Encode a raw URI String and convert any raw spaces to their "%20" equivalent.static StringencodeSpecific(String str, String charsToEncode) Encode a raw String and convert any specific characters to their URI encoded equivalent.static StringBuilderencodeString(StringBuilder buf, String path, String encode) Encode a URI path.static booleanequalsIgnoreEncodings(String uriA, String uriB) static booleanequalsIgnoreEncodings(URI uriA, URI uriB) static StringgetJarSource(String uri) static URIgetJarSource(URI uri) static StringgetUriLastPathSegment(URI uri) Given a URI, attempt to get the last segment.static booleanprivate static intlenientPercentDecode(String str, int offset) static StringCreate a new URI from the arguments, handling IPv6 host encoding and default portsstatic StringBuildernewURIBuilder(String scheme, String server, int port) Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default portsstatic StringparentPath(String p) Return the parent Path.
-
Field Details
-
LOG
-
SLASH
- See Also:
-
HTTP
- See Also:
-
HTTPS
- See Also:
-
__CHARSET
-
-
Constructor Details
-
URIUtil
private URIUtil()
-
-
Method Details
-
encodePath
-
encodePath
Encode a URI path.- Parameters:
buf- StringBuilder to encode path into (or null)path- The path the encode- Returns:
- The StringBuilder or null if no substitutions required.
-
encodePath
Encode a URI path.- Parameters:
buf- StringBuilder to encode path into (or null)path- The path the encode- Returns:
- The StringBuilder or null if no substitutions required.
-
encodeSpaces
-
encodeSpecific
Encode a raw String and convert any specific characters to their URI encoded equivalent.- Parameters:
str- input raw stringcharsToEncode- the list of raw characters that need to be encoded (if encountered)- Returns:
- output with specified characters encoded.
-
decodeSpecific
Decode a raw String and convert any specific URI encoded sequences into characters.- Parameters:
str- input raw stringcharsToDecode- the list of raw characters that need to be decoded (if encountered), leaving all other encoded sequences alone.- Returns:
- output with specified characters decoded.
-
encodeString
Encode a URI path.- Parameters:
buf- StringBuilder to encode path into (or null)path- The path the encodeencode- String of characters to encode. % is always encoded.- Returns:
- The StringBuilder or null if no substitutions required.
-
decodePath
-
decodePath
-
decodeISO88591Path
-
addEncodedPaths
Add two encoded URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSIONID=xxx) and avoids duplicate '/'- Parameters:
p1- URI path segment (should be encoded)p2- URI path segment (should be encoded)- Returns:
- Legally combined path segments.
-
addPaths
Add two Decoded URI path segments. Handles null and empty paths. Path and query params (eg ?a=b or ;JSESSIONID=xxx) are not handled- Parameters:
p1- URI path segment (should be decoded)p2- URI path segment (should be decoded)- Returns:
- Legally combined path segments.
-
addPathQuery
Add a path and a query string- Parameters:
path- The path which may already contain contain a queryquery- The query string or null if no query to be added- Returns:
- The path with any non null query added after a '?' or '&' as appropriate.
-
getUriLastPathSegment
-
parentPath
-
canonicalPath
Convert an encoded path to a canonical form.All instances of "." and ".." are factored out. Null is returned if the path tries to .. above its root.
- Parameters:
path- the path to convert, decoded, with path separators '/' and no queries.- Returns:
- the canonical path, or null if path traversal above root.
-
canonicalEncodedPath
Convert a path to a cananonical form.All instances of "." and ".." are factored out.
Null is returned if the path tries to .. above its root.
- Parameters:
path- the path to convert (expects URI/URL form, encoded, and with path separators '/')- Returns:
- the canonical path, or null if path traversal above root.
-
compactPath
-
hasScheme
- Parameters:
uri- URI- Returns:
- True if the uri has a scheme
-
newURI
Create a new URI from the arguments, handling IPv6 host encoding and default ports- Parameters:
scheme- the URI schemeserver- the URI serverport- the URI portpath- the URI pathquery- the URI query- Returns:
- A String URI
-
newURIBuilder
Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports- Parameters:
scheme- the URI schemeserver- the URI serverport- the URI port- Returns:
- a StringBuilder containing URI prefix
-
appendSchemeHostPort
Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports- Parameters:
url- StringBuilder to append toscheme- the URI schemeserver- the URI serverport- the URI port
-
appendSchemeHostPort
Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports- Parameters:
url- StringBuffer to append toscheme- the URI schemeserver- the URI serverport- the URI port
-
equalsIgnoreEncodings
-
lenientPercentDecode
-
equalsIgnoreEncodings
-
addPath
-
addQueries
Combine two query strings into one. Each query string should not contain the beginning '?' character, but may contain multiple parameters separated by the '&' character.- Parameters:
query1- the first query string.query2- the second query string.- Returns:
- the combination of the two query strings.
-
getJarSource
-
getJarSource
-