|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.groupdocs.annotation.utils.Utils
public class Utils
Utils methods
Nested Class Summary | |
---|---|
static interface |
Utils.IDistinct<T>
Interface for check values |
static interface |
Utils.IExcept<T>
Interface for check values |
static interface |
Utils.IFirst<T>
Interface for select values |
static interface |
Utils.ILast<T>
Interface for select values |
static interface |
Utils.ISelect<T,R>
Interface for check values |
static interface |
Utils.ISortListBy<T,R>
Interface for sort values |
static interface |
Utils.IWhere<T>
Interface for check values |
Field Summary | |
---|---|
static String |
tempPath
|
Constructor Summary | |
---|---|
Utils()
|
Method Summary | ||
---|---|---|
static
|
assetEntity(T t)
Asset entity for null |
|
static
|
assetEntity(T t,
String errorMessage)
Asset entity for null |
|
static void |
closeStreams(Object... streams)
For each parameters if it extends @{InputStream} or @{OutputStream} will call .close() method |
|
static int |
colorToInt(com.aspose.pdf.Color color)
|
|
static int |
colorToInt(Color color)
|
|
static int |
colorToInt(float red,
float green,
float blue)
|
|
static
|
distinct(List<T> values,
Utils.IDistinct<T> distinct)
Return unique values if distinct will check elements by equals |
|
static String |
dt2s(Date date)
Date to String format for database |
|
static
|
except(List<T> sources,
List<T> excepts,
Utils.IExcept<T> except)
Return list with values which exists in sources and don't exists in except list |
|
static
|
first(List<T> values,
Utils.IFirst<T> first)
Return first value for which check method return true, or null |
|
static
|
fromJson(String jsonString,
Class<T> clazz)
Convert json to object |
|
static String |
getBody(javax.servlet.http.HttpServletRequest request)
Get body from HTTP servlet request |
|
static
|
getObjectData(String request,
Class<T> clazz)
Get object from request |
|
static Color |
intToColor(int value)
|
|
static
|
last(List<T> values,
Utils.ILast<T> last)
Return first value for which check method return true, or null |
|
static String |
makeAppPath(javax.servlet.http.HttpServletRequest request)
Make base application path using parameters from request object |
|
static
|
ofType(List<T> values,
Class<R> clazz)
Return list of R type from values |
|
static
|
or(T source1,
T source2)
Return source2 if source1 is null else source1 |
|
static String |
processTemplate(String templateName,
Map<String,Object> replaceValues)
Process template (replace all ${some_word|default_value} to value in params map) |
|
static Double |
round(Double value,
int count)
|
|
static Date |
s2dt(String strDate)
Parse String to Date format (default date format "yyyy-MM-dd HH:mm:ss" ) |
|
static Date |
s2dt(String strDate,
String dateFormat)
Parse String to Date format |
|
static
|
select(List<T> values,
Utils.ISelect<T,R> select)
Return list with values which will be provided by select object for each element from values |
|
static void |
setTempPath(String tempPath)
|
|
static
|
sortBy(List<T> values,
boolean descending,
Utils.ISortListBy<T,R> sortBy)
|
|
static
|
sortBy(Map<K,V> values,
boolean descending,
Comparator<Map.Entry<K,V>> comparator)
Return new sorted map by provided from sortBy object |
|
static String |
toJson(com.google.gson.Gson gson,
Object obj)
Convert object to json |
|
static String |
toJson(Object obj)
Convert object to json |
|
static long |
utcToLocal(long utcTime)
Convert UTC time to local time using TimeZone.getDefault() |
|
static
|
where(List<T> values,
Utils.IWhere where)
Return list with values, for which 'where' object return true |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String tempPath
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static void setTempPath(String tempPath)
public static String processTemplate(String templateName, Map<String,Object> replaceValues) throws IOException
templateName
- template namereplaceValues
- map with params
IOException
public static <T> T getObjectData(String request, Class<T> clazz) throws IOException
T
- object typerequest
- requestclazz
- class type
IOException
public static String getBody(javax.servlet.http.HttpServletRequest request) throws IOException
request
- HTTP servlet request
IOException
public static String toJson(Object obj)
obj
- object to convert
public static String toJson(com.google.gson.Gson gson, Object obj)
gson
- Gson oblect to serializeobj
- object to convert
public static <T> T fromJson(String jsonString, Class<T> clazz)
T
- object typejsonString
- jsonclazz
- object type class
public static <T extends com.groupdocs.annotation.db.tables.GroupDocsAnnotationTable> T assetEntity(T t) throws NullPointerException
T
- entity typet
- entity
NullPointerException
public static <T extends com.groupdocs.annotation.db.tables.GroupDocsAnnotationTable> T assetEntity(T t, String errorMessage) throws NullPointerException
T
- entity typet
- entityerrorMessage
- error message
NullPointerException
public static String dt2s(Date date)
date
- input date
public static Date s2dt(String strDate)
strDate
- date as String
public static Date s2dt(String strDate, String dateFormat)
strDate
- date as StringdateFormat
- date format to parse (sample "yyyy-MM-dd HH:mm:ss" )
public static void closeStreams(Object... streams)
streams
- streams to closepublic static long utcToLocal(long utcTime)
utcTime
- UTC time
public static String makeAppPath(javax.servlet.http.HttpServletRequest request)
request
- http servlet request
public static int colorToInt(com.aspose.pdf.Color color)
public static int colorToInt(Color color)
public static int colorToInt(float red, float green, float blue)
public static Double round(Double value, int count)
public static <T> T or(T source1, T source2)
T
- parameters typesource1
- object1 for check to nullsource2
- object to return if source1 is null
public static <T> List<T> where(List<T> values, Utils.IWhere where)
T
- type of values to checkvalues
- values to filterwhere
- object to check each values
public static <T> List<T> except(List<T> sources, List<T> excepts, Utils.IExcept<T> except)
T
- sources
- list to filterexcepts
- elements which should be filteredexcept
- object to
public static <T,R> List<R> select(List<T> values, Utils.ISelect<T,R> select)
T
- source typeR
- result typevalues
- list to checkselect
- object to return value
public static <T> List<T> distinct(List<T> values, Utils.IDistinct<T> distinct)
T
- list typevalues
- list to checkdistinct
- check object
public static <K,V,R> Map<K,V> sortBy(Map<K,V> values, boolean descending, Comparator<Map.Entry<K,V>> comparator)
values
- map to sortdescending
- comparator
- object for compare values
public static <T,R> List<T> sortBy(List<T> values, boolean descending, Utils.ISortListBy<T,R> sortBy)
T
- R
- values
- descending
- sortBy
-
public static <T> T first(List<T> values, Utils.IFirst<T> first)
T
- type of objects in listvalues
- values to checkfirst
- object for checkung
public static <T> T last(List<T> values, Utils.ILast<T> last)
T
- type of objects in listvalues
- values to checklast
- object for checkung
public static <T,R> List<R> ofType(List<T> values, Class<R> clazz)
T
- input typeR
- output typevalues
- to filterclazz
- filtered class
public static Color intToColor(int value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |