public static class QueryString.Encoder extends Object
This encoder is for one time use only. Create a new instance for each URI.
QueryStringCodec.Encoder encoder = new QueryStringCodec.Encoder("/hello"); encoder.addParam("recipient", "world"); assert encoder.toString().equals("/hello?recipient=world");
QueryString.Decoder
Constructor and Description |
---|
Encoder(String uri)
Creates a new encoder that encodes a URI that starts with the specified path string.
|
Encoder(String uri, Charset charset)
Creates a new encoder that encodes a URI that starts with the specified path string in the specified charset.
|
Modifier and Type | Method and Description |
---|---|
void |
addParam(String name, String value)
Adds a parameter with the specified name and value to this encoder.
|
String |
toString()
Returns the URL-encoded URI which was created from the path string specified in the constructor and the parameters added by
addParam(String, String) getMethod.
|
URI |
toUri()
Returns the URL-encoded URI object which was created from the path string specified in the constructor and the parameters added by
addParam(String, String) getMethod.
|
public Encoder(String uri)
The encoder will encode the URI in UTF-8.
uri
- URI
public void addParam(String name, String value)
name
- Name
value
- Value
public URI toUri() throws URISyntaxException
addParam(String, String)
getMethod.
URISyntaxException
- when the URI is invalid
public String toString()
addParam(String, String)
getMethod.