org.restlet.ext.jaxrs
Class AbstractUriBuilder

java.lang.Object
  extended by javax.ws.rs.core.UriBuilder
      extended by org.restlet.ext.jaxrs.AbstractUriBuilder
Direct Known Subclasses:
ExtendedUriBuilder

public abstract class AbstractUriBuilder
extends javax.ws.rs.core.UriBuilder

Abstract implementation of interface UriBuilder. Not intended for public use.

Author:
Stephan Koops
See Also:
UriBuilder

Constructor Summary
protected AbstractUriBuilder()
           
 
Method Summary
 URI build(Object... values)
          Build a URI, using the supplied values in order to replace any URI template parameters.
 URI buildFromEncoded(Object... values)
           
 URI buildFromEncodedMap(Map<String,? extends Object> values)
           
 URI buildFromMap(Map<String,? extends Object> values)
           
protected  void copyInto(AbstractUriBuilder uriBuilder)
           
 javax.ws.rs.core.UriBuilder fragment(String fragment)
          Set the URI fragment using an unencoded value.
protected  String getExtension()
           
 javax.ws.rs.core.UriBuilder host(String host)
          Set the URI host.
 javax.ws.rs.core.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.
protected  javax.ws.rs.core.UriBuilder path(CharSequence pathToAppend)
          Appends the given path to the current path.S
 javax.ws.rs.core.UriBuilder path(Class rootResource)
          Append path segments from a Path-annotated class to the existing list of segments.
 javax.ws.rs.core.UriBuilder path(Class rootResource, String methodName)
          Append path segments from a Path-annotated method to the existing list of segments.
 javax.ws.rs.core.UriBuilder path(Method method)
          Append the path from a Path-annotated method to the existing path.
 javax.ws.rs.core.UriBuilder path(String pathToAppend)
          Append path to the existing path.
 javax.ws.rs.core.UriBuilder port(int port)
          Set the URI port.
 javax.ws.rs.core.UriBuilder port(String port)
          Set the URI port.
 javax.ws.rs.core.UriBuilder queryParam(String name, Object... values)
          Append a query parameter to the existing set of query parameters.
 javax.ws.rs.core.UriBuilder replaceMatrix(String matrix)
          Set the matrix parameters of the current final segment of the current URI path.
 javax.ws.rs.core.UriBuilder replaceMatrixParam(String name, Object... values)
           
protected  javax.ws.rs.core.UriBuilder replacePath(CharSequence newPath)
          Replaces the current path with the given path.
 javax.ws.rs.core.UriBuilder replacePath(String newPath)
          Set the URI path.
 javax.ws.rs.core.UriBuilder replaceQuery(String query)
          Set the URI query string.
 javax.ws.rs.core.UriBuilder replaceQueryParam(String name, Object... values)
           
 javax.ws.rs.core.UriBuilder scheme(String scheme)
          Set the URI scheme.
 javax.ws.rs.core.UriBuilder schemeSpecificPart(String ssp)
          Set the URI scheme-specific-part (see URI).
 javax.ws.rs.core.UriBuilder segment(String... segments)
          Append path segments to the existing path.
 String toString()
          Returns the actual URI as String.
 javax.ws.rs.core.UriBuilder uri(URI uri)
          Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.
 javax.ws.rs.core.UriBuilder userInfo(String userInfo)
          Set the URI user-info.
 
Methods inherited from class javax.ws.rs.core.UriBuilder
clone, fromPath, fromResource, fromUri, fromUri, newInstance
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractUriBuilder

protected AbstractUriBuilder()
Method Detail

build

public URI build(Object... values)
          throws IllegalArgumentException,
                 javax.ws.rs.core.UriBuilderException
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".

Specified by:
build in class javax.ws.rs.core.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.
javax.ws.rs.core.UriBuilderException - if a URI cannot be constructed based on the current state of the builder.
See Also:
UriBuilder.build(java.lang.Object[])

buildFromEncoded

public URI buildFromEncoded(Object... values)
                     throws IllegalArgumentException,
                            javax.ws.rs.core.UriBuilderException
Specified by:
buildFromEncoded in class javax.ws.rs.core.UriBuilder
Throws:
IllegalArgumentException
javax.ws.rs.core.UriBuilderException
See Also:
UriBuilder.buildFromEncoded(java.lang.Object[])

buildFromEncodedMap

public URI buildFromEncodedMap(Map<String,? extends Object> values)
                        throws IllegalArgumentException,
                               javax.ws.rs.core.UriBuilderException
Specified by:
buildFromEncodedMap in class javax.ws.rs.core.UriBuilder
Throws:
IllegalArgumentException
javax.ws.rs.core.UriBuilderException
See Also:
UriBuilder.buildFromEncodedMap(java.util.Map)

buildFromMap

public URI buildFromMap(Map<String,? extends Object> values)
                 throws IllegalArgumentException,
                        javax.ws.rs.core.UriBuilderException
Specified by:
buildFromMap in class javax.ws.rs.core.UriBuilder
Throws:
IllegalArgumentException
javax.ws.rs.core.UriBuilderException
See Also:
UriBuilder.buildFromMap(java.util.Map)

copyInto

protected void copyInto(AbstractUriBuilder uriBuilder)
Parameters:
uriBuilder -

fragment

public javax.ws.rs.core.UriBuilder fragment(String fragment)
                                     throws IllegalArgumentException
Set the URI fragment using an unencoded value.

Specified by:
fragment in class javax.ws.rs.core.UriBuilder
Parameters:
fragment - the URI fragment, may contain URI template parameters
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if fragment is null, or if automatic encoding is disabled and fragment contains illegal characters
See Also:
UriBuilder.fragment(java.lang.String)

getExtension

protected String getExtension()
Returns:
the extension of the current state, with a "." at beginning. Is intended to be overriden in subclass ExtendedUriBuilder. Must not return null, "" or ".".

host

public javax.ws.rs.core.UriBuilder host(String host)
                                 throws IllegalArgumentException
Set the URI host.

Specified by:
host in class javax.ws.rs.core.UriBuilder
Parameters:
host - the URI host, may contain URI template parameters
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if host is invalid or is null
See Also:
UriBuilder.host(java.lang.String)

matrixParam

public javax.ws.rs.core.UriBuilder matrixParam(String name,
                                               Object... values)
                                        throws IllegalArgumentException
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 javax.ws.rs.core.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 value is null, or if automatic encoding is disabled and the name or any stringified value contains illegal characters
See Also:
Matrix URIs, UriBuilder.matrixParam(String, Object...)

path

protected javax.ws.rs.core.UriBuilder path(CharSequence pathToAppend)
                                    throws IllegalArgumentException
Appends the given path to the current path.S

Parameters:
pathToAppend -
Returns:
the current UriBuilder
Throws:
IllegalArgumentException

path

public javax.ws.rs.core.UriBuilder path(Class rootResource)
                                 throws IllegalArgumentException
Append path segments from a Path-annotated class to the existing list of segments. When constructing the final path, each segment will be separated by '/' if necessary. The value of the encode property of the Path annotation will be used when processing the value of the @Path but it will not be used to modify the state of automatic encoding for the builder.

Specified by:
path in class javax.ws.rs.core.UriBuilder
Parameters:
rootResource - a resource whose @Path value will be used to obtain the path segment.
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if resource is null, or if resource.encode is false and resource.value contains illegal characters, or if resource is not annotated with UrPath
See Also:
UriBuilder.path(java.lang.Class)

path

public javax.ws.rs.core.UriBuilder path(Class rootResource,
                                        String methodName)
                                 throws IllegalArgumentException
Append path segments from a Path-annotated method to the existing list of segments. When constructing the final path, each segment will be separated by '/' 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 javax.ws.rs.core.UriBuilder
Parameters:
rootResource - the root resource class containing the method.
methodName - the name of the method whose @Path value will be used to obtain the path segment.
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if resource or method is null, or if the specified method does not exist, or there is more than or less than one variant of the method annotated with UriPath
See Also:
UriBuilder.path(java.lang.Class, java.lang.String)

path

public javax.ws.rs.core.UriBuilder path(Method method)
                                 throws IllegalArgumentException
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 javax.ws.rs.core.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 any element of methods is null or is not annotated with a Path
See Also:
UriBuilder.path(java.lang.reflect.Method)

path

public javax.ws.rs.core.UriBuilder path(String pathToAppend)
                                 throws IllegalArgumentException
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 javax.ws.rs.core.UriBuilder
Parameters:
pathToAppend - the path to append to the current path, may contain URI template parameters
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if path is null
See Also:
UriBuilder.path(java.lang.String)

port

public javax.ws.rs.core.UriBuilder port(int port)
                                 throws IllegalArgumentException
Set the URI port.

Specified by:
port in class javax.ws.rs.core.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
See Also:
UriBuilder.port(int)

port

public javax.ws.rs.core.UriBuilder port(String port)
                                 throws IllegalArgumentException
Set the URI port. Only integers or a variable template is allowed

Parameters:
port - the URI port (null will unset an explicit port) or a template variable.
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if given value is invalid
See Also:
port(int)

queryParam

public javax.ws.rs.core.UriBuilder queryParam(String name,
                                              Object... values)
                                       throws IllegalArgumentException
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 javax.ws.rs.core.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 value is null, or if automatic encoding is disabled and name or value contains illegal characters
See Also:
UriBuilder.queryParam(String, Object...)

replaceMatrix

public javax.ws.rs.core.UriBuilder replaceMatrix(String matrix)
                                          throws IllegalArgumentException
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 javax.ws.rs.core.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, or if automatic encoding is disabled and any matrix parameter name or value contains illegal characters
See Also:
UriBuilder.replaceMatrix(String)

replaceMatrixParam

public javax.ws.rs.core.UriBuilder replaceMatrixParam(String name,
                                                      Object... values)
                                               throws IllegalArgumentException
Specified by:
replaceMatrixParam in class javax.ws.rs.core.UriBuilder
Throws:
IllegalArgumentException
See Also:
UriBuilder.replaceMatrixParam(java.lang.String, java.lang.Object[])

replacePath

protected javax.ws.rs.core.UriBuilder replacePath(CharSequence newPath)
                                           throws IllegalArgumentException
Replaces the current path with the given path. This method checks, if there is an extension in, if needed by this class.

Parameters:
newPath - the new path.
Throws:
IllegalArgumentException

replacePath

public javax.ws.rs.core.UriBuilder replacePath(String newPath)
                                        throws IllegalArgumentException
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 javax.ws.rs.core.UriBuilder
Parameters:
newPath - the path to replace the old path with, may contain URI template parameters. A null value will unset the path component of the URI.
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException
See Also:
UriBuilder.replacePath(java.lang.String)

replaceQuery

public javax.ws.rs.core.UriBuilder replaceQuery(String query)
                                         throws IllegalArgumentException
Set the URI query string. This method will overwrite any existing query parameters.

Specified by:
replaceQuery in class javax.ws.rs.core.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
See Also:
UriBuilder.replaceQuery(java.lang.String)

replaceQueryParam

public javax.ws.rs.core.UriBuilder replaceQueryParam(String name,
                                                     Object... values)
                                              throws IllegalArgumentException
Specified by:
replaceQueryParam in class javax.ws.rs.core.UriBuilder
Throws:
IllegalArgumentException
See Also:
UriBuilder.replaceQueryParam(String, Object[])

scheme

public javax.ws.rs.core.UriBuilder scheme(String scheme)
                                   throws IllegalArgumentException
Set the URI scheme.

Specified by:
scheme in class javax.ws.rs.core.UriBuilder
Parameters:
scheme - the URI scheme, may contain URI template parameters
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if scheme is invalid or is null
See Also:
UriBuilder.scheme(java.lang.String)

schemeSpecificPart

public javax.ws.rs.core.UriBuilder schemeSpecificPart(String ssp)
                                               throws IllegalArgumentException
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 javax.ws.rs.core.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
See Also:
UriBuilder.schemeSpecificPart(java.lang.String)

segment

public javax.ws.rs.core.UriBuilder segment(String... segments)
                                    throws IllegalArgumentException
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 javax.ws.rs.core.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
See Also:
UriBuilder.segment(java.lang.String[])

toString

public String toString()
Returns the actual URI as String.

Overrides:
toString in class Object
Returns:
the actual URI as String.
See Also:
toStringWithCheck(boolean)

uri

public javax.ws.rs.core.UriBuilder uri(URI uri)
                                throws IllegalArgumentException
Copies the non-null components of the supplied URI to the UriBuilder replacing any existing values for those components.

Specified by:
uri in class javax.ws.rs.core.UriBuilder
Parameters:
uri - the URI to copy components from
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if uri is null
See Also:
UriBuilder.uri(java.net.URI)

userInfo

public javax.ws.rs.core.UriBuilder userInfo(String userInfo)
                                     throws IllegalArgumentException
Set the URI user-info.

Specified by:
userInfo in class javax.ws.rs.core.UriBuilder
Parameters:
userInfo - the URI user-info, may contain URI template parameters
Returns:
the updated UriBuilder
Throws:
IllegalArgumentException - if automatic encoding is disabled and the userInfo contains illegal characters, or if the userInfo is null.
See Also:
UriBuilder.userInfo(java.lang.String)


Copyright © 2005-2013 Restlet.