public class ParserUtility
extends java.lang.Object
Constructor and Description |
---|
ParserUtility() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
dateTimeUtcToString(java.util.Date date)
Helper to convert the provided Date UTC into String.
|
static java.util.Date |
getDateTimeUtc(java.lang.String dataTime)
Helper to convert the provided string in a UTC Date.
|
static java.util.Map<java.lang.String,java.lang.Object> |
getJsonObjectValue(com.google.gson.JsonObject jsonObject) |
static java.lang.String |
getUTCDateStringFromDate(java.util.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(java.util.Map<java.lang.String,java.lang.Object> map)
Helper to convert a provided map in to a JsonElement, including sub-maps.
|
static java.lang.Object |
resolveJsonElement(com.google.gson.JsonElement jsonElement) |
static java.util.Date |
stringToDateTimeOffset(java.lang.String dateTime)
Helper to convert the provided string in a offset Date.
|
static void |
validateBlobName(java.lang.String blobName)
Helper to validate if the provided blob name is not null, empty, and valid.
|
static void |
validateMap(java.util.Map<java.lang.String,java.lang.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(java.lang.Object val)
Helper to validate if the provided object is not null.
|
static void |
validateQuery(java.lang.String query)
Validates if query contains select and from keywords and also if it is a valid utf-8 string
|
static void |
validateStringUTF8(java.lang.String str)
Helper to validate if the provided string is not null, empty, and all characters are UTF-8.
|
public static void validateStringUTF8(java.lang.String str) throws java.lang.IllegalArgumentException
str
- is the string to be validated.java.lang.IllegalArgumentException
- if the string do not fit the criteria.public static void validateQuery(java.lang.String query) throws java.lang.IllegalArgumentException
query
- query to be validatedjava.lang.IllegalArgumentException
- if query does not contain "select" or "from" or is not a valid utf-8 stringpublic static void validateBlobName(java.lang.String blobName) throws java.lang.IllegalArgumentException
blobName
- is the blob name to be validated.java.lang.IllegalArgumentException
- if the blob name do not fit the criteria.public static void validateObject(java.lang.Object val) throws java.lang.IllegalArgumentException
val
- is the object to be validated.java.lang.IllegalArgumentException
- if the object do not fit the criteria.public static void validateMap(java.util.Map<java.lang.String,java.lang.Object> map) throws java.lang.IllegalArgumentException
map
- the Map
to be validate. It can be null
, and it will succeed in this case.java.lang.IllegalArgumentException
- If the Map contains more than maxLevel levels or do not allow metadata
but contains metadata key.public static java.util.Date getDateTimeUtc(java.lang.String dataTime) throws java.lang.IllegalArgumentException
dataTime
- is the string with the date and timejava.lang.IllegalArgumentException
- if the date and time in the string is not in the correct format.public static java.util.Date stringToDateTimeOffset(java.lang.String dateTime) throws java.lang.IllegalArgumentException
dateTime
- is the string with the date and timejava.lang.IllegalArgumentException
- if the date and time in the string is not in the correct format.public static java.lang.String dateTimeUtcToString(java.util.Date date) throws java.lang.IllegalArgumentException
date
- is the Date
with the date and timeString
with the date and time using the UTC format.java.lang.IllegalArgumentException
- if the provided date is null
.public static java.lang.String getUTCDateStringFromDate(java.util.Date date) throws java.lang.IllegalArgumentException
date
- the date to convert into a stringjava.lang.IllegalArgumentException
- if the provided date is nullpublic static com.google.gson.JsonElement mapToJsonElement(java.util.Map<java.lang.String,java.lang.Object> map) throws java.lang.IllegalArgumentException
map
- is the map to serializejava.lang.IllegalArgumentException
- if the provided map is null.public static java.lang.Object resolveJsonElement(com.google.gson.JsonElement jsonElement)
public static java.util.Map<java.lang.String,java.lang.Object> getJsonObjectValue(com.google.gson.JsonObject jsonObject)
Copyright © 2023. All rights reserved.