|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.groupdocs.annotation.common.Utils
public final 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 |
| 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 Integer |
colorToInt(com.aspose.pdf.Color color)
Convert color object to int value |
|
static Integer |
colorToInt(Color color)
Convert color object to int value |
|
static Integer |
colorToInt(float red,
float green,
float blue)
Convert color to int value |
|
static String |
discard(String inputString,
int discardCount)
Discard few letters from end of string |
|
static String |
discard(String inputString,
int discardCount,
boolean fromStart)
Discard few letters from string |
|
static String |
discard(String inputString,
String matchRegEx)
Discard letters according to regex from end of string |
|
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
|
fromJson(String jsonString,
Type type)
Convert json to object |
|
static
|
fromXml(String xmlString)
Restore Java object from xml |
|
static
|
fromXml(String xmlString,
Class clazz)
Restore Java object from xml |
|
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 String |
getTempPath()
Getter for property 'tempPath'. |
|
static Color |
intToColor(int value)
|
|
static
|
isEntityNull(T t)
Check is entity is null or entity id is 0 |
|
static boolean |
isNullOrEmpty(String inputString)
Check that string null or empty |
|
static boolean |
isNullOrEmpty(String inputString,
boolean spaceIsEmpty)
Check that string null or empty |
|
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 int |
makeUniqueId()
Create integer id - unique for running application |
|
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 Color |
parseColor(String color)
Parse color |
|
static String |
processTemplate(String templateName,
Map<String,Object> replaceValues)
Process template (replace all ${some_word|default_value} to value in params map) |
|
static String |
readFile(InputStream inputStream)
Read all file content to string |
|
static Double |
round(Double value,
int count)
Round double value |
|
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)
Setter for property 'tempPath'. |
|
static
|
sortBy(List<T> values,
boolean descending,
Utils.ISortListBy<T,R> sortBy)
Sort values by criteria |
|
static
|
sortBy(Map<K,V> values,
boolean descending,
Comparator<Map.Entry<K,V>> comparator)
Return new sorted map by provided from sortBy object |
|
static void |
throwIfNull(Object 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 String |
toXml(Object obj)
Convert object to XML |
|
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 |
| Method Detail |
|---|
public static String getTempPath()
public static void setTempPath(String tempPath)
tempPath - Value to set for property '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 AnnotationException
T - object typerequest - requestclazz - class type
AnnotationException - annotation exception
public static String getBody(javax.servlet.http.HttpServletRequest request)
throws AnnotationException
request - HTTP servlet request
AnnotationException - annotation exceptionpublic 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> T fromJson(String jsonString,
Type type)
T - object typejsonString - jsontype - object type class
public static String toXml(Object obj)
obj - object to convert
public static <T> T fromXml(String xmlString,
Class clazz)
T - type of java objectxmlString - xml stringclazz - class of java object
public static <T> T fromXml(String xmlString)
T - type of java objectxmlString - xml string
public static <T extends ITable> boolean isEntityNull(T t)
T - entity classt - entity to check
public static <T extends ITable> T assetEntity(T t)
throws AnnotationException
T - entity typet - entity
AnnotationException - annotation exception
public static <T extends ITable> T assetEntity(T t,
String errorMessage)
throws AnnotationException
T - entity typet - entityerrorMessage - error message
AnnotationException - annotation exceptionpublic 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 Integer colorToInt(com.aspose.pdf.Color color)
color - com.aspose.pdf.Color object
public static Integer colorToInt(Color color)
color - java.awt.Color object
public static Integer colorToInt(float red,
float green,
float blue)
red - red part of colorgreen - green part of colorblue - blue part of color
public static Color intToColor(int value)
public static Double round(Double value,
int count)
value - value to roundcount - count of numbers after point
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 int makeUniqueId()
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 - result typesources - 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 - descending sortcomparator - object for compare values
public static <T,R> List<T> sortBy(List<T> values,
boolean descending,
Utils.ISortListBy<T,R> sortBy)
T - key type for sortR - value type for sortvalues - values to sortdescending - descending sortsortBy - criteria for sorting
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 boolean isNullOrEmpty(String inputString)
inputString - input string
public static boolean isNullOrEmpty(String inputString,
boolean spaceIsEmpty)
inputString - input stringspaceIsEmpty - space equals to empty
public static String readFile(InputStream inputStream)
throws IOException
inputStream - file input stream
IOExceptionpublic static Color parseColor(String color)
color - string color
public static void throwIfNull(Object object)
throws AnnotationException
AnnotationException
public static String discard(String inputString,
int discardCount)
inputString - input stringdiscardCount - count of letters to discard
public static String discard(String inputString,
int discardCount,
boolean fromStart)
inputString - input stringdiscardCount - count of letters to discardfromStart - discard from start of string if true
public static String discard(String inputString,
String matchRegEx)
inputString - input stringmatchRegEx - regex for fing letters to discard
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||