Constructor and Description |
---|
RestUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
getHttpResponseText(int rc)
Returns readable text for an HTTP response code.
|
static String |
getPathInfoUndecoded(javax.servlet.http.HttpServletRequest req)
Identical to
HttpServletRequest.getPathInfo() but doesn't decode encoded characters. |
static Object[] |
merge(Object[] fromParent,
Object[] fromChild)
Merges the specified parent and child arrays.
|
static Object |
parseAnything(String s)
Parses a string that can consist of a simple string or JSON object/array.
|
static String[] |
parseHeader(String s)
Parses HTTP header.
|
static String[] |
parseKeyValuePair(String s)
Parses key/value pairs separated by either : or =
|
static Map<String,String[]> |
parseQuery(Object qs)
Parses a URL query string or form-data body.
|
static Map<String,String[]> |
parseQuery(Object qs,
Map<String,String[]> map)
Same as
parseQuery(Object) but allows you to specify the map to insert values into. |
static StringBuffer |
trimPathInfo(StringBuffer requestURI,
String contextPath,
String servletPath)
Efficiently trims the path info part from a request URI.
|
public RestUtils()
public static String getHttpResponseText(int rc)
rc
- The HTTP response code.public static String getPathInfoUndecoded(javax.servlet.http.HttpServletRequest req)
HttpServletRequest.getPathInfo()
but doesn't decode encoded characters.req
- The HTTP requestpublic static StringBuffer trimPathInfo(StringBuffer requestURI, String contextPath, String servletPath)
The result is the URI of the servlet itself.
requestURI
- The value returned by HttpServletRequest.getRequestURL()
contextPath
- The value returned by HttpServletRequest.getContextPath()
servletPath
- The value returned by HttpServletRequest.getServletPath()
public static String[] parseHeader(String s)
s
- The string to parse.public static String[] parseKeyValuePair(String s)
s
- The string to parse.public static Map<String,String[]> parseQuery(Object qs) throws Exception
qs
- A reader or string containing the query string to parse.Exception
public static Map<String,String[]> parseQuery(Object qs, Map<String,String[]> map) throws Exception
parseQuery(Object)
but allows you to specify the map to insert values into.qs
- A reader containing the query string to parse.map
- The map to pass the values into.Exception
public static Object parseAnything(String s) throws ParseException
s
- The string to parse.ParseException
public static Object[] merge(Object[] fromParent, Object[] fromChild)
The general concept is to allow child values to override parent values.
The rules are:
None
, then an empty array is always returned.
Inherit
, then the contents of the parent array are inserted into the position of the Inherit
entry.
fromParent
- The parent array.fromChild
- The child array.Copyright © 2018 Apache. All rights reserved.