public class ParserUtility extends Object
Constructor and Description |
---|
ParserUtility() |
Modifier and Type | Method and Description |
---|---|
static String |
dateTimeUtcToString(Date date)
Helper to convert the provided Date UTC into String.
|
static Date |
getDateTimeUtc(String dataTime)
Helper to convert the provided string in a UTC Date.
|
static Map<String,Object> |
getJsonObjectValue(com.google.gson.JsonObject jsonObject) |
static String |
getUTCDateStringFromDate(Date date)
Convert from a date object back into a string representation
Expected format of returned string:
"2016-01-21T11:05:21"
|
static com.google.gson.JsonElement |
mapToJsonElement(Map<String,Object> map)
Helper to convert a provided map in to a JsonElement, including sub-maps.
|
static Object |
resolveJsonElement(com.google.gson.JsonElement jsonElement) |
static Date |
stringToDateTimeOffset(String dateTime)
Helper to convert the provided string in a offset Date.
|
static void |
validateBlobName(String blobName)
Helper to validate if the provided blob name is not null, empty, and valid.
|
static void |
validateMap(Map<String,Object> map)
Helper to validate if the provided map in terms of maximum
levels and optionally if the keys ar not metadata.
|
static void |
validateObject(Object val)
Helper to validate if the provided object is not null.
|
static void |
validateQuery(String query)
Validates if query contains select and from keywords and also if it is a valid utf-8 string
|
static void |
validateStringUTF8(String str)
Helper to validate if the provided string is not null, empty, and all characters are UTF-8.
|
public static void validateStringUTF8(String str) throws IllegalArgumentException
str
- is the string to be validated.IllegalArgumentException
- if the string do not fit the criteria.public static void validateQuery(String query) throws IllegalArgumentException
query
- query to be validatedIllegalArgumentException
- if query does not contain "select" or "from" or is not a valid utf-8 stringpublic static void validateBlobName(String blobName) throws IllegalArgumentException
blobName
- is the blob name to be validated.IllegalArgumentException
- if the blob name do not fit the criteria.public static void validateObject(Object val) throws IllegalArgumentException
val
- is the object to be validated.IllegalArgumentException
- if the object do not fit the criteria.public static void validateMap(Map<String,Object> map) throws IllegalArgumentException
map
- the Map
to be validate. It can be null
, and it will succeed in this case.IllegalArgumentException
- If the Map contains more than maxLevel levels or do not allow metadata
but contains metadata key.public static Date getDateTimeUtc(String dataTime) throws IllegalArgumentException
dataTime
- is the string with the date and timeIllegalArgumentException
- if the date and time in the string is not in the correct format.public static Date stringToDateTimeOffset(String dateTime) throws IllegalArgumentException
dateTime
- is the string with the date and timeIllegalArgumentException
- if the date and time in the string is not in the correct format.public static String dateTimeUtcToString(Date date) throws IllegalArgumentException
date
- is the Date
with the date and timeString
with the date and time using the UTC format.IllegalArgumentException
- if the provided date is null
.public static String getUTCDateStringFromDate(Date date) throws IllegalArgumentException
date
- the date to convert into a stringIllegalArgumentException
- if the provided date is nullpublic static com.google.gson.JsonElement mapToJsonElement(Map<String,Object> map) throws IllegalArgumentException
map
- is the map to serializeIllegalArgumentException
- if the provided map is null.public static Object resolveJsonElement(com.google.gson.JsonElement jsonElement)
Copyright © 2022. All rights reserved.