org.schemarepo.json
Class GsonJsonUtil

java.lang.Object
  extended by org.schemarepo.json.GsonJsonUtil
All Implemented Interfaces:
JsonUtil

public class GsonJsonUtil
extends Object
implements JsonUtil

An implementation of JsonUtil that uses google-gson.


Constructor Summary
GsonJsonUtil()
           
 
Method Summary
 Iterable<SchemaEntry> schemasFromJson(String str)
          Decode a string created by JsonUtil.schemasToJson(Iterable)
 String schemasToJson(Iterable<SchemaEntry> allEntries)
          Encode SchemaEntry objects into a String for use by JsonUtil.schemasFromJson(String) The format is an array of objects containing id and schema fields, for example: [{"id": "0", "schema": "schema1"}, {"id": "2", "schema": "schema2"}]
 Iterable<String> subjectNamesFromJson(String str)
          Decode a string created by JsonUtil.subjectsToJson(Iterable)
 String subjectsToJson(Iterable<Subject> subjects)
          Encode Subjects into a String for use by JsonUtil.subjectNamesFromJson(String) The format is an array of objects containing a name field, for example: [{"name": "subject1"}, {"name": "subject2"}]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GsonJsonUtil

public GsonJsonUtil()
Method Detail

subjectsToJson

public String subjectsToJson(Iterable<Subject> subjects)
Description copied from interface: JsonUtil
Encode Subjects into a String for use by JsonUtil.subjectNamesFromJson(String) The format is an array of objects containing a name field, for example: [{"name": "subject1"}, {"name": "subject2"}]

Specified by:
subjectsToJson in interface JsonUtil
Parameters:
subjects - the Subject objects to encode
Returns:
The Subject objects encoded as a String

subjectNamesFromJson

public Iterable<String> subjectNamesFromJson(String str)
Description copied from interface: JsonUtil
Decode a string created by JsonUtil.subjectsToJson(Iterable)

Specified by:
subjectNamesFromJson in interface JsonUtil
Parameters:
str - The String to decode
Returns:
an Iterable of Subject

schemasToJson

public String schemasToJson(Iterable<SchemaEntry> allEntries)
Description copied from interface: JsonUtil
Encode SchemaEntry objects into a String for use by JsonUtil.schemasFromJson(String) The format is an array of objects containing id and schema fields, for example: [{"id": "0", "schema": "schema1"}, {"id": "2", "schema": "schema2"}]

Specified by:
schemasToJson in interface JsonUtil
Parameters:
allEntries - the SchemaEntry objects to encode
Returns:
The SchemaEntry objects encoded as a String

schemasFromJson

public Iterable<SchemaEntry> schemasFromJson(String str)
Description copied from interface: JsonUtil
Decode a string created by JsonUtil.schemasToJson(Iterable)

Specified by:
schemasFromJson in interface JsonUtil
Parameters:
str - The String to decode
Returns:
An Iterable of SchemaEntry


Copyright © 2015. All rights reserved.