com.sibvisions.rad.server.http.rest
Class JSONUtil

java.lang.Object
  extended by com.sibvisions.rad.server.http.rest.JSONUtil

public final class JSONUtil
extends Object

The JSONUtil is an internal utility class for REST handling.


Method Summary
static void configureObjectMapper(com.fasterxml.jackson.databind.ObjectMapper pMapper)
          Configures the given object mapper.
static com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
          Creates a new ObjectMapper with preconfigured settings.
static com.fasterxml.jackson.databind.ObjectMapper enableArrays(com.fasterxml.jackson.databind.ObjectMapper pMapper)
          Configures the given object mapper to return Java arrays Object[] instead of Lists.
static PrintStream getDumpStream()
          Gets the dump stream.
static Object getObject(org.restlet.representation.Representation pRepresentation)
          Gets the result object from a representation, using default object mapper.
static
<T> T
getObject(org.restlet.representation.Representation pRepresentation, Class pClass)
          Gets the result object from a representation, using default object mapper.
static
<T> T
getObject(org.restlet.representation.Representation pRepresentation, Class pClass, com.fasterxml.jackson.databind.ObjectMapper pMapper)
          Gets the result object from a representation, using a custom object mapper.
static boolean isDumpStreamEnabled()
          Gets whether JSTOM stream dumping is enabled.
static void setDumpStream(PrintStream pStream)
          Sets the dump stream.
static void setDumpStreamEnabled(boolean pDump)
          Sets whether the JSON stream should be dumped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createObjectMapper

public static com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
Creates a new ObjectMapper with preconfigured settings.

Returns:
the object mapper

configureObjectMapper

public static void configureObjectMapper(com.fasterxml.jackson.databind.ObjectMapper pMapper)
Configures the given object mapper.

Parameters:
pMapper - the mapper

enableArrays

public static com.fasterxml.jackson.databind.ObjectMapper enableArrays(com.fasterxml.jackson.databind.ObjectMapper pMapper)
Configures the given object mapper to return Java arrays Object[] instead of Lists.

Parameters:
pMapper - the object mapper
Returns:
the configured objexct mapper

getObject

public static Object getObject(org.restlet.representation.Representation pRepresentation)
                        throws IOException
Gets the result object from a representation, using default object mapper.

Parameters:
pRepresentation - the object representation
Returns:
the object from the representation
Throws:
IOException - if object creation fails

getObject

public static <T> T getObject(org.restlet.representation.Representation pRepresentation,
                              Class pClass)
                   throws IOException
Gets the result object from a representation, using default object mapper.

Type Parameters:
T - the result object type
Parameters:
pRepresentation - the object representation
pClass - the expected class type
Returns:
the object from the representation
Throws:
IOException - if object creation fails

getObject

public static <T> T getObject(org.restlet.representation.Representation pRepresentation,
                              Class pClass,
                              com.fasterxml.jackson.databind.ObjectMapper pMapper)
                   throws IOException
Gets the result object from a representation, using a custom object mapper.

Type Parameters:
T - the result object type
Parameters:
pRepresentation - the object representation
pClass - the expected class type
pMapper - the object mapper for the object deserialization
Returns:
the object from the representation
Throws:
IOException - if object creation fails

setDumpStreamEnabled

public static void setDumpStreamEnabled(boolean pDump)
Sets whether the JSON stream should be dumped.

Parameters:
pDump - true to enable dumps, false otherwise

isDumpStreamEnabled

public static boolean isDumpStreamEnabled()
Gets whether JSTOM stream dumping is enabled.

Returns:
true if stream dumping is enabled, false otherwise

setDumpStream

public static void setDumpStream(PrintStream pStream)
Sets the dump stream.

Parameters:
pStream - the stream or null to reset the stream to its default value (System.out)

getDumpStream

public static PrintStream getDumpStream()
Gets the dump stream.

Returns:
the stream


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.