public class URIUtil extends Object implements Cloneable
This class assists with the decoding and encoding or HTTP URI's. It differs from the java.net.URL class as it does not provide communications ability, but it does assist with query string formatting.
UTF-8 encoding is used by default for % encoded characters. This may be overridden with the org.eclipse.jetty.util.URI.charset system property.
UrlEncoded
Modifier and Type | Field and Description |
---|---|
static Charset |
__CHARSET |
static String |
HTTP |
static String |
HTTP_COLON |
static String |
HTTPS |
static String |
HTTPS_COLON |
static String |
SLASH |
Modifier and Type | Method and Description |
---|---|
static String |
addPaths(String p1,
String p2)
Add two URI path segments.
|
static void |
appendSchemeHostPort(StringBuffer url,
String scheme,
String server,
int port)
Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports
|
static void |
appendSchemeHostPort(StringBuilder url,
String scheme,
String server,
int port)
Append scheme, host and port URI prefix, handling IPv6 address encoding and default ports
|
static String |
canonicalPath(String path)
Convert a path to a cananonical form.
|
static String |
compactPath(String path)
Convert a path to a compact form.
|
static String |
decodePath(String path) |
static String |
decodePath(String path,
int offset,
int length) |
static String |
encodePath(String path)
Encode a URI path.
|
static StringBuilder |
encodePath(StringBuilder buf,
String path)
Encode a URI path.
|
static StringBuilder |
encodeString(StringBuilder buf,
String path,
String encode)
Encode a URI path.
|
static boolean |
equalsIgnoreEncodings(String uriA,
String uriB) |
static boolean |
hasScheme(String uri) |
static String |
newURI(String scheme,
String server,
int port,
String path,
String query)
Create a new URI from the arguments, handling IPv6 host encoding and default ports
|
static StringBuilder |
newURIBuilder(String scheme,
String server,
int port)
Create a new URI StringBuilder from the arguments, handling IPv6 host encoding and default ports
|
static String |
parentPath(String p)
Return the parent Path.
|
public static final String SLASH
public static final String HTTP
public static final String HTTP_COLON
public static final String HTTPS
public static final String HTTPS_COLON
public static final Charset __CHARSET
public static String encodePath(String path)
path
- The path the encodepublic static StringBuilder encodePath(StringBuilder buf, String path)
path
- The path the encodebuf
- StringBuilder to encode path into (or null)public static StringBuilder encodeString(StringBuilder buf, String path, String encode)
path
- The path the encodebuf
- StringBuilder to encode path into (or null)encode
- String of characters to encode. % is always encoded.public static String addPaths(String p1, String p2)
p1
- URI path segment (should be encoded)p2
- URI path segment (should be encoded)public static String parentPath(String p)
p
- the path to return a parent reference topublic static String canonicalPath(String path)
path
- the path to convertpublic static String compactPath(String path)
path
- the path to compactpublic static boolean hasScheme(String uri)
uri
- URIpublic static String newURI(String scheme, String server, int port, String path, String query)
scheme
- the URI schemeserver
- the URI serverport
- the URI portpath
- the URI pathquery
- the URI querypublic static StringBuilder newURIBuilder(String scheme, String server, int port)
scheme
- the URI schemeserver
- the URI serverport
- the URI portpublic static void appendSchemeHostPort(StringBuilder url, String scheme, String server, int port)
url
- StringBuilder to append toscheme
- the URI schemeserver
- the URI serverport
- the URI portpublic static void appendSchemeHostPort(StringBuffer url, String scheme, String server, int port)
url
- StringBuffer to append toscheme
- the URI schemeserver
- the URI serverport
- the URI portCopyright © 1995-2016 Webtide. All Rights Reserved.