Class ObjectBuilder
- java.lang.Object
-
- org.exoplatform.ws.frameworks.json.impl.ObjectBuilder
-
public class ObjectBuilder extends Object
- Version:
- $Id$
- Author:
- Andrey Parfonov
-
-
Constructor Summary
Constructors Constructor Description ObjectBuilder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectcreateArray(Class<?> clazz, JsonValue jsonArray)Create array of Java Object from JSON source include multi-dimension array.static <T extends Collection<?>>
TcreateCollection(Class<T> collectionClass, Type genericType, JsonValue jsonArray)Create instance ofcollectionClassfrom JSON representation.static <T extends Map<String,?>>
TcreateObject(Class<T> mapClass, Type genericType, JsonValue jsonObject)Create instance ofmapClassfrom JSON representation.static <T> TcreateObject(Class<T> clazz, JsonValue jsonValue)Create Java Bean from Json Source.
-
-
-
Method Detail
-
createArray
public static Object createArray(Class<?> clazz, JsonValue jsonArray) throws JsonException
Create array of Java Object from JSON source include multi-dimension array.- Parameters:
clazz- the Class of target Object.jsonArray- the JSON representation of array- Returns:
- result array
- Throws:
JsonException- if any errors occurs
-
createCollection
public static <T extends Collection<?>> T createCollection(Class<T> collectionClass, Type genericType, JsonValue jsonArray) throws JsonException
Create instance ofcollectionClassfrom JSON representation. IfcollectionClassis interface then appropriate implementation of interface will be returned.- Parameters:
collectionClass- collection typegenericType- generic type of collectionjsonArray- the JSON representation of collection- Returns:
- result collection
- Throws:
JsonException- if any errors occurs
-
createObject
public static <T extends Map<String,?>> T createObject(Class<T> mapClass, Type genericType, JsonValue jsonObject) throws JsonException
Create instance ofmapClassfrom JSON representation. IfmapClassis interface then appropriate implementation of interface will be returned.- Parameters:
mapClass- map typegenericType- actual type of mapjsonObject- source JSON object- Returns:
- map
- Throws:
JsonException- if any errors occurs
-
createObject
public static <T> T createObject(Class<T> clazz, JsonValue jsonValue) throws JsonException
Create Java Bean from Json Source.- Parameters:
clazz- the Class of target Object.jsonValue- the Json representation.- Returns:
- Object.
- Throws:
JsonException- if any errors occurs.
-
-