Skip to main content

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

typeparametersummary
static Stringcapitalize(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 StringcreateImageMD(Bitmap bitmap)Returns MD5 representation of an image bitmap
static <T> StringcreateObjectMD5(T dataObject)Returns MD5 representation of any data object
static StringgetBase64FromBytes(byte[] byteArray)Returns bas64 string of given byte[]
static DategetCurrentDate()Returns the current date
static StringgetDeviceName()Returns the name of device
static DategetFormattedDate(String inputDate)Returns Date object from string representation of given date
static StringgetSha256Hash(String password)Returns SHA256 Hash value of given string data
static StringgetSha512Hash(String password)Returns SHA512 Hash value of given string data
static longgetTimestampDifference(long timestamp1, long timestamp2)Returns time difference in hours
static <T> TJSONStringToObject(String json, Class<T> classOfT)Converts JSONString representation into an object
static Stringmd5HashV0(String s)Returns MD5 Hash value of given string data
static Stringmd5HashV1(String s)Returns MD5 Hash value of given string data
static <T> StringobjectToJSONString(T classOfT, Boolean disableHtmlEscaping)Returns JSONString representation of an object
static booleanvalidateDate(String str)Returns if the given string representation of date object is valid
static booleanvalidateMapKeys(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
sString: Input string.

convertArrayToList

public static List<JSONObject> convertArrayToList(JSONArray jArray)

  • Converts an array object into a List.
Parameter
jArrayJSONArray: JSON array to be converted into List.

convertObjectToMap

public static LinkedHashMap<String, Object> convertObjectToMap(Object object)

  • Converts any object into LinkedHashMap.
Parameter
objectObject: An object to be converted into LinkedHashMap.

createImageMD

public static String createImageMD(Bitmap bitmap)

  • Returns MD5 representation of an image bitmap.
Parameter
bitmapBitmap: An image bitmap.

createObjectMD5

public static <T> String createObjectMD5(T dataObject)

  • Returns MD5 representation of any data object.
Parameter
dataObjectT: Any data object for which MD5 representation is required.

getBase64FromBytes

public static String getBase64FromBytes(byte[] byteArray)

  • Returns bas64 string of given byte[]
Parameter
byteArraybyte[]: 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
inputDateString: String representation of given date.

getSha256Hash

public static String getSha256Hash(String password)

  • Returns SHA256 Hash value of given string data.
Parameter
passwordString: Input data for which SHA256 Hash is required.

getSha512Hash

public static String getSha512Hash(String data)

  • Returns SHA512 Hash value of given string data.
Parameter
dataString: Input data for which SHA256 Hash is required.

--

getTimestampDifference

public static long getTimestampDifference(long timestamp1, long timestamp2)

  • Returns time difference in hours
Parameters
timestamp1long: start timestamp
timestamp2long: end timestamp

JSONStringToObject

public static <T> T JSONStringToObject(String json, Class<T> classOfT)

  • Converts JSONString representation into an object.
Parameter
jsonString: JSONString to be converted into an object.
classOfTT: An object to represent the converted JSONString.

md5HashV0

public static String md5HashV0(String s)

  • Returns MD5 Hash value of given string data.
Parameter
sString: String data for which MD5 Hash is required.

md5HashV1

public static String md5HashV1(String s)

  • Returns MD5 Hash value of given string data.
Parameter
sString: 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
classOfTT: An object being converted into JSONString.
disableHtmlEscapingBoolean: 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
strString: 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
mapLinkedHashMap<String, Object>: A hash map object.
keyString: A key to be checked in hash map object.