Package io.netty.handler.codec.http
Class QueryStringEncoder
- java.lang.Object
-
- io.netty.handler.codec.http.QueryStringEncoder
-
public class QueryStringEncoder extends java.lang.ObjectCreates a URL-encoded URI from a path string and key-value parameter pairs. This encoder is for one time use only. Create a new instance for each URI.QueryStringEncoderencoder = newQueryStringEncoder("/hello"); encoder.addParam("recipient", "world"); assert encoder.toString().equals("/hello?recipient=world");- See Also:
QueryStringDecoder
-
-
Constructor Summary
Constructors Constructor Description QueryStringEncoder(java.lang.String uri)Creates a new encoder that encodes a URI that starts with the specified path string.QueryStringEncoder(java.lang.String uri, java.nio.charset.Charset charset)Creates a new encoder that encodes a URI that starts with the specified path string in the specified charset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddParam(java.lang.String name, java.lang.String value)Adds a parameter with the specified name and value to this encoder.java.lang.StringtoString()Returns the URL-encoded URI which was created from the path string specified in the constructor and the parameters added byaddParam(String, String)method.java.net.URItoUri()Returns the URL-encoded URI object which was created from the path string specified in the constructor and the parameters added byaddParam(String, String)method.
-
-
-
Constructor Detail
-
QueryStringEncoder
public QueryStringEncoder(java.lang.String uri)
Creates a new encoder that encodes a URI that starts with the specified path string. The encoder will encode the URI in UTF-8.
-
QueryStringEncoder
public QueryStringEncoder(java.lang.String uri, java.nio.charset.Charset charset)Creates a new encoder that encodes a URI that starts with the specified path string in the specified charset.
-
-
Method Detail
-
addParam
public void addParam(java.lang.String name, java.lang.String value)Adds a parameter with the specified name and value to this encoder.
-
toUri
public java.net.URI toUri() throws java.net.URISyntaxExceptionReturns the URL-encoded URI object which was created from the path string specified in the constructor and the parameters added byaddParam(String, String)method.- Throws:
java.net.URISyntaxException
-
toString
public java.lang.String toString()
Returns the URL-encoded URI which was created from the path string specified in the constructor and the parameters added byaddParam(String, String)method.- Overrides:
toStringin classjava.lang.Object
-
-