Constructor and Description |
---|
URIBuilder()
Constructs an empty instance.
|
URIBuilder(String string)
Construct an instance from the string which must be a valid URI.
|
URIBuilder(String string,
java.nio.charset.Charset charset)
Construct an instance from the string which must be a valid URI.
|
URIBuilder(URI uri)
Construct an instance from the provided URI.
|
URIBuilder(URI uri,
java.nio.charset.Charset charset)
Construct an instance from the provided URI.
|
Modifier and Type | Method and Description |
---|---|
URIBuilder |
addParameter(String param,
String value)
Adds parameter to URI query.
|
URIBuilder |
addParameters(List<NameValuePair> nvps)
Adds URI query parameters.
|
URI |
build()
Builds a
URI instance. |
URIBuilder |
clearParameters()
Clears URI query parameters.
|
java.nio.charset.Charset |
getCharset() |
String |
getFragment() |
String |
getHost() |
String |
getPath() |
List<String> |
getPathSegments() |
int |
getPort() |
List<NameValuePair> |
getQueryParams() |
String |
getScheme() |
String |
getUserInfo() |
boolean |
isAbsolute() |
boolean |
isOpaque() |
boolean |
isPathEmpty() |
boolean |
isQueryEmpty() |
static URIBuilder |
localhost()
Creates a new builder for the host
InetAddress.getLocalHost() . |
static URIBuilder |
loopbackAddress()
Creates a new builder for the host
InetAddress.getLoopbackAddress() . |
URIBuilder |
removeQuery()
Removes URI query.
|
URIBuilder |
setCharset(java.nio.charset.Charset charset) |
URIBuilder |
setCustomQuery(String query)
Sets custom URI query.
|
URIBuilder |
setFragment(String fragment)
Sets URI fragment.
|
URIBuilder |
setHost(InetAddress host)
Sets URI host.
|
URIBuilder |
setHost(String host)
Sets URI host.
|
URIBuilder |
setHttpHost(HttpHost httpHost)
Sets the scheme, host name, and port.
|
URIBuilder |
setParameter(String param,
String value)
Sets parameter of URI query overriding existing value if set.
|
URIBuilder |
setParameters(List<NameValuePair> nvps)
Sets URI query parameters.
|
URIBuilder |
setParameters(NameValuePair... nvps)
Sets URI query parameters.
|
URIBuilder |
setPath(String path)
Sets URI path.
|
URIBuilder |
setPathSegments(List<String> pathSegments)
Sets URI path.
|
URIBuilder |
setPathSegments(String... pathSegments)
Sets URI path.
|
URIBuilder |
setPort(int port)
Sets URI port.
|
URIBuilder |
setScheme(String scheme)
Sets URI scheme.
|
URIBuilder |
setUserInfo(String userInfo)
Sets URI user info.
|
URIBuilder |
setUserInfo(String username,
String password)
Sets URI user info as a combination of username and password.
|
String |
toString()
Returns a string representation of the object.
|
public URIBuilder()
public URIBuilder(String string) throws URISyntaxException
string
- a valid URI in string formURISyntaxException
- if the input is not a valid URIpublic URIBuilder(String string, java.nio.charset.Charset charset) throws URISyntaxException
string
- a valid URI in string formURISyntaxException
- if the input is not a valid URIpublic URIBuilder(URI uri)
uri
- public URIBuilder(URI uri, java.nio.charset.Charset charset)
uri
- public URIBuilder addParameter(String param, String value)
Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.
public URIBuilder addParameters(List<NameValuePair> nvps)
Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.
public URI build() throws URISyntaxException
URI
instance.URISyntaxException
public URIBuilder clearParameters()
public java.nio.charset.Charset getCharset()
public String getFragment()
public String getHost()
public String getPath()
public int getPort()
public List<NameValuePair> getQueryParams()
public String getScheme()
public String getUserInfo()
public boolean isAbsolute()
public boolean isOpaque()
public boolean isPathEmpty()
public boolean isQueryEmpty()
public static URIBuilder localhost() throws UnknownHostException
InetAddress.getLocalHost()
.UnknownHostException
- if the local host name could not be resolved into an address.public static URIBuilder loopbackAddress()
InetAddress.getLoopbackAddress()
.public URIBuilder removeQuery()
public URIBuilder setCharset(java.nio.charset.Charset charset)
public URIBuilder setCustomQuery(String query)
Please note query parameters and custom query component are mutually exclusive. This method will remove query parameters if present.
public URIBuilder setFragment(String fragment)
public URIBuilder setHost(InetAddress host)
public URIBuilder setHost(String host)
public URIBuilder setHttpHost(HttpHost httpHost)
httpHost
- the scheme, host name, and port.public URIBuilder setParameter(String param, String value)
Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.
public URIBuilder setParameters(List<NameValuePair> nvps)
Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.
public URIBuilder setParameters(NameValuePair... nvps)
Please note query parameters and custom query component are mutually exclusive. This method will remove custom query if present.
public URIBuilder setPath(String path)
public URIBuilder setPathSegments(List<String> pathSegments)
public URIBuilder setPathSegments(String... pathSegments)
public URIBuilder setPort(int port)
public URIBuilder setScheme(String scheme)
public URIBuilder setUserInfo(String userInfo)
public URIBuilder setUserInfo(String username, String password)
public String toString()
Object
toString
method returns a
string that "textually represents" this object. The result should be a concise but informative
representation that is easy for a person to read. It is recommended that all subclasses override
this method.
The toString
method for class Object
returns a string consisting of the name of
the class of which the object is an instance, the at-sign character `@
', and the unsigned
hexadecimal representation of the hash code of the object. In other words, this method returns a
string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())