public class Request extends Object
Constructor and Description |
---|
Request(String cmd)
Constructs a new Request object with the given command verb.
|
Request(String cmd,
String... parameters)
Constructs a new Request object with the given command verb
and the given set of parameter key/value pairs.
|
Modifier and Type | Method and Description |
---|---|
void |
addParam(String key)
Adds a new query parameter with the given name and an empty value.
|
void |
addParam(String key,
String value)
Adds a new query parameter with the given name and value.
|
void |
addParams(String... params)
Adds new query parameters with the given name/value pairs,
passed as a var-args array in the order K1, V1, K2, V2, etc.
|
void |
addRaw(String key,
String value)
Adds a new query parameter with the given name and value.
|
static String |
decode(String str)
URL-decodes the given string.
|
static String |
encode(String str)
URL-encodes the given string.
|
static Request |
fromUrl(String url)
Converts the given string into a Request object,
parsing and separating any of its query parameters.
|
static Request |
fromUrl(URL url)
Converts the given URL into a Request object,
parsing and separating any of its query parameters.
|
String |
getCommand()
Returns this request's HTTP command verb.
|
String |
getParam(String key)
Returns the value of this request's query parameter with the given name.
|
Map<String,String> |
getParams()
Returns all of this request's query parameters as a map.
|
String |
getRaw(String key)
Returns the value of this request's query parameter with the given name.
|
boolean |
hasParam(String key)
Returns true if this request contains a query parameter with the given name.
|
void |
removeParam(String key)
Removes the query parameter with the given name from this request.
|
String |
toGetRequest()
Converts this request into a URL string that could be used for an
HTTP GET request, such as
"http://server:port/verb?param1=value1¶m2=value2...¶mN=valueN".
|
String |
toString()
Returns a string representation of this request for debugging.
|
public Request(String cmd)
public static Request fromUrl(String url)
public static Request fromUrl(URL url)
public void addParam(String key)
public void addParam(String key, String value)
public void addParams(String... params)
public void addRaw(String key, String value)
public String getCommand()
public String getParam(String key)
public Map<String,String> getParams()
public String getRaw(String key)
public boolean hasParam(String key)
public void removeParam(String key)
public String toGetRequest()