Top Description Fields Constructors Methods
org.mortbay.util

public Class URIUtil

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.UnsupportedEncodingException

URI Holder. 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.mortbay.util.URI.charset system property.

Author
Greg Wilkins (gregw)
See Also
UrlEncoded

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

Legally combined path segments.
addPaths
(String
URI path segment
p1
,
String
URI path segment
p2
)

Add two URI path segments.

public static String

Returns:

path or null.
canonicalPath
(String path)

Convert a path to a cananonical form.

public static String

Returns:

path
compactPath
(String path)

Convert a path to a compact form.

public static String
public static String
decodePath(byte[] buf, int offset, int length)

public static String

Returns:

The encoded path
encodePath
(String
The path the encode
path
)

Encode a URI path.

public static StringBuilder

Returns:

The StringBuilder or null if no substitutions required.
encodePath
(StringBuilder
StringBuilder to encode path into (or null)
buf
,
String
The path the encode
path
)

Encode a URI path.

public static StringBuilder

Returns:

The StringBuilder or null if no substitutions required.
encodeString
(StringBuilder
StringBuilder to encode path into (or null)
buf
,
String
The path the encode
path
,
String
String of characters to encode. % is always encoded.
encode
)

Encode a URI path.

public static boolean

Returns:

True if the uri has a scheme
hasScheme
(String
URI
uri
)

public static String
parentPath(String p)

Return the parent Path.

public static String
stripPath(String path)

Strip parameters from a path.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__CHARSETback to summary
public static final String __CHARSET
HTTPback to summary
public static final String HTTP
HTTP_COLONback to summary
public static final String HTTP_COLON
HTTPSback to summary
public static final String HTTPS
HTTPS_COLONback to summary
public static final String HTTPS_COLON
SLASHback to summary
public static final String SLASH

Constructor Detail

URIUtilback to summary
private URIUtil()

Method Detail

addPathsback to summary
public static String addPaths(String p1, String p2)

Add two URI path segments. Handles null and empty paths, path and query params (eg ?a=b or ;JSESSIONID=xxx) and avoids duplicate '/'

Parameters
p1:String

URI path segment

p2:String

URI path segment

Returns:String

Legally combined path segments.

canonicalPathback to summary
public static String canonicalPath(String path)

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.

Returns:String

path or null.

compactPathback to summary
public static String compactPath(String path)

Convert a path to a compact form. All instances of "//" and "///" etc. are factored out to single "/"

Returns:String

path

decodePathback to summary
public static String decodePath(String path)
decodePathback to summary
public static String decodePath(byte[] buf, int offset, int length)
encodePathback to summary
public static String encodePath(String path)

Encode a URI path. This is the same encoding offered by URLEncoder, except that the '/' character is not encoded.

Parameters
path:String

The path the encode

Returns:String

The encoded path

encodePathback to summary
public static StringBuilder encodePath(StringBuilder buf, String path)

Encode a URI path.

Parameters
buf:StringBuilder

StringBuilder to encode path into (or null)

path:String

The path the encode

Returns:StringBuilder

The StringBuilder or null if no substitutions required.

encodeStringback to summary
public static StringBuilder encodeString(StringBuilder buf, String path, String encode)

Encode a URI path.

Parameters
buf:StringBuilder

StringBuilder to encode path into (or null)

path:String

The path the encode

encode:String

String of characters to encode. % is always encoded.

Returns:StringBuilder

The StringBuilder or null if no substitutions required.

hasSchemeback to summary
public static boolean hasScheme(String uri)
Parameters
uri:String

URI

Returns:boolean

True if the uri has a scheme

parentPathback to summary
public static String parentPath(String p)

Return the parent Path. Treat a URI like a directory path and return the parent directory.

stripPathback to summary
public static String stripPath(String path)

Strip parameters from a path. Return path upto any semicolon parameters.