Class ObjectBuilder

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

public class ObjectBuilder extends Object
Version:
$Id$
Author:
Andrey Parfonov
  • Constructor Details

    • ObjectBuilder

      public ObjectBuilder()
  • Method Details

    • 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.