public class Common extends Object
| 构造器和说明 |
|---|
Common() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Map<String,Object> |
assertAsMap(Object object)
Assert a value, if it is a map, return it, otherwise throws
|
static Number |
defaultNumber(Number number,
Number defaultNumber)
If not set the real, use default value
|
static String |
defaultString(String str,
String defaultStr)
If not set the real, use default value
|
static boolean |
empty(String str)
Check the string is empty?
|
static boolean |
equalNumber(Number num,
Number val)
Check one number equals another one?
|
static boolean |
equalString(String str,
String val)
Check one string equals another one?
|
static String |
getDateUTCString()
Get an UTC format string by current date, e.g.
|
static String |
getNonce()
Generate a nonce string
|
static String |
getUserAgent(String val) |
static boolean |
isUnset(Object object)
Check one value is unset
|
static Object |
parseJSON(String json)
Parse it by JSON format
|
static byte[] |
readAsBytes(InputStream stream)
Read data from a readable stream, and compose it to a bytes
|
static Object |
readAsJSON(InputStream stream)
Read data from a readable stream, and parse it by JSON format
|
static String |
readAsString(InputStream stream)
Read data from a readable stream, and compose it to a string
|
static Map<String,String> |
stringifyMapValue(Map<String,?> map)
Stringify the value of map
|
static byte[] |
toBytes(String str)
Convert a string(utf8) to bytes
|
static String |
toFormString(Map<String,?> map)
Format a map to form string, like a=a%20b%20c
|
static String |
toJSONString(Object object)
If not set the real, use default value
|
static String |
toString(byte[] bytes)
Convert a bytes to string(utf8)
|
public static byte[] toBytes(String str) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static String toString(byte[] bytes) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static Map<String,Object> assertAsMap(Object object)
public static byte[] readAsBytes(InputStream stream) throws IOException
stream - the readable streamIOExceptionpublic static String readAsString(InputStream stream) throws IOException
stream - the readable streamIOExceptionpublic static Object readAsJSON(InputStream stream) throws IOException
stream - the readable streamIOExceptionpublic static String getNonce()
public static String getDateUTCString()
public static String defaultString(String str, String defaultStr)
public static Number defaultNumber(Number number, Number defaultNumber)
public static String toFormString(Map<String,?> map) throws UnsupportedEncodingException
UnsupportedEncodingExceptionpublic static String toJSONString(Object object)
public static boolean empty(String str)
public static boolean equalString(String str, String val)
public static boolean equalNumber(Number num, Number val)
public static boolean isUnset(Object object)
public static Map<String,String> stringifyMapValue(Map<String,?> map)
Copyright © 2020. All rights reserved.