|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.net.http.URIBuilder
public class URIBuilder
This class implements a mutable URI. All set
, add
and remove
methods affect this class' internal URI
representation. All mutator methods support chaining, e.g.
new URIBuilder("http://www.google.com/") .setScheme( "https" ) .setPort( 443 ) .setPath( "some/path" ) .toString();A slightly more 'Groovy' version would be:
new URIBuilder('http://www.google.com/').with { scheme = 'https' port = 443 path = 'some/path' query = [p1:1, p2:'two'] }.toString()
Field Summary | |
---|---|
protected URI |
base
|
Constructor Summary | |
---|---|
URIBuilder(String url)
|
|
URIBuilder(URI url)
|
|
URIBuilder(URL url)
|
Method Summary | |
---|---|
URIBuilder |
addQueryParam(String param,
Object value)
This will append a param to the existing query string. |
URIBuilder |
addQueryParams(Map<String,?> params)
|
static URI |
convertToURI(Object uri)
Attempts to convert a URL or String to a URI. |
Map<String,String> |
getQuery()
Get the query string as a map |
boolean |
hasQueryParam(String name)
|
URIBuilder |
removeQueryParam(String param)
|
URIBuilder |
setFragment(String fragment)
The document fragment, without a preceeding '#' |
URIBuilder |
setHost(String host)
|
URIBuilder |
setPath(String path)
|
URIBuilder |
setPort(int port)
|
URIBuilder |
setQuery(Map<String,?> params)
Set the query portion of the URI |
URIBuilder |
setScheme(String scheme)
AKA protocol |
String |
toString()
|
URI |
toURI()
|
URL |
toURL()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected URI base
Constructor Detail |
---|
public URIBuilder(String url) throws URISyntaxException
URISyntaxException
public URIBuilder(URL url) throws URISyntaxException
URISyntaxException
public URIBuilder(URI url)
Method Detail |
---|
public static URI convertToURI(Object uri) throws URISyntaxException
uri
- a URI
, URL
or any object that produces a
parse-able URI string from its toString()
result.
URISyntaxException
public URIBuilder setScheme(String scheme) throws URISyntaxException
URISyntaxException
public URIBuilder setPort(int port) throws URISyntaxException
URISyntaxException
public URIBuilder setHost(String host) throws URISyntaxException
URISyntaxException
public URIBuilder setPath(String path) throws URISyntaxException
URISyntaxException
public URIBuilder setQuery(Map<String,?> params) throws URISyntaxException
params
- a Map of parameters that will be transformed into the query string
URISyntaxException
public Map<String,String> getQuery()
public boolean hasQueryParam(String name)
public URIBuilder removeQueryParam(String param) throws URISyntaxException
URISyntaxException
public URIBuilder addQueryParam(String param, Object value) throws URISyntaxException
param
- value
-
URISyntaxException
public URIBuilder addQueryParams(Map<String,?> params) throws URISyntaxException
URISyntaxException
public URIBuilder setFragment(String fragment) throws URISyntaxException
fragment
-
URISyntaxException
public String toString()
toString
in class Object
public URL toURL() throws MalformedURLException
MalformedURLException
public URI toURI()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |