public final class Functions extends Object
Functions class contains static functions that are commonly needed by most Insight Providers.| Modifier and Type | Method and Description |
|---|---|
static <T> T |
convertFromJSON(String json,
Class<T> type)
Converts a JSON
String into a Java object. |
static String |
convertToJSON(Object obj)
Converts an
Object to a string representation of itself in JSON format. |
static String |
epochToUTC(long millis)
Converts a timestamp in Unix time to a timestamp
String. |
static Calendar |
epochToUTCTimestamp(long millis)
Converts a timestamp in Unix time to a
Calendar instance. |
static String |
fromStream(InputStream in) |
static javax.ws.rs.core.Response |
getJsonResponse(javax.ws.rs.core.Response.Status status,
String json)
Returns an HTTP
Response object with the passed status argument as its status code and json as its message. |
static javax.ws.rs.core.Response |
getResponse(javax.ws.rs.core.Response.Status status)
Returns an HTTP
Response object with the passed argument as its status code. |
static int |
isSqlNameInjectionSafe(javax.persistence.EntityManager em,
String value)
Uses HANA functionality to determine whether a SQL command is injection safe.
|
public static String epochToUTC(long millis)
String. The resulting String is in
format yyyy-MM-dd HH:mm:ss.SSSmillis - the Unix timestamp in milliseconds since 00:00:00 UTC on 1 January 1970String in format yyyy-MM-dd HH:mm:ss.SSSpublic static Calendar epochToUTCTimestamp(long millis)
Calendar instance. The resulting Calendar instance
is set to the time represented by the Unix timestamp in the Gregorian Calendar.millis - the Unix timestamp in milliseconds since 00:00:00 UTC on 1 January 1970String in format yyyy-MM-dd HH:mm:ss.SSSpublic static String convertToJSON(Object obj)
Object to a string representation of itself in JSON format.obj - the object to be convertedString representation of the Objectpublic static <T> T convertFromJSON(String json, Class<T> type)
String into a Java object.T - the resulting Java object type that should be created from the JSON Stringjson - the JSON String to be convertedtype - the class of the resulting Java object type that should be created from the JSON Stringtypepublic static String fromStream(InputStream in) throws IOException
IOExceptionpublic static javax.ws.rs.core.Response getResponse(javax.ws.rs.core.Response.Status status)
Response object with the passed argument as its status code. The resulting object
has PDMS compliant no-cache, no-store cache header settings.status - the HTTP statusResponse object with the passed argument as its status codepublic static javax.ws.rs.core.Response getJsonResponse(javax.ws.rs.core.Response.Status status,
String json)
Response object with the passed status argument as its status code and json as its message.
The resulting object has PDMS compliant no-cache, no-store cache header settings.status - the HTTP statusjson - the JSON to be returned with the responseResponse object with the passed argument as its status codepublic static int isSqlNameInjectionSafe(javax.persistence.EntityManager em,
String value)
em - the EntityManager that should be used to manage the transactionvalue - the SQL expression that should be checked for SQL injectionCopyright © 2016 SAP. All Rights Reserved.