|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.negro.jajb.utility.Utility
public class Utility
This Class provides some utilities used by JAJB
and
can be reused as you want.
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static java.lang.Class<?> |
getArrayClass(java.lang.Class<?> componentType)
This method return an array Class for the componentType Class passed. |
static java.lang.Class<?> |
getClass(java.lang.String typeName)
Return correct primitive type class for typeName passed like, "int", "short", "float", etc. |
static java.lang.Class<?> |
getCollectionClass(java.lang.String collectionType,
java.lang.Class<?> componentType)
Returns the correct collection class type for the passed collectionType and componentType passed parameters. |
static it.dangelo.domjson.JSONBuilder |
getJSONBuilder()
Returns a JSONBuilder instance. |
static boolean |
isComplexType(java.lang.Class<?> clazz)
Return true is passed parameter clazz is not primitive, is not an array, is not a Wrapper Class (Integer, Long, String, etc.), is not the Class of Object and is not a java.util.Date. |
static boolean |
isWrapper(java.lang.Class<?> clazz)
This method says if passed parameter Class is one of Byte , Short , Integer , Long ,
String , Character , Boolean , Float , Double
or not. |
static it.dangelo.domjson.JSONArray |
marshallSimpleArrayToJSONArray(java.lang.Object array)
Converts an array into a JSONArray . |
static it.dangelo.domjson.JSONArray |
marshallSimpleCollectionToJSONArray(java.util.Collection<?> collection,
java.lang.Class<?> componentType)
Converts a collection into a JSONArray . |
static java.lang.String |
resolveRefId(java.lang.Class<?> clazz)
Returns the refId of passed clazz. |
static java.lang.Object |
unmarshallSimpleArray(it.dangelo.domjson.JSONArray jsonArray,
java.lang.Class<?> arrayClass)
Converts a JSONArray into Java Array. |
static java.util.Collection<?> |
unmarshallSimpleCollection(it.dangelo.domjson.JSONArray jsonArray,
java.lang.Class<?> collectionClass,
java.lang.Class<?> componentType)
Does the same work of unmarshallSimpleArray method, but using collections. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static it.dangelo.domjson.JSONBuilder getJSONBuilder()
JSONBuilder
public static boolean isWrapper(java.lang.Class<?> clazz)
Byte
, Short
, Integer
, Long
,
String
, Character
, Boolean
, Float
, Double
or not.
clazz
-
public static java.lang.Class<?> getArrayClass(java.lang.Class<?> componentType)
componentType
-
public static boolean isComplexType(java.lang.Class<?> clazz)
clazz
-
public static java.lang.Class<?> getClass(java.lang.String typeName) throws java.lang.ClassNotFoundException
typeName
-
java.lang.ClassNotFoundException
public static java.lang.Class<?> getCollectionClass(java.lang.String collectionType, java.lang.Class<?> componentType) throws java.lang.ClassNotFoundException
Vector
Class;
if collectionType is "list" returns ArrayList
Class;
if collectionType is "set" return HashSet
Class;
otherwise tries to take the Class treating collectionType like a
Collection
Class name.
collectionType
- componentType
-
java.lang.ClassNotFoundException
public static java.lang.String resolveRefId(java.lang.Class<?> clazz)
EntityAnnotation
returns '@className',
otherwise '#className'.
clazz
-
public static java.lang.Object unmarshallSimpleArray(it.dangelo.domjson.JSONArray jsonArray, java.lang.Class<?> arrayClass) throws JAJBUnMarshallException
JSONArray
into Java Array.
Use it only for simple component type (wrapper, primitive or Date
jsonArray
- the JSONArray
to convertarrayClass
- the array class for result
(for example 'int[].class', 'String[].class', etc.
JAJBUnMarshallException
public static java.util.Collection<?> unmarshallSimpleCollection(it.dangelo.domjson.JSONArray jsonArray, java.lang.Class<?> collectionClass, java.lang.Class<?> componentType) throws JAJBUnMarshallException
jsonArray
- the JSONArray
to convertcollectionClass
- the collection class for result
(for example 'ArrayList.class', 'Vector.class', etc.componentType
- the class of collection component
JAJBUnMarshallException
public static it.dangelo.domjson.JSONArray marshallSimpleArrayToJSONArray(java.lang.Object array) throws JAJBMarshallException
JSONArray
.
Converts only Date[] or primitive array (int[], char[], etc) or wrapper array (String[], Boolean[], etc.)
array
- the array to convert
JSONArray
JAJBMarshallException
public static it.dangelo.domjson.JSONArray marshallSimpleCollectionToJSONArray(java.util.Collection<?> collection, java.lang.Class<?> componentType) throws JAJBMarshallException
JSONArray
.
Component type must be a wrapper type (String, Long, etc.9 or a Date
collection
- componentType
-
JSONArray
JAJBMarshallException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |