Package com.google.gwt.http.client
Class UrlBuilder
java.lang.Object
com.google.gwt.http.client.UrlBuilder
Utility class to build a URL from components.
TODO(jlabanca): Add a constructor that parses an existing URL
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The port to use when no port should be specified. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionBuild the URL and return it as an encoded string.removeParameter
(String name) Remove a query parameter from the map.Set the hash portion of the location (ex.Set the host portion of the location (ex.setParameter
(String key, String... values) Set a query parameter to a list of values.Set the path portion of the location (ex.setPort
(int port) Set the port to connect to.setProtocol
(String protocol) Set the protocol portion of the location (ex.
-
Field Details
-
PORT_UNSPECIFIED
public static final int PORT_UNSPECIFIEDThe port to use when no port should be specified.- See Also:
-
-
Constructor Details
-
UrlBuilder
public UrlBuilder()
-
-
Method Details
-
buildString
Build the URL and return it as an encoded string.- Returns:
- the encoded URL string
-
removeParameter
Remove a query parameter from the map.- Parameters:
name
- the parameter name
-
setHash
Set the hash portion of the location (ex. myAnchor or #myAnchor).- Parameters:
hash
- the hash
-
setHost
Set the host portion of the location (ex. google.com). You can also specify the port in this method (ex. localhost:8888).- Parameters:
host
- the host
-
setParameter
Set a query parameter to a list of values. Each value in the list will be added as its own key/value pair.
Example Output
?mykey=value0invalid input: '&mykey'=value1invalid input: '&mykey'=value2
- Parameters:
key
- the keyvalues
- the list of values
-
setPath
Set the path portion of the location (ex. path/to/file.html).- Parameters:
path
- the path
-
setPort
Set the port to connect to.- Parameters:
port
- the port, orPORT_UNSPECIFIED
-
setProtocol
Set the protocol portion of the location (ex. http).- Parameters:
protocol
- the protocol
-