org.apache.commons.httpclient

Class HttpURL

public class HttpURL extends URI

The HTTP URL.

Author: Sung-Gu Mike Bowler

Field Summary
static intDEFAULT_PORT
Default port for HTTP URL.
static char[]DEFAULT_SCHEME
Default scheme for HTTP URL.
static int_default_port
Default port for HTTP URL.
static char[]_default_scheme
Default scheme for HTTP URL.
Constructor Summary
protected HttpURL()
Create an instance as an internal use.
HttpURL(char[] escaped, String charset)
Construct a HTTP URL as an escaped form of a character array with the given charset to do escape encoding.
HttpURL(char[] escaped)
Construct a HTTP URL as an escaped form of a character array.
HttpURL(String original, String charset)
Construct a HTTP URL from a given string with the given charset to do escape encoding.
HttpURL(String original)
Construct a HTTP URL from a given string.
HttpURL(String host, int port, String path)
Construct a HTTP URL from given components.
HttpURL(String host, int port, String path, String query)
Construct a HTTP URL from given components.
HttpURL(String user, String password, String host)
Construct a HTTP URL from given components.
HttpURL(String user, String password, String host, int port)
Construct a HTTP URL from given components.
HttpURL(String user, String password, String host, int port, String path)
Construct a HTTP URL from given components.
HttpURL(String user, String password, String host, int port, String path, String query)
Construct a HTTP URL from given components.
HttpURL(String host, String path, String query, String fragment)
Construct a HTTP URL from given components.
HttpURL(String userinfo, String host, String path, String query, String fragment)
Construct a HTTP URL from given components.
HttpURL(String userinfo, String host, int port, String path)
Construct a HTTP URL from given components.
HttpURL(String userinfo, String host, int port, String path, String query)
Construct a HTTP URL from given components.
HttpURL(String userinfo, String host, int port, String path, String query, String fragment)
Construct a HTTP URL from given components.
HttpURL(String user, String password, String host, int port, String path, String query, String fragment)
Construct a HTTP URL from given components.
HttpURL(HttpURL base, String relative)
Construct a HTTP URL with a given relative URL string.
HttpURL(HttpURL base, HttpURL relative)
Construct a HTTP URL with a given relative URL.
Method Summary
protected voidcheckValid()
Verify the valid class use for construction.
StringgetEscapedPassword()
Get the escaped password.
StringgetEscapedUser()
Get the escaped user
StringgetPassword()
Get the password.
intgetPort()
Get the port number.
char[]getRawAboveHierPath()
Get the level above the this hierarchy level.
char[]getRawCurrentHierPath()
Get the raw-escaped current hierarchy level.
char[]getRawPassword()
Get the raw-escaped password.
char[]getRawPath()
Get the raw escaped path.
char[]getRawScheme()
Get the scheme.
char[]getRawUser()
Get the raw-escaped user.
StringgetScheme()
Get the scheme.
StringgetUser()
Get the user.
voidsetEscapedPassword(String escapedPassword)
Set the escaped password string.
voidsetEscapedUser(String escapedUser)
Set the escaped user string.
voidsetEscapedUserinfo(String escapedUser, String escapedPassword)
Set the raw-escaped user and password.
voidsetPassword(String password)
Set the password string.
voidsetQuery(String queryName, String queryValue)
Set the query as the name and value pair.
voidsetQuery(String[] queryName, String[] queryValue)
Set the query as the name and value pairs.
voidsetRawPassword(char[] escapedPassword)
Set the raw-escaped password.
voidsetRawUser(char[] escapedUser)
Set the raw-escaped user.
voidsetRawUserinfo(char[] escapedUser, char[] escapedPassword)
Set the raw-escaped user and password.
protected voidsetURI()
Once it's parsed successfully, set this URI.
voidsetUser(String user)
Set the user string.
voidsetUserinfo(String user, String password)
Set the user and password.
protected static StringtoUserinfo(String user, String password)

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
Default port for HTTP URL.

DEFAULT_SCHEME

public static final char[] DEFAULT_SCHEME
Default scheme for HTTP URL.

_default_port

public static final int _default_port

Deprecated: Use {@link #DEFAULT_PORT} instead. This one doesn't conform to the project naming conventions.

Default port for HTTP URL.

_default_scheme

public static final char[] _default_scheme

Deprecated: Use {@link #DEFAULT_SCHEME} instead. This one doesn't conform to the project naming conventions.

Default scheme for HTTP URL.

Constructor Detail

HttpURL

protected HttpURL()
Create an instance as an internal use.

HttpURL

public HttpURL(char[] escaped, String charset)
Construct a HTTP URL as an escaped form of a character array with the given charset to do escape encoding.

Parameters: escaped the HTTP URL character sequence charset the charset string to do escape encoding

Throws: URIException If {@link #checkValid()} fails NullPointerException if escaped is null

See Also: HttpURL

HttpURL

public HttpURL(char[] escaped)
Construct a HTTP URL as an escaped form of a character array.

Parameters: escaped the HTTP URL character sequence

Throws: URIException If {@link #checkValid()} fails NullPointerException if escaped is null

See Also: HttpURL

HttpURL

public HttpURL(String original, String charset)
Construct a HTTP URL from a given string with the given charset to do escape encoding.

Parameters: original the HTTP URL string charset the charset string to do escape encoding

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String original)
Construct a HTTP URL from a given string.

Parameters: original the HTTP URL string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String host, int port, String path)
Construct a HTTP URL from given components.

Parameters: host the host string port the port number path the path string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String host, int port, String path, String query)
Construct a HTTP URL from given components.

Parameters: host the host string port the port number path the path string query the query string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String user, String password, String host)
Construct a HTTP URL from given components.

Parameters: user the user name password his or her password host the host string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String user, String password, String host, int port)
Construct a HTTP URL from given components.

Parameters: user the user name password his or her password host the host string port the port number

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String user, String password, String host, int port, String path)
Construct a HTTP URL from given components.

Parameters: user the user name password his or her password host the host string port the port number path the path string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String user, String password, String host, int port, String path, String query)
Construct a HTTP URL from given components.

Parameters: user the user name password his or her password host the host string port the port number path the path string query The query string.

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String host, String path, String query, String fragment)
Construct a HTTP URL from given components.

Parameters: host the host string path the path string query the query string fragment the fragment string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String userinfo, String host, String path, String query, String fragment)
Construct a HTTP URL from given components. Note: The userinfo format is normally <username>:<password> where username and password must both be URL escaped.

Parameters: userinfo the userinfo string whose parts are URL escaped host the host string path the path string query the query string fragment the fragment string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String userinfo, String host, int port, String path)
Construct a HTTP URL from given components. Note: The userinfo format is normally <username>:<password> where username and password must both be URL escaped.

Parameters: userinfo the userinfo string whose parts are URL escaped host the host string port the port number path the path string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String userinfo, String host, int port, String path, String query)
Construct a HTTP URL from given components. Note: The userinfo format is normally <username>:<password> where username and password must both be URL escaped.

Parameters: userinfo the userinfo string whose parts are URL escaped host the host string port the port number path the path string query the query string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String userinfo, String host, int port, String path, String query, String fragment)
Construct a HTTP URL from given components. Note: The userinfo format is normally <username>:<password> where username and password must both be URL escaped.

Parameters: userinfo the userinfo string whose parts are URL escaped host the host string port the port number path the path string query the query string fragment the fragment string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(String user, String password, String host, int port, String path, String query, String fragment)
Construct a HTTP URL from given components.

Parameters: user the user name password his or her password host the host string port the port number path the path string query the query string fragment the fragment string

Throws: URIException If {@link #checkValid()} fails

See Also: HttpURL

HttpURL

public HttpURL(HttpURL base, String relative)
Construct a HTTP URL with a given relative URL string.

Parameters: base the base HttpURL relative the relative HTTP URL string

Throws: URIException If {@link #checkValid()} fails

HttpURL

public HttpURL(HttpURL base, HttpURL relative)
Construct a HTTP URL with a given relative URL.

Parameters: base the base HttpURL relative the relative HttpURL

Throws: URIException If {@link #checkValid()} fails

Method Detail

checkValid

protected void checkValid()
Verify the valid class use for construction.

Throws: URIException the wrong scheme use

getEscapedPassword

public String getEscapedPassword()
Get the escaped password.

Returns: the escaped password

getEscapedUser

public String getEscapedUser()
Get the escaped user

Returns: the escaped user

getPassword

public String getPassword()
Get the password.

Returns: the password

Throws: URIException If {@link #decode(char[],String)} fails.

getPort

public int getPort()
Get the port number.

Returns: the port number

getRawAboveHierPath

public char[] getRawAboveHierPath()
Get the level above the this hierarchy level.

Returns: the raw above hierarchy level

Throws: URIException If {@link #getRawCurrentHierPath(char[])} fails.

getRawCurrentHierPath

public char[] getRawCurrentHierPath()
Get the raw-escaped current hierarchy level.

Returns: the raw-escaped current hierarchy level

Throws: URIException If {@link #getRawCurrentHierPath(char[])} fails.

getRawPassword

public char[] getRawPassword()
Get the raw-escaped password.

Returns: the raw-escaped password

getRawPath

public char[] getRawPath()
Get the raw escaped path.

Returns: the path '/' if empty or undefined

getRawScheme

public char[] getRawScheme()
Get the scheme. You can get the scheme explicitly.

Returns: the scheme

getRawUser

public char[] getRawUser()
Get the raw-escaped user.

Returns: the raw-escaped user

getScheme

public String getScheme()
Get the scheme. You can get the scheme explicitly.

Returns: the scheme null if empty or undefined

getUser

public String getUser()
Get the user.

Returns: the user name

Throws: URIException If {@link #decode} fails

setEscapedPassword

public void setEscapedPassword(String escapedPassword)
Set the escaped password string.

Parameters: escapedPassword the escaped password string; could be null

Throws: URIException escaped password not valid or username missed

setEscapedUser

public void setEscapedUser(String escapedUser)
Set the escaped user string.

Parameters: escapedUser the escaped user string

Throws: URIException escaped user not valid NullPointerException null user

setEscapedUserinfo

public void setEscapedUserinfo(String escapedUser, String escapedPassword)
Set the raw-escaped user and password.

Parameters: escapedUser the escaped user escapedPassword the escaped password; could be null

Throws: URIException escaped user not valid or user required; escaped password not valid or username missed NullPointerException null user

setPassword

public void setPassword(String password)
Set the password string.

Parameters: password the password string; could be null

Throws: URIException encoding error or username missed

setQuery

public void setQuery(String queryName, String queryValue)
Set the query as the name and value pair.

Parameters: queryName the query string. queryValue the query string.

Throws: URIException incomplete trailing escape pattern Or unsupported character encoding NullPointerException null query

See Also: HttpURL

setQuery

public void setQuery(String[] queryName, String[] queryValue)
Set the query as the name and value pairs.

Parameters: queryName the array of the query string. queryValue the array of the query string.

Throws: URIException incomplete trailing escape pattern, unsupported character encoding or wrong array size NullPointerException null query

See Also: HttpURL

setRawPassword

public void setRawPassword(char[] escapedPassword)
Set the raw-escaped password.

Parameters: escapedPassword the raw-escaped password; could be null

Throws: URIException escaped password not valid or username missed

setRawUser

public void setRawUser(char[] escapedUser)
Set the raw-escaped user.

Parameters: escapedUser the raw-escaped user

Throws: URIException escaped user not valid or user required

setRawUserinfo

public void setRawUserinfo(char[] escapedUser, char[] escapedPassword)
Set the raw-escaped user and password.

Parameters: escapedUser the raw-escaped user escapedPassword the raw-escaped password; could be null

Throws: URIException escaped user not valid or user required; escaped password not valid or username missed

setURI

protected void setURI()
Once it's parsed successfully, set this URI.

See Also: HttpURL

setUser

public void setUser(String user)
Set the user string.

Parameters: user the user string

Throws: URIException user encoding error NullPointerException null user

setUserinfo

public void setUserinfo(String user, String password)
Set the user and password.

Parameters: user the user password the password; could be null

Throws: URIException encoding error or username missed NullPointerException null user

toUserinfo

protected static String toUserinfo(String user, String password)
Copyright (c) 1999-2005 - Apache Software Foundation