net.handle.hdllib
Class GsonUtility

java.lang.Object
  extended by net.handle.hdllib.GsonUtility

public class GsonUtility
extends java.lang.Object


Nested Class Summary
static class GsonUtility.AdminRecordGsonTypeAdapter
           
static class GsonUtility.HandleValueGsonTypeAdapter
           
static class GsonUtility.InterfaceGsonTypeAdapter
           
static class GsonUtility.PublicKeyTypeHierarchyAdapter
           
static class GsonUtility.ResponseGsonTypeHierarchyAdapter
           
static class GsonUtility.ServerInfoGsonTypeAdapter
           
static class GsonUtility.SiteInfoGsonTypeAdapter
           
static class GsonUtility.TransactionGsonTypeAdapter
           
static class GsonUtility.ValueReferenceGsonTypeAdapter
           
 
Constructor Summary
GsonUtility()
           
 
Method Summary
static com.google.gson.Gson getGson()
          Returns a Gson instance which can serialize and deserialize various Handle.net types.
static com.google.gson.GsonBuilder getNewGsonBuilder()
          Returns a GsonBuilder which can serialize and deserialize various Handle.net types.
static com.google.gson.Gson getPrettyGson()
          Returns a Gson instance which can serialize and deserialize various Handle.net types.
static com.google.gson.JsonElement serializeResponseToRequest(AbstractRequest req, AbstractResponse resp)
          Serialize a response, adding in the handle value from the given request.
static com.google.gson.GsonBuilder setup(com.google.gson.GsonBuilder gsonBuilder)
          Register Handle.net type adapters on a given GsonBuilder, to enable serialization and deserialization of various Handle.net types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GsonUtility

public GsonUtility()
Method Detail

setup

public static com.google.gson.GsonBuilder setup(com.google.gson.GsonBuilder gsonBuilder)
Register Handle.net type adapters on a given GsonBuilder, to enable serialization and deserialization of various Handle.net types.

Parameters:
gsonBuilder - a GsonBuilder
Returns:
the passed-in GsonBuilder.

getNewGsonBuilder

public static com.google.gson.GsonBuilder getNewGsonBuilder()
Returns a GsonBuilder which can serialize and deserialize various Handle.net types.

Returns:
a GsonBuilder which can serialize and deserialize various Handle.net types.

getGson

public static com.google.gson.Gson getGson()
Returns a Gson instance which can serialize and deserialize various Handle.net types. This Gson instance has HTML escaping disabled.

Returns:
a Gson instance which can serialize and deserialize various Handle.net types.

getPrettyGson

public static com.google.gson.Gson getPrettyGson()
Returns a Gson instance which can serialize and deserialize various Handle.net types. This Gson instance has HTML escaping disabled and pretty-printing enabled.

Returns:
a Gson instance which can serialize and deserialize various Handle.net types.

serializeResponseToRequest

public static com.google.gson.JsonElement serializeResponseToRequest(AbstractRequest req,
                                                                     AbstractResponse resp)
Serialize a response, adding in the handle value from the given request.

Parameters:
req - a request
resp - a response
Returns:
The response, serialized as a JSON tree, with the "handle" value from the request if not already in the response.