def uri = UriBuilder.basic(UriBuilder.root())
.setFull('http://localhost:10101')
.setPath('/foo')
.toURI()
public abstract class UriBuilder
extends java.lang.Object
Provides a simple means of creating a request URI and optionally overriding its parts.
def uri = UriBuilder.basic(UriBuilder.root())
.setFull('http://localhost:10101')
.setPath('/foo')
.toURI()
Generally, this class is not instantiated directly, but created by the HttpConfig instance and modified.
| Modifier and Type | Field and Description | 
|---|---|
static int | 
DEFAULT_PORT  | 
| Constructor and Description | 
|---|
UriBuilder()  | 
| Modifier and Type | Method and Description | 
|---|---|
static UriBuilder | 
basic(UriBuilder parent)
Creates a basic  
UriBuilder from the provided parent builder. | 
java.net.URI | 
forCookie(java.net.HttpCookie cookie)  | 
abstract java.lang.String | 
getFragment()
Retrieves the fragment part of the  
URI. | 
abstract java.lang.String | 
getHost()
Retrieves the host part of the URI. 
 | 
abstract UriBuilder | 
getParent()  | 
abstract GString | 
getPath()
Retrieves the path part of the URI. 
 | 
abstract int | 
getPort()
Retrieves the port part of the URI. 
 | 
abstract java.util.Map<java.lang.String,?> | 
getQuery()
Retrieves the  
Map of query string parameters for the URI. | 
abstract java.lang.String | 
getScheme()
Retrieves the scheme part of the URI. 
 | 
java.lang.Boolean | 
getUseRawValues()  | 
abstract java.lang.String | 
getUserInfo()
Retrieves the user info part of the  
URI. | 
protected void | 
populateFrom(java.net.URI uri)  | 
static UriBuilder | 
root()  | 
abstract UriBuilder | 
setFragment(java.lang.String val)
Sets the fragment part of the  
URI. | 
UriBuilder | 
setFull(java.lang.String str)
Sets the full URI (all parts) as a String. 
 | 
UriBuilder | 
setFull(java.net.URI uri)
Sets the full URI (all parts) as a URI object. 
 | 
abstract UriBuilder | 
setHost(java.lang.String val)
Sets the host part of the URI. 
 | 
abstract UriBuilder | 
setPath(GString val)
Sets the path part of the URI. 
 | 
UriBuilder | 
setPath(java.lang.String str)
Sets the path part of the URI. 
 | 
abstract UriBuilder | 
setPort(int val)
Sets the port part of the URI. 
 | 
abstract UriBuilder | 
setQuery(java.util.Map<java.lang.String,?> val)
Sets the query string part of the  
URI from the provided map. | 
abstract UriBuilder | 
setScheme(java.lang.String val)
Sets the scheme part of the URI. 
 | 
void | 
setUseRawValues(boolean useRaw)  | 
abstract UriBuilder | 
setUserInfo(java.lang.String val)
Sets the user info part of the  
URI. | 
static UriBuilder | 
threadSafe(UriBuilder parent)
Creates a thread-safe  
UriBuilder from the provided parent builder. | 
java.net.URI | 
toURI()
Converts the parts of the  
UriBuilder to the URI object instance. | 
public static final int DEFAULT_PORT
public abstract UriBuilder setScheme(java.lang.String val)
Sets the scheme part of the URI.
val - the value to use as the scheme part of the URIpublic abstract java.lang.String getScheme()
Retrieves the scheme part of the URI.
public abstract UriBuilder setPort(int val)
Sets the port part of the URI.
val - the value to use as the port part of the URIpublic abstract int getPort()
Retrieves the port part of the URI.
public abstract UriBuilder setHost(java.lang.String val)
Sets the host part of the URI.
val - the value to use as the host part of the URIpublic abstract java.lang.String getHost()
Retrieves the host part of the URI.
public abstract UriBuilder setPath(GString val)
Sets the path part of the URI.
val - the path part of the URIpublic abstract GString getPath()
Retrieves the path part of the URI.
public abstract UriBuilder setQuery(java.util.Map<java.lang.String,?> val)
Sets the query string part of the URI from the provided map. The query string key-value pairs will be generated from the key-value pairs
of the map and are NOT URL-encoded. Nested maps or other data structures are not supported.
val - the map of query string parameterspublic abstract java.util.Map<java.lang.String,?> getQuery()
Retrieves the Map of query string parameters for the URI.
Map of query string parameters for the URI.public abstract UriBuilder setFragment(java.lang.String val)
Sets the fragment part of the URI.
val - the fragment part of the URIpublic abstract java.lang.String getFragment()
Retrieves the fragment part of the URI.
URIpublic abstract UriBuilder setUserInfo(java.lang.String val)
Sets the user info part of the URI.
val - the user info part of the URIpublic abstract java.lang.String getUserInfo()
Retrieves the user info part of the URI.
URIpublic abstract UriBuilder getParent()
public UriBuilder setPath(java.lang.String str)
Sets the path part of the URI.
str - the path part of the URIpublic java.net.URI forCookie(java.net.HttpCookie cookie)
                       throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic java.net.URI toURI()
                   throws java.net.URISyntaxException
Converts the parts of the UriBuilder to the URI object instance.
URI representing the parts contained in the builderjava.net.URISyntaxExceptionpublic void setUseRawValues(boolean useRaw)
public java.lang.Boolean getUseRawValues()
protected final void populateFrom(java.net.URI uri)
public final UriBuilder setFull(java.lang.String str)
Sets the full URI (all parts) as a String.
str - the full URI to be used by the UriBuilderjava.lang.IllegalArgumentException - if there is a problem with the URI syntaxpublic final UriBuilder setFull(java.net.URI uri)
Sets the full URI (all parts) as a URI object.
uri - the full URI to be used by the UriBuilderpublic static UriBuilder basic(UriBuilder parent)
Creates a basic UriBuilder from the provided parent builder. An empty UriBuilder may be created using the root() method as the parent value,
otherwise a new UriBuilder may be created from an existing builder:
def parent = UriBuilder.basic(UriBuilder.root()).setFull('http://localhost:10101/foo')
def child = UriBuilder.basic(parent)
child.setPath('/bar').toURI() == new URI('http://localhost:10101/bar')
The UriBuilder implementation generated with this method is not thread-safe.
parent - the UriBuilder parentUriBuilderpublic static UriBuilder threadSafe(UriBuilder parent)
Creates a thread-safe UriBuilder from the provided parent builder. An empty UriBuilder may be created using the root() method as the
parent value, otherwise a new UriBuilder may be created from an existing builder:
def parent = UriBuilder.threadSafe(UriBuilder.root()).setFull('http://localhost:10101/foo')
def child = UriBuilder.threadSafe(parent)
child.setPath('/bar').toURI() == new URI('http://localhost:10101/bar')
The UriBuilder implementation generated with this method is thread-safe.
parent - the UriBuilder parentUriBuilderpublic static UriBuilder root()