BIDUtil
public class BIDTenant extends Object
↳ package com.onekosmos.blockid.sdk.utils
Helper class which provides bunch of related methods to be reused.
Method Summary
type | parameter | summary |
---|---|---|
static String | capitalize(String s) | Converts the first character of given string to upper case |
static List<JSONObject> | convertArrayToList(JSONArray jArray) | Converts an array object into a List |
static LinkedHashMap<String, Object> | convertObjectToMap(Object object) | Converts any object into LinkedHashMap |
static String | createImageMD(Bitmap bitmap) | Returns MD5 representation of an image bitmap |
static <T> String | createObjectMD5(T dataObject) | Returns MD5 representation of any data object |
static String | getBase64FromBytes(byte[] byteArray) | Returns bas64 string of given byte[] |
static Date | getCurrentDate() | Returns the current date |
static String | getDeviceName() | Returns the name of device |
static Date | getFormattedDate(String inputDate) | Returns Date object from string representation of given date |
static String | getSha256Hash(String password) | Returns SHA256 Hash value of given string data |
static String | getSha512Hash(String password) | Returns SHA512 Hash value of given string data |
static long | getTimestampDifference(long timestamp1, long timestamp2) | Returns time difference in hours |
static <T> T | JSONStringToObject(String json, Class<T> classOfT) | Converts JSONString representation into an object |
static String | md5HashV0(String s) | Returns MD5 Hash value of given string data |
static String | md5HashV1(String s) | Returns MD5 Hash value of given string data |
static <T> String | objectToJSONString(T classOfT, Boolean disableHtmlEscaping) | Returns JSONString representation of an object |
static boolean | validateDate(String str) | Returns if the given string representation of date object is valid |
static boolean | validateMapKeys(LinkedHashMap<String, Object> map, String key) | Returns if hash map object contains the given key |
Method Detail
capitalize
public static String capitalize(String s)
- Converts the first character of given string to upper case. Returns the same input string if the first letter is already in upper case.
Parameter | |
---|---|
s | String: Input string. |
convertArrayToList
public static List<JSONObject>
convertArrayToList(JSONArray jArray)
- Converts an array object into a List.
Parameter | |
---|---|
jArray | JSONArray: JSON array to be converted into List. |
convertObjectToMap
public static LinkedHashMap<String, Object> convertObjectToMap(Object object)
- Converts any object into LinkedHashMap.
Parameter | |
---|---|
object | Object: An object to be converted into LinkedHashMap. |
createImageMD
public static String createImageMD(Bitmap bitmap)
- Returns MD5 representation of an image bitmap.
Parameter | |
---|---|
bitmap | Bitmap: An image bitmap. |
createObjectMD5
public static <T>
String createObjectMD5(T dataObject)
- Returns MD5 representation of any data object.
Parameter | |
---|---|
dataObject | T: Any data object for which MD5 representation is required. |
getBase64FromBytes
public static String getBase64FromBytes(byte[] byteArray)
- Returns bas64 string of given byte[]
Parameter | |
---|---|
byteArray | byte[]: Image in byte[] format |
getCurrentDate
public static Date getCurrentDate()
- Returns the current date.
getDeviceName
public static String getDeviceName()
- Returns the name of device.
getFormattedDate
public static Date getFormattedDate(String inputDate)
- Returns Date object from string representation of given date.
Parameter | |
---|---|
inputDate | String: String representation of given date. |
getSha256Hash
public static String getSha256Hash(String password)
- Returns SHA256 Hash value of given string data.
Parameter | |
---|---|
password | String: Input data for which SHA256 Hash is required. |
getSha512Hash
public static String getSha512Hash(String data)
- Returns SHA512 Hash value of given string data.
Parameter | |
---|---|
data | String: Input data for which SHA256 Hash is required. |
--
getTimestampDifference
public static long getTimestampDifference(long timestamp1, long timestamp2)
- Returns time difference in hours
Parameters | |
---|---|
timestamp1 | long: start timestamp |
timestamp2 | long: end timestamp |
JSONStringToObject
public static <T>
T JSONStringToObject(String json, Class<T>
classOfT)
- Converts JSONString representation into an object.
Parameter | |
---|---|
json | String: JSONString to be converted into an object. |
classOfT | T: An object to represent the converted JSONString. |
md5HashV0
public static String md5HashV0(String s)
- Returns MD5 Hash value of given string data.
Parameter | |
---|---|
s | String: String data for which MD5 Hash is required. |
md5HashV1
public static String md5HashV1(String s)
- Returns MD5 Hash value of given string data.
Parameter | |
---|---|
s | String: String data for which MD5 Hash is required. |
objectToJSONString
public static <T>
String objectToJSONString(T classOfT, Boolean disableHtmlEscaping)
- Returns JSONString representation of an object.
Parameter | |
---|---|
classOfT | T: An object being converted into JSONString. |
disableHtmlEscaping | Boolean: Flag to indicate if escaping is required. |
validateDate
public static boolean validateDate(String str)
- Returns if the given string representation of date object is valid.
Parameter | |
---|---|
str | String: String representation of date. |
validateMapKeys
public static boolean validateMapKeys(LinkedHashMap<String, Object> map, String key)
- Returns if hash map object contains the given key.
Parameter | |
---|---|
map | LinkedHashMap<String, Object>: A hash map object. |
key | String: A key to be checked in hash map object. |