org.jboss.resteasy.specimpl
Class UriBuilderImpl

java.lang.Object
  extended by javax.ws.rs.core.UriBuilder
      extended by org.jboss.resteasy.specimpl.UriBuilderImpl

public class UriBuilderImpl
extends UriBuilder

Version:
$Revision: 1 $
Author:
Bill Burke

Constructor Summary
UriBuilderImpl()
           
 
Method Summary
 URI build(Object... values)
          Build a URI, using the supplied values in order to replace any URI template parameters.
 URI build(Object[] values, boolean encodeSlashInPath)
          Build a URI, using the supplied values in order to replace any URI template parameters.
 URI buildFromEncoded(Object... values)
          Build a URI.
 URI buildFromEncodedMap(Map<String,? extends Object> values)
          Build a URI.
 URI buildFromMap(Map<String,? extends Object> values)
          Build a URI.
 URI buildFromMap(Map<String,? extends Object> paramMap, boolean fromEncodedMap)
          Build a URI.
protected  URI buildFromValues(boolean encoded, Object... values)
           
 UriBuilder clientQueryParam(String name, Object value)
          Called by ClientRequest.getUri() to add a query parameter for @QueryParam parameters.
 UriBuilder clone()
          Create a copy of the UriBuilder preserving its state.
static Matcher createUriParamMatcher(String string)
           
 UriBuilder fragment(String fragment)
          Set the URI fragment.
static UriBuilder fromTemplate(String uriTemplate)
          You may put path parameters anywhere within the uriTemplate except port
 String getFragment()
           
 String getHost()
           
 String getPath()
           
 List<String> getPathParamNamesInDeclarationOrder()
          Return a unique order list of path params
 int getPort()
           
 String getQuery()
           
 String getScheme()
           
 String getUserInfo()
           
 UriBuilder host(String host)
          Set the URI host.
 UriBuilder matrixParam(String name, Object... values)
          Append a matrix parameter to the existing set of matrix parameters of the current final segment of the URI path.
 UriBuilder path(Class resource)
          Append the path from a Path-annotated class to the existing path.
 UriBuilder path(Class resource, String method)
          Append the path from a Path-annotated method to the existing path.
 UriBuilder path(Method method)
          Append the path from a Path-annotated method to the existing path.
 UriBuilder path(String segment)
          Append path to the existing path.
protected static String paths(boolean encode, String basePath, String... segments)
           
 UriBuilder port(int port)
          Set the URI port.
 UriBuilder queryParam(String name, Object... values)
          Append a query parameter to the existing set of query parameters.
 UriBuilder replaceMatrix(String matrix)
          Set the matrix parameters of the current final segment of the current URI path.
 UriBuilder replaceMatrixParam(String name, Object... values)
          Replace the existing value(s) of a matrix parameter on the current final segment of the URI path.
protected  StringBuffer replaceParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer)
           
 UriBuilder replacePath(String path)
          Set the URI path.
protected  StringBuffer replacePathParameter(String name, String value, boolean isEncoded, String string, StringBuffer buffer)
           
 UriBuilder replaceQuery(String query)
          Set the URI query string.
 UriBuilder replaceQueryParam(String name, Object... values)
          Replace the existing value(s) of a query parameter.
protected  StringBuffer replaceQueryStringParameter(Map<String,? extends Object> paramMap, boolean fromEncodedMap, boolean isTemplate, String string, StringBuffer buffer)
           
 UriBuilder resolveTemplate(String name, Object value)
          Resolve a URI template with a given name in this UriBuilder instance using a supplied value.
 UriBuilder resolveTemplate(String name, Object value, boolean encodeSlashInPath)
          Resolve a URI template with a given name in this UriBuilder instance using a supplied value.
 UriBuilder resolveTemplateFromEncoded(String name, Object value)
          Resolve a URI template with a given name in this UriBuilder instance using a supplied encoded value.
 UriBuilder resolveTemplates(Map<String,Object> templateValues)
          Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.
 UriBuilder resolveTemplates(Map<String,Object> templateValues, boolean encodeSlashInPath)
          Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.
 UriBuilder resolveTemplatesFromEncoded(Map<String,Object> templateValues)
          Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs.
 UriBuilder scheme(String scheme)
          Set the URI scheme.
 UriBuilder schemeSpecificPart(String ssp)
          Set the URI scheme-specific-part (see URI).
 UriBuilder segment(String... segments)
          Append path segments to the existing path.
 UriBuilder substitutePathParam(String name, Object value, boolean isEncoded)
          Only replace path params in path of URI.
 String toTemplate()
          Get the URI template string represented by this URI builder.
 UriBuilder uri(String uriTemplate)
          Parses the uriTemplate string and copies the parsed components of the supplied URI to the UriBuilder replacing any existing values for those components.
 UriBuilder uri(URI uri)
          Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.
 UriBuilder uriTemplate(String uriTemplate)
          You may put path parameters anywhere within the uriTemplate except port
 UriBuilder userInfo(String ui)
          Set the URI user-info.
 
Methods inherited from class javax.ws.rs.core.UriBuilder
fromLink, fromMethod, fromPath, fromResource, fromUri, fromUri, newInstance
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriBuilderImpl

public UriBuilderImpl()
Method Detail

clone

public UriBuilder clone()
Description copied from class: UriBuilder
Create a copy of the UriBuilder preserving its state. This is a more efficient means of creating a copy than constructing a new UriBuilder from a URI returned by the UriBuilder.build(Object...) method.

Specified by:
clone in class UriBuilder
Returns:
a copy of the UriBuilder.

fromTemplate

public static UriBuilder fromTemplate(String uriTemplate)
You may put path parameters anywhere within the uriTemplate except port

Parameters:
uriTemplate -
Returns:

uriTemplate

public UriBuilder uriTemplate(String uriTemplate)
You may put path parameters anywhere within the uriTemplate except port

Parameters:
uriTemplate -
Returns:

uri

public UriBuilder uri(String uriTemplate)
               throws IllegalArgumentException
Description copied from class: UriBuilder
Parses the uriTemplate string and copies the parsed components of the supplied URI to the UriBuilder replacing any existing values for those components.

Specified by:
uri in class UriBuilder
Parameters:
uriTemplate - a URI template that will be used to initialize the UriBuilder, may contain URI parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if uriTemplate is not a valid URI template or is null.

uri

public UriBuilder uri(URI uri)
               throws IllegalArgumentException
Description copied from class: UriBuilder
Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.

Specified by:
uri in class UriBuilder
Parameters:
uri - the URI to copy components from.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the uri parameter is null.

scheme

public UriBuilder scheme(String scheme)
                  throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI scheme.

Specified by:
scheme in class UriBuilder
Parameters:
scheme - the URI scheme, may contain URI template parameters. A null value will unset the URI scheme, but will not unset the any scheme-specific-part components.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if scheme is invalid.

schemeSpecificPart

public UriBuilder schemeSpecificPart(String ssp)
                              throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI scheme-specific-part (see URI). This method will overwrite any existing values for authority, user-info, host, port and path.

Specified by:
schemeSpecificPart in class UriBuilder
Parameters:
ssp - the URI scheme-specific-part, may contain URI template parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if ssp cannot be parsed or is null.

userInfo

public UriBuilder userInfo(String ui)
Description copied from class: UriBuilder
Set the URI user-info.

Specified by:
userInfo in class UriBuilder
Parameters:
ui - the URI user-info, may contain URI template parameters. A null value will unset userInfo component of the URI.
Returns:
the updated UriBuilder.

host

public UriBuilder host(String host)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI host.

Specified by:
host in class UriBuilder
Parameters:
host - the URI host, may contain URI template parameters. A null value will unset the host component of the URI, but will not unset other authority component parts (user info or port).
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if host is invalid.

port

public UriBuilder port(int port)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI port.

Specified by:
port in class UriBuilder
Parameters:
port - the URI port, a value of -1 will unset an explicit port.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if port is invalid.

paths

protected static String paths(boolean encode,
                              String basePath,
                              String... segments)

path

public UriBuilder path(String segment)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Append path to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary. Existing '/' characters are preserved thus a single value can represent multiple URI path segments.

Specified by:
path in class UriBuilder
Parameters:
segment - the path, may contain URI template parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if path is null.

path

public UriBuilder path(Class resource)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Append the path from a Path-annotated class to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary.

Specified by:
path in class UriBuilder
Parameters:
resource - a resource whose Path value will be used to obtain the path to append.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if resource is null, or if resource is not annotated with Path.

path

public UriBuilder path(Class resource,
                       String method)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Append the path from a Path-annotated method to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary. This method is a convenience shortcut to path(Method), it can only be used in cases where there is a single method with the specified name that is annotated with Path.

Specified by:
path in class UriBuilder
Parameters:
resource - the resource containing the method.
method - the name of the method whose Path value will be used to obtain the path to append.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if resource or method is null, or there is more than or less than one variant of the method annotated with Path.

path

public UriBuilder path(Method method)
                throws IllegalArgumentException
Description copied from class: UriBuilder
Append the path from a Path-annotated method to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the supplied path if necessary.

Specified by:
path in class UriBuilder
Parameters:
method - a method whose Path value will be used to obtain the path to append to the existing path.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if method is null or is not annotated with a Path.

replaceMatrix

public UriBuilder replaceMatrix(String matrix)
                         throws IllegalArgumentException
Description copied from class: UriBuilder
Set the matrix parameters of the current final segment of the current URI path. This method will overwrite any existing matrix parameters on the current final segment of the current URI path. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.

Specified by:
replaceMatrix in class UriBuilder
Parameters:
matrix - the matrix parameters, may contain URI template parameters. A null value will remove all matrix parameters of the current final segment of the current URI path.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if matrix cannot be parsed.
See Also:
Matrix URIs

replaceQuery

public UriBuilder replaceQuery(String query)
                        throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI query string. This method will overwrite any existing query parameters.

Specified by:
replaceQuery in class UriBuilder
Parameters:
query - the URI query string, may contain URI template parameters. A null value will remove all query parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if query cannot be parsed.

fragment

public UriBuilder fragment(String fragment)
                    throws IllegalArgumentException
Description copied from class: UriBuilder
Set the URI fragment.

Specified by:
fragment in class UriBuilder
Parameters:
fragment - the URI fragment, may contain URI template parameters. A null value will remove any existing fragment.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException

substitutePathParam

public UriBuilder substitutePathParam(String name,
                                      Object value,
                                      boolean isEncoded)
Only replace path params in path of URI. This changes state of URIBuilder.

Parameters:
name -
value -
isEncoded -
Returns:

buildFromMap

public URI buildFromMap(Map<String,? extends Object> values)
                 throws IllegalArgumentException,
                        UriBuilderException
Description copied from class: UriBuilder
Build a URI. Any URI template parameters will be replaced by the value in the supplied map. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

NOTE: By default all '/' characters in the stringified values will be encoded in path templates, i.e. the result is identical to invoking buildFromMap(valueMap, true). To override this behavior use buildFromMap(valueMap, false) instead.

Specified by:
buildFromMap in class UriBuilder
Parameters:
values - a map of URI template parameter names and values.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.buildFromMap(java.util.Map, boolean), UriBuilder.buildFromEncodedMap(java.util.Map)

buildFromEncodedMap

public URI buildFromEncodedMap(Map<String,? extends Object> values)
                        throws IllegalArgumentException,
                               UriBuilderException
Description copied from class: UriBuilder
Build a URI. Any URI template parameters will be replaced by the value in the supplied map. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

Specified by:
buildFromEncodedMap in class UriBuilder
Parameters:
values - a map of URI template parameter names and values.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.buildFromMap(java.util.Map), UriBuilder.buildFromMap(java.util.Map, boolean)

buildFromMap

public URI buildFromMap(Map<String,? extends Object> paramMap,
                        boolean fromEncodedMap)
                 throws IllegalArgumentException,
                        UriBuilderException
Description copied from class: UriBuilder
Build a URI. Any URI template parameters will be replaced by the value in the supplied map. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

The encodeSlashInPath parameter may be used to override the default encoding of '/' characters in the stringified template values in cases when the template is part of the URI path component when using the UriBuilder.buildFromMap(java.util.Map) method. If the encodeSlashInPath parameter is set to true (default), the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component. If set to false the default encoding behavior is overridden an slash characters in template values will not be encoded when used to substitute path templates.

Specified by:
buildFromMap in class UriBuilder
Parameters:
paramMap - a map of URI template parameter names and values.
fromEncodedMap - if true, the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component, otherwise the slash characters will not be encoded in path templates.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a template parameter value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.buildFromMap(java.util.Map), UriBuilder.buildFromEncodedMap(java.util.Map)

replacePathParameter

protected StringBuffer replacePathParameter(String name,
                                            String value,
                                            boolean isEncoded,
                                            String string,
                                            StringBuffer buffer)

createUriParamMatcher

public static Matcher createUriParamMatcher(String string)

replaceParameter

protected StringBuffer replaceParameter(Map<String,? extends Object> paramMap,
                                        boolean fromEncodedMap,
                                        boolean isTemplate,
                                        String string,
                                        StringBuffer buffer)

replaceQueryStringParameter

protected StringBuffer replaceQueryStringParameter(Map<String,? extends Object> paramMap,
                                                   boolean fromEncodedMap,
                                                   boolean isTemplate,
                                                   String string,
                                                   StringBuffer buffer)

getPathParamNamesInDeclarationOrder

public List<String> getPathParamNamesInDeclarationOrder()
Return a unique order list of path params

Returns:

build

public URI build(Object... values)
          throws IllegalArgumentException,
                 UriBuilderException
Description copied from class: UriBuilder
Build a URI, using the supplied values in order to replace any URI template parameters. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".

NOTE: By default all '/' characters in the stringified values will be encoded in path templates, i.e. the result is identical to invoking UriBuilder.build(Object[], boolean) build(values, true)}. To override this behavior use build(values, false) instead.

Specified by:
build in class UriBuilder
Parameters:
values - a list of URI template parameter values.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.build(Object[], boolean), UriBuilder.buildFromEncoded(Object...)

buildFromValues

protected URI buildFromValues(boolean encoded,
                              Object... values)

matrixParam

public UriBuilder matrixParam(String name,
                              Object... values)
                       throws IllegalArgumentException
Description copied from class: UriBuilder
Append a matrix parameter to the existing set of matrix parameters of the current final segment of the URI path. If multiple values are supplied the parameter will be added once per value. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.

Specified by:
matrixParam in class UriBuilder
Parameters:
name - the matrix parameter name, may contain URI template parameters.
values - the matrix parameter value(s), each object will be converted. to a String using its toString() method. Stringified values may contain URI template parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if name or values is null.
See Also:
Matrix URIs

replaceMatrixParam

public UriBuilder replaceMatrixParam(String name,
                                     Object... values)
                              throws IllegalArgumentException
Description copied from class: UriBuilder
Replace the existing value(s) of a matrix parameter on the current final segment of the URI path. If multiple values are supplied the parameter will be added once per value. Note that the matrix parameters are tied to a particular path segment; subsequent addition of path segments will not affect their position in the URI path.

Specified by:
replaceMatrixParam in class UriBuilder
Parameters:
name - the matrix parameter name, may contain URI template parameters.
values - the matrix parameter value(s), each object will be converted. to a String using its toString() method. Stringified values may contain URI template parameters. If values is empty or null then all current values of the parameter are removed.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if name is null.
See Also:
Matrix URIs

clientQueryParam

public UriBuilder clientQueryParam(String name,
                                   Object value)
                            throws IllegalArgumentException
Called by ClientRequest.getUri() to add a query parameter for @QueryParam parameters. We do not use UriBuilder.queryParam() because

Parameters:
name - the name of the query parameter.
value - the value of the query parameter.
Returns:
Returns this instance to allow call chaining.
Throws:
IllegalArgumentException

queryParam

public UriBuilder queryParam(String name,
                             Object... values)
                      throws IllegalArgumentException
Description copied from class: UriBuilder
Append a query parameter to the existing set of query parameters. If multiple values are supplied the parameter will be added once per value.

Specified by:
queryParam in class UriBuilder
Parameters:
name - the query parameter name, may contain URI template parameters.
values - the query parameter value(s), each object will be converted to a String using its toString() method. Stringified values may contain URI template parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if name or values is null.

replaceQueryParam

public UriBuilder replaceQueryParam(String name,
                                    Object... values)
                             throws IllegalArgumentException
Description copied from class: UriBuilder
Replace the existing value(s) of a query parameter. If multiple values are supplied the parameter will be added once per value.

Specified by:
replaceQueryParam in class UriBuilder
Parameters:
name - the query parameter name, may contain URI template parameters.
values - the query parameter value(s), each object will be converted to a String using its toString() method. Stringified values may contain URI template parameters. If values is empty or null then all current values of the parameter are removed.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if name is null.

getHost

public String getHost()

getScheme

public String getScheme()

getPort

public int getPort()

getUserInfo

public String getUserInfo()

getPath

public String getPath()

getQuery

public String getQuery()

getFragment

public String getFragment()

segment

public UriBuilder segment(String... segments)
                   throws IllegalArgumentException
Description copied from class: UriBuilder
Append path segments to the existing path. When constructing the final path, a '/' separator will be inserted between the existing path and the first path segment if necessary and each supplied segment will also be separated by '/'. Existing '/' characters are encoded thus a single value can only represent a single URI path segment.

Specified by:
segment in class UriBuilder
Parameters:
segments - the path segment values, each may contain URI template parameters.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if segments or any element of segments is null.

buildFromEncoded

public URI buildFromEncoded(Object... values)
                     throws IllegalArgumentException,
                            UriBuilderException
Description copied from class: UriBuilder
Build a URI. Any URI templates parameters will be replaced with the supplied values in order. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".

Specified by:
buildFromEncoded in class UriBuilder
Parameters:
values - a list of URI template parameter values.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.build(Object[]), UriBuilder.build(Object[], boolean)

replacePath

public UriBuilder replacePath(String path)
Description copied from class: UriBuilder
Set the URI path. This method will overwrite any existing path and associated matrix parameters. Existing '/' characters are preserved thus a single value can represent multiple URI path segments.

Specified by:
replacePath in class UriBuilder
Parameters:
path - the path, may contain URI template parameters. A null value will unset the path component of the URI.
Returns:
the updated UriBuilder.

build

public URI build(Object[] values,
                 boolean encodeSlashInPath)
          throws IllegalArgumentException,
                 UriBuilderException
Description copied from class: UriBuilder
Build a URI, using the supplied values in order to replace any URI template parameters. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All '%' characters in the stringified values will be encoded. The state of the builder is unaffected; this method may be called multiple times on the same builder instance.

All instances of the same template parameter will be replaced by the same value that corresponds to the position of the first instance of the template parameter. e.g. the template "{a}/{b}/{a}" with values {"x", "y", "z"} will result in the the URI "x/y/x", not "x/y/z".

The encodeSlashInPath parameter may be used to override the default encoding of '/' characters in the stringified template values in cases when the template is part of the URI path component when using the UriBuilder.build(Object[]) method. If the encodeSlashInPath parameter is set to true (default), the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component. If set to false the default encoding behavior is overridden an slash characters in template values will not be encoded when used to substitute path templates.

Specified by:
build in class UriBuilder
Parameters:
values - a list of URI template parameter values.
encodeSlashInPath - if true, the slash ('/') characters in parameter values will be encoded if the template is placed in the URI path component, otherwise the slash characters will not be encoded in path templates.
Returns:
the URI built from the UriBuilder.
Throws:
IllegalArgumentException - if there are any URI template parameters without a supplied value, or if a value is null.
UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.build(Object[]), UriBuilder.buildFromEncoded(Object...)

toTemplate

public String toTemplate()
Description copied from class: UriBuilder
Get the URI template string represented by this URI builder.

Specified by:
toTemplate in class UriBuilder
Returns:
the URI template string for this URI builder.

resolveTemplate

public UriBuilder resolveTemplate(String name,
                                  Object value)
                           throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve a URI template with a given name in this UriBuilder instance using a supplied value. In case a null template name or value is entered a IllegalArgumentException is thrown.

Specified by:
resolveTemplate in class UriBuilder
Parameters:
name - name of the URI template.
value - value to be used to resolve the template.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the resolved template name or value is null.

resolveTemplates

public UriBuilder resolveTemplates(Map<String,Object> templateValues)
                            throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored.

Specified by:
resolveTemplates in class UriBuilder
Parameters:
templateValues - a map of URI template names and their values.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the name-value map or any of the names or values in the map is null.

resolveTemplate

public UriBuilder resolveTemplate(String name,
                                  Object value,
                                  boolean encodeSlashInPath)
                           throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve a URI template with a given name in this UriBuilder instance using a supplied value. In case a null template name or value is entered a IllegalArgumentException is thrown.

Specified by:
resolveTemplate in class UriBuilder
Parameters:
name - name of the URI template.
value - value to be used to resolve the template.
encodeSlashInPath - if true, the slash ('/') characters in template values will be encoded if the template is placed in the URI path component, otherwise the slash characters will not be encoded in path templates.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the resolved template name or value is null.

resolveTemplateFromEncoded

public UriBuilder resolveTemplateFromEncoded(String name,
                                             Object value)
                                      throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve a URI template with a given name in this UriBuilder instance using a supplied encoded value. A template with a matching name will be replaced by the supplied value. Value is converted to String using its toString() method and is then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. In case a null template name or encoded value is entered a IllegalArgumentException is thrown.

Specified by:
resolveTemplateFromEncoded in class UriBuilder
Parameters:
name - name of the URI template.
value - encoded value to be used to resolve the template.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the resolved template name or encoded value is null.

resolveTemplates

public UriBuilder resolveTemplates(Map<String,Object> templateValues,
                                   boolean encodeSlashInPath)
                            throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. A call to the method with an empty parameter map is ignored.

Specified by:
resolveTemplates in class UriBuilder
Parameters:
templateValues - a map of URI template names and their values.
encodeSlashInPath - if true, the slash ('/') characters in template values will be encoded if the template is placed in the URI path component, otherwise the slash characters will not be encoded in path templates.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the name-value map or any of the names or values in the map is null.

resolveTemplatesFromEncoded

public UriBuilder resolveTemplatesFromEncoded(Map<String,Object> templateValues)
                                       throws IllegalArgumentException
Description copied from class: UriBuilder
Resolve one or more URI templates in this UriBuilder instance using supplied name-value pairs. All templates with their name matching one of the keys in the supplied map will be replaced by the value in the supplied map. Values are converted to String using their toString() method and are then encoded to match the rules of the URI component to which they pertain. All % characters in the stringified values that are not followed by two hexadecimal numbers will be encoded. A call to the method with an empty parameter map is ignored.

Specified by:
resolveTemplatesFromEncoded in class UriBuilder
Parameters:
templateValues - a map of URI template names and their values.
Returns:
the updated UriBuilder.
Throws:
IllegalArgumentException - if the name-value map or any of the names or values in the map is null.


Copyright © 2013. All Rights Reserved.