|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.wikitty.WikittyUtil
public class WikittyUtil
Util static method for wikitty.
| Field Summary | |
|---|---|
protected static Locale |
CANONICAL_LOCALE
|
protected static TimeZone |
CANONICAL_TZ
used to format date for solr |
static String |
DATE_FORMAT
|
static String[] |
DATE_FORMAT_ALLOWED
|
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, mutually exclusive with group 5 group 5: upper bound (n or *) can be null group 6: unique can be null (legacy configuration, prefer use of unique="true"
group 7: not null can be null (legacy configuration, prefer use of notNull="true"
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 org.apache.commons.lang.time.FastDateFormat |
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 LinkedHashMap<String,FieldType> |
buildFieldMapExtension(String... definitions)
Create map from string representation. |
|
static
|
cast(Object obj,
Class<E> clazz)
Try to cast obj to class passed in argument. |
|
static Wikitty |
checkExtensionVersion(String securityToken,
WikittyService wikittyService,
Wikitty wikitty,
BusinessEntityWikitty entity)
Check extension default, i.e. if bean contain a extension with a great version as in wikitty. |
|
static String |
formatDate(Date date)
|
|
static Object |
fromString(FieldType field,
String s)
Convert string field representation to correct value type. |
|
static String |
genSecurityToken()
SecurityToken is used like wikitty id and must begin with UUID_ |
|
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(String securityToken,
WikittyService wikittyService,
Class<E> clazz,
Wikitty w)
Create new instance of BusinessEntity from 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 Date |
parseDate(String dateAsString)
|
|
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)
Get value as BigDecimal. |
|
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)
Convert value to list. |
|
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 equals. 1.2.0 et 1.2 ne sont pas egaux |
|
static boolean |
versionGreaterThan(String v1,
String v2)
Return true if v1 greater than v2. |
|
| 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
public static final String[] DATE_FORMAT_ALLOWED
protected static TimeZone CANONICAL_TZ
protected static final Locale CANONICAL_LOCALE
protected static final org.apache.commons.lang.time.FastDateFormat solrDateFormat
public static Map<Class<?>,Class<?>> interfaceToClass
protected static String tagValuesPatternString
protected static Pattern tagValuesPattern
protected static Pattern fieldPattern
unique="true"
notNull="true"
| Constructor Detail |
|---|
public WikittyUtil()
| Method Detail |
|---|
public static Date parseDate(String dateAsString)
throws ParseException
ParseException
public static String formatDate(Date date)
throws ParseException
ParseException
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 - extension definition
public static String normalizeVersion(String version)
version - version
public static boolean versionEquals(String v1,
String v2)
v1 - versionv2 - version
true if v1 == v2
public static boolean versionGreaterThan(String v1,
String v2)
v1 - versionv2 - version
true if v1 > v2public static String incrementMinorRevision(String v)
v - version as 3.1 where 1 is minor and 3 major
public static String incrementMajorRevision(String v)
v - 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 - value
public static String toString(Object value)
public static Date toDate(Object value)
public static String toWikitty(Object value)
value -
public static <E> List<E> toList(Object value,
Class<E> clazz)
E - elements typevalue - value to convertclazz - element class
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
E - element typeclazz - class of the new instance
public static <E extends BusinessEntity> E newInstance(String securityToken,
WikittyService wikittyService,
Class<E> clazz,
Wikitty w)
clazz parameter must be child of Business interface
E - entity typewikittyService - wikitty serviceclazz - class of the new instancew - wikitty object to use internaly for in new instance
public static Wikitty checkExtensionVersion(String securityToken,
WikittyService wikittyService,
Wikitty wikitty,
BusinessEntityWikitty entity)
wikittyService - wikitty - entity -
public static <E> E cast(Object obj,
Class<E> clazz)
E - element typeobj - object to castclazz - new type of object
public static String genSecurityToken()
public static String genUID()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||