org.datanucleus.api.rest
Class RESTUtils

java.lang.Object
  extended by org.datanucleus.api.rest.RESTUtils

public class RESTUtils
extends java.lang.Object

Series of convenience methods for manipulating JSONObject objects.


Constructor Summary
RESTUtils()
           
 
Method Summary
static java.lang.Object getIdentityForURLToken(org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.String token, org.datanucleus.NucleusContext nucCtx)
           
static JSONArray getJSONArrayFromCollection(java.util.Collection coll, org.datanucleus.store.ExecutionContext ec)
          Method to convert the provided POJO into its equivalent JSONObject.
static JSONObject getJSONObjectFromPOJO(java.lang.Object obj, org.datanucleus.store.ExecutionContext ec)
          Method to convert the provided POJO into its equivalent JSONObject.
static java.lang.Object getNonPersistableObjectFromJSONObject(JSONObject jsonobj, java.lang.Class cls, org.datanucleus.NucleusContext nucCtx)
          Deserialise from JSON to an object.
static java.lang.Object getObjectFromJSONObject(JSONObject jsonobj, java.lang.String className, org.datanucleus.store.ExecutionContext ec)
          Method to convert the provided JSONObject into its equivalent object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RESTUtils

public RESTUtils()
Method Detail

getJSONArrayFromCollection

public static JSONArray getJSONArrayFromCollection(java.util.Collection coll,
                                                   org.datanucleus.store.ExecutionContext ec)
Method to convert the provided POJO into its equivalent JSONObject.

Parameters:
coll - Collection of POJOs
ec - ExecutionContext
Returns:
The JSONObject

getJSONObjectFromPOJO

public static JSONObject getJSONObjectFromPOJO(java.lang.Object obj,
                                               org.datanucleus.store.ExecutionContext ec)
Method to convert the provided POJO into its equivalent JSONObject.

Parameters:
obj - The object
ec - ExecutionContext
Returns:
The JSONObject

getObjectFromJSONObject

public static java.lang.Object getObjectFromJSONObject(JSONObject jsonobj,
                                                       java.lang.String className,
                                                       org.datanucleus.store.ExecutionContext ec)
Method to convert the provided JSONObject into its equivalent object. If it represents a POJO and the POJO is persistent then retrieves it and superimposes the JSONObject values. If it represents a POJO and the POJO is not yet persistent then creates it with the JSONObject values. Also allows some specific non-persistable object types.

Parameters:
jsonobj - JSONObject
className - Name of the class
ec - ExecutionContext
Returns:
The Object being represented
Throws:
org.datanucleus.exceptions.ClassNotResolvedException - when the class is not found
{@link - JDOFatalUserException} If other error occurred

getIdentityForURLToken

public static java.lang.Object getIdentityForURLToken(org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                      java.lang.String token,
                                                      org.datanucleus.NucleusContext nucCtx)

getNonPersistableObjectFromJSONObject

public static java.lang.Object getNonPersistableObjectFromJSONObject(JSONObject jsonobj,
                                                                     java.lang.Class cls,
                                                                     org.datanucleus.NucleusContext nucCtx)
Deserialise from JSON to an object. Used for non-persistable classes.

Parameters:
jsonobj - JSONObject
cls - The class
nucCtx - NucleusContext
Returns:
The object of the specified class


Copyright © 2012. All Rights Reserved.