|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sharengo.wikitty.WikittyUtil
public class WikittyUtil
Util static method for wikitty
| Nested Class Summary | |
|---|---|
static class |
WikittyUtil.SolrDateFormat
|
| Field Summary | |
|---|---|
protected static Locale |
CANONICAL_LOCALE
|
protected static TimeZone |
CANONICAL_TZ
used to format date for solr |
static String |
DATE_FORMAT
|
static String |
DEFAULT_VERSION
|
protected static Pattern |
fieldPattern
Field pattern parser group 1: type (string) group 2: name (string) group 3: lower bound (number) can be null group 4: upper bound (number) can be null, mutualy exclusif with group 5 group 5: upper bound (n or *) can be null group 6: unique can be null group 7: not null can be null group 8: all tag/value (toto=titi tutu=tata;lala tata="truc bidulle") |
static Map<Class,Class> |
interfaceToClass
contains mapping between interface and concret class that must be used |
protected static DateFormat[] |
parserDateFormats
All date format parser used to convert string to date |
static SimpleDateFormat |
solrDateFormat
|
protected static Pattern |
tagValuesPattern
|
protected static String |
tagValuesPatternString
Pattern for tag value: tag="value" or tag=value. value can contains '"' |
| Constructor Summary | |
|---|---|
WikittyUtil()
|
|
| Method Summary | ||
|---|---|---|
static Wikitty |
beanToWikitty(BusinessEntity bean)
|
|
static Wikitty |
beanToWikitty(BusinessEntityBean bean)
|
|
static LinkedHashMap<String,FieldType> |
buildFieldMapExtension(String... definitions)
Create map from string representation ex: "String name", "Wikitty children[0-*]" |
|
static
|
cast(Object obj,
Class<E> clazz)
Try to cast obj to class passed in arguement |
|
static Wikitty |
checkExtensionVersion(WikittyService wikittyService,
Wikitty wikitty,
BusinessEntityWikitty entity)
Check extension default, i.e. if bean contain a extension with a great version as in wikitty. |
|
static Object |
fromString(FieldType field,
String s)
convert string field representation to correct value type |
|
static String |
genUID()
|
|
static Class |
getClass(Object value)
return class of argument, if argument is null, return null |
|
static String |
incrementMajorRevision(String v)
increment major version. |
|
static String |
incrementMinorRevision(String v)
increment minor version. |
|
static
|
newInstance(Class<E> clazz)
Create new instance of WikittyDto without Wikitty object passed in argument. |
|
static
|
newInstance(WikittyService wikittyService,
Class<E> clazz,
Wikitty w)
Create new instance of WikittyDto with Wikitty object passed in argument. |
|
static String |
normalizeVersion(String version)
if version if null return 0 else version If version is not in format |
|
static String |
parseField(String def,
FieldType fieldType)
parse FieldType definition and return field name. |
|
static Map<String,String> |
tagValuesToMap(String tagValues)
Deserialize tagValues to map |
|
static String |
tagValuesToString(Map<String,String> tagValues)
Serialize tagValues to string |
|
static BigDecimal |
toBigDecimal(Object value)
|
|
static boolean |
toBoolean(Object value)
Convert object to boolean: - null => false - 0 => false - numeric => true - object.toString() == false => false - other => true |
|
static Date |
toDate(Object value)
|
|
static
|
toList(Object value,
Class<E> clazz)
|
|
static String |
toString(FieldType field,
Object o)
Convert object o for indexation |
|
static String |
toString(Object value)
|
|
static String |
toWikitty(Object value)
return wikitty id and not wikitty objet because this method can be call on server or client side and it's better to keep conversion between id and objet to the caller |
|
static boolean |
versionEquals(String v1,
String v2)
return true if v1 and v2 are egals 1.2.0 et 1.2 ne sont pas egaux |
|
static boolean |
versionGreaterThan(String v1,
String v2)
return true if v1 greater than v2 |
|
static
|
wikittyToBean(Class<E> clazz,
F dto)
|
|
static
|
wikittyToBean(Class<E> clazz,
Wikitty w)
Convert WikittyDto (dto that encapsulate Wikitty) to BeanDto (dto without internaly wikitty) |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_VERSION
public static final String DATE_FORMAT
protected static TimeZone CANONICAL_TZ
protected static final Locale CANONICAL_LOCALE
public static final SimpleDateFormat solrDateFormat
protected static final DateFormat[] parserDateFormats
public static Map<Class,Class> interfaceToClass
protected static String tagValuesPatternString
protected static Pattern tagValuesPattern
protected static Pattern fieldPattern
| Constructor Detail |
|---|
public WikittyUtil()
| Method Detail |
|---|
public static String parseField(String def,
FieldType fieldType)
def - string field definitionfieldType - object used to put parsed information
public static String tagValuesToString(Map<String,String> tagValues)
tagValues - tagValues as map
public static Map<String,String> tagValuesToMap(String tagValues)
tagValues - tagValues as string
public static LinkedHashMap<String,FieldType> buildFieldMapExtension(String... definitions)
definitions -
public static String normalizeVersion(String version)
version -
public static boolean versionEquals(String v1,
String v2)
public static boolean versionGreaterThan(String v1,
String v2)
v1 - v2 -
public static String incrementMinorRevision(String v)
version - version as 3.1 where 1 is minor and 3 major
public static String incrementMajorRevision(String v)
version - version as 3.2 where 2 is minor and 3 major
public static BigDecimal toBigDecimal(Object value)
value - null and empty string are casted to '0' value.
WikittyException - on NumberFormatException or if value object can't be casted
to number.public static boolean toBoolean(Object value)
value -
public static String toString(Object value)
public static Date toDate(Object value)
public static String toWikitty(Object value)
value -
WikittyException
public static <E> List<E> toList(Object value,
Class<E> clazz)
E - clazz -
public static String toString(FieldType field,
Object o)
field - field descriptiono - field value
public static Object fromString(FieldType field,
String s)
field - field descriptions - string value
public static Class getClass(Object value)
value -
public static <E extends BusinessEntity> E newInstance(Class<E> clazz)
clazz parameter must be child of WikittyDto or business interface
clazz - class of the new instance
public static <E extends BusinessEntity> E newInstance(WikittyService wikittyService,
Class<E> clazz,
Wikitty w)
clazz parameter must be child of WikittyDto or business interface
clazz - class of the new instancew - wikitty object to use internaly for in new instance
public static Wikitty checkExtensionVersion(WikittyService wikittyService,
Wikitty wikitty,
BusinessEntityWikitty entity)
wikittyService - wikitty - entity -
public static <E> E cast(Object obj,
Class<E> clazz)
obj - object to castclazz - new type of object
public static Wikitty beanToWikitty(BusinessEntity bean)
public static Wikitty beanToWikitty(BusinessEntityBean bean)
public static <E extends BusinessEntityBean,F extends BusinessEntityWikitty> E wikittyToBean(Class<E> clazz,
F dto)
public static <E extends BusinessEntityBean> E wikittyToBean(Class<E> clazz,
Wikitty w)
clazz - target object clazzw - source object
public static String genUID()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||