eXo WS :: Framework :: JSON 2.4.0-Alpha1

org.exoplatform.ws.frameworks.json.impl
Class ObjectBuilder

java.lang.Object
  extended by org.exoplatform.ws.frameworks.json.impl.ObjectBuilder

public class ObjectBuilder
extends Object

Version:
$Id$
Author:
Andrey Parfonov

Constructor Summary
ObjectBuilder()
           
 
Method Summary
static Object createArray(Class<?> clazz, JsonValue jsonArray)
          Create array of Java Object from JSON source include multi-dimension array.
static
<T extends Collection<?>>
T
createCollection(Class<T> collectionClass, Type genericType, JsonValue jsonArray)
          Create instance of collectionClass from JSON representation.
static
<T> T
createObject(Class<T> clazz, JsonValue jsonValue)
          Create Java Bean from Json Source.
static
<T extends Map<String,?>>
T
createObject(Class<T> mapClass, Type genericType, JsonValue jsonObject)
          Create instance of mapClass from JSON representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectBuilder

public ObjectBuilder()
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 of collectionClass from JSON representation. If collectionClass is interface then appropriate implementation of interface will be returned.

Parameters:
collectionClass - collection type
genericType - generic type of collection
jsonArray - 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 of mapClass from JSON representation. If mapClass is interface then appropriate implementation of interface will be returned.

Parameters:
mapClass - map type
genericType - actual type of map
jsonObject - 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.

eXo WS :: Framework :: JSON 2.4.0-Alpha1

Copyright © 2013 eXo Platform SAS. All Rights Reserved.