public abstract class URIBuilder
extends java.lang.Object
URIBuilder allows to use templates. The URI template has the following format:
uri_template = "{" template_name "}" template_name = 1*(ALPHA / DIGIT)URIBuilder builder = URIBuilder.getInstance("http://example.com/{A}/{B}"); String uri = builder.build("template", "value"); The uri is http://example.com/template/value
Constructor and Description |
---|
URIBuilder() |
Modifier and Type | Method and Description |
---|---|
abstract URIBuilder |
appendPath(java.lang.String path)
Appends the given
path to the existing path. |
abstract URIBuilder |
appendQueryParameter(java.lang.String parameter,
java.lang.String value)
Appends query parameter to the existing query.
|
abstract java.lang.String |
build(java.util.Map<java.lang.String,java.lang.String> values)
Builds the string representation of URI using the given values.
|
abstract java.lang.String |
build(java.lang.String... values)
Builds the string representation of URI using the given values.
|
abstract java.lang.String |
getFragment()
Returns the URI fragment.
|
abstract java.lang.String |
getHost()
Returns the URI host.
|
static URIBuilder |
getInstance()
Returns a new instance
URIBuilder . |
static URIBuilder |
getInstance(java.lang.String uri)
Returns a new instance
URIBuilder . |
static URIBuilder |
getInstance(URIBuilder builder)
Returns a new instance
URIBuilder . |
abstract java.lang.String |
getPath()
Returns the URI path.
|
abstract int |
getPort()
Returns the URI port.
|
abstract java.lang.String |
getQuery()
Returns the URI query.
|
abstract java.lang.String |
getScheme()
Returns the URI scheme.
|
abstract java.lang.String |
getUserInfo()
Returns the user information.
|
abstract URIBuilder |
setFragment(java.lang.String fragment)
Set the URI fragment.
|
abstract URIBuilder |
setHost(java.lang.String host)
Set the URI host.
|
abstract URIBuilder |
setPath(java.lang.String path)
Set the URI path.
|
abstract URIBuilder |
setPort(int port)
Set the URI port.
|
abstract URIBuilder |
setQuery(java.lang.String query)
Set the URI query.
|
abstract URIBuilder |
setScheme(java.lang.String scheme)
Set the URI scheme.
|
abstract URIBuilder |
setUserInfo(java.lang.String userInfo)
Set the user information.
|
public static URIBuilder getInstance()
URIBuilder
.URIBuilder
.public static URIBuilder getInstance(java.lang.String uri)
URIBuilder
.uri
- describes the target should conform to the URI format
as described in RFC 3986.
This takes the general form:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]URIBuilder
.java.lang.NullPointerException
- in case of given uri
is null
.public static URIBuilder getInstance(URIBuilder builder)
URIBuilder
.
The state of a new builder will be copied from the given builder
.builder
- data used to provide initial state for the new uri builder.URIBuilder
.java.lang.NullPointerException
- in case of given builder
is null
.public abstract URIBuilder setScheme(java.lang.String scheme)
scheme
- URI scheme. The given scheme
may contain uri templates.
A null
value will unset the URI scheme.java.lang.IllegalArgumentException
- in case of given scheme
is invalid.public abstract java.lang.String getScheme()
null
.public abstract URIBuilder setUserInfo(java.lang.String userInfo)
userInfo
- user information. The given userInfo
may contain uri templates.
A null
value will unset the user information.java.lang.IllegalArgumentException
- in case of given userInfo
is invalid.public abstract java.lang.String getUserInfo()
null
.public abstract URIBuilder setHost(java.lang.String host)
host
- URI host. The given host
may contain uri templates.
A null
value will unset the host.java.lang.IllegalArgumentException
- in case of given host
is invalid.public abstract java.lang.String getHost()
null
.public abstract URIBuilder setPort(int port)
port
- port. A -1
value will unset the port.java.lang.IllegalArgumentException
- in case of given port
is invalid.public abstract int getPort()
-1
.public abstract URIBuilder setPath(java.lang.String path)
path
- URI path. The given path
may contain uri templates.
A null
value will unset the path.java.lang.IllegalArgumentException
- in case of given path
is invalid.public abstract URIBuilder appendPath(java.lang.String path)
path
to the existing path.path
- URI path. The given path
may contain uri templates.java.lang.IllegalArgumentException
- in case of given path
is invalid.public abstract java.lang.String getPath()
null
.public abstract URIBuilder setQuery(java.lang.String query)
query
- URI query. The given query
may contain uri templates.
A null
value will unset the query.java.lang.IllegalArgumentException
- in case of given query
is invalid.public abstract URIBuilder appendQueryParameter(java.lang.String parameter, java.lang.String value)
parameter
- query parameter name. May contain uri templates.value
- query parameter value. May contain uri templates.IllegaArgumentException
- in case of parameter
or value
is invalid.java.lang.NullPointerException
- in case of parameter
or value
is null.public abstract java.lang.String getQuery()
null
.public abstract URIBuilder setFragment(java.lang.String fragment)
fragment
- URI fragment. May contain uri templates.
A null
value will unset the fragment.java.lang.IllegalArgumentException
- in case of given fragment
is invalid.public abstract java.lang.String getFragment()
null
.public abstract java.lang.String build(java.lang.String... values)
values
- list of uri template values.java.lang.NullPointerException
- in case of values
is null
.java.lang.IllegalArgumentException
- in case of any uri template cannot be resolved by the given values
.public abstract java.lang.String build(java.util.Map<java.lang.String,java.lang.String> values)
values
- map of uri template names and values.java.lang.NullPointerException
- in case of values
is null
.java.lang.IllegalArgumentException
- in case of any uri template cannot be resolved by the given values
.Copyright © 2013, 2014, Oracle and/or its affiliates. All rights reserved.