|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.stefaniuk.json.service.JsonServiceUtil
public class JsonServiceUtil
JSON service utility methods.
Constructor Summary | |
---|---|
JsonServiceUtil()
|
Method Summary | ||
---|---|---|
static
|
fromJson(FileReader fr,
Class<T> pojoClass)
Creates Java POJO object from JSON string. |
|
static
|
fromJson(String jsonAsString,
Class<T> pojoClass)
Creates Java POJO object from JSON string. |
|
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForMethodCall(BufferedOutputStream bos)
This method sets HTTP response headers adequate for JSON-RPC method call and returns ResponseEntity to be used by Spring Framework. |
|
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForMethodCall(BufferedOutputStream bos,
org.springframework.http.HttpStatus status)
This method sets HTTP response headers adequate for JSON-RPC method call and returns ResponseEntity to be used by Spring Framework. |
|
static org.springframework.http.ResponseEntity<String> |
getResponseEntityForServiceMap(BufferedOutputStream bos)
This method sets HTTP response headers adequate for Service Mapping Description and returns ResponseEntity to be used by Spring Framework. |
|
static org.springframework.http.ResponseEntity<String> |
handle(JsonServiceRegistry service,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Class<?> clazz)
Handles HTTP request. |
|
static org.springframework.http.ResponseEntity<String> |
handle(JsonServiceRegistry service,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Object obj)
Handles HTTP request. |
|
static void |
setHeadersForMethodCall(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response)
This method sets HTTP response headers adequate for JSON-RPC method call. |
|
static void |
setHeadersForMethodCall(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response,
int status)
This method sets HTTP response headers adequate for JSON-RPC method call. |
|
static void |
setHeadersForServiceMap(BufferedOutputStream bos,
javax.servlet.http.HttpServletResponse response)
This method sets HTTP response headers adequate for Service Mapping Description. |
|
static org.codehaus.jackson.node.ArrayNode |
toJson(List<?> list)
Converts a list to JSON array. |
|
static org.codehaus.jackson.node.ObjectNode |
toJson(Map<?,?> map)
Converts a map to JSON object. |
|
static String |
toJson(Object pojo,
boolean prettyPrint)
Serialises Java POJO object to JSON string. |
|
static void |
toJson(Object pojo,
FileWriter fw,
boolean prettyPrint)
Serialises Java POJO object to JSON string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsonServiceUtil()
Method Detail |
---|
public static void setHeadersForServiceMap(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response)
bos
- Output streamresponse
- HTTP response objectpublic static void setHeadersForMethodCall(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response)
bos
- Output streamresponse
- HTTP response objectpublic static void setHeadersForMethodCall(BufferedOutputStream bos, javax.servlet.http.HttpServletResponse response, int status)
bos
- Output streamresponse
- HTTP response objectstatus
- HTTP response codepublic static org.springframework.http.ResponseEntity<String> getResponseEntityForServiceMap(BufferedOutputStream bos)
bos
- Output stream
public static org.springframework.http.ResponseEntity<String> getResponseEntityForMethodCall(BufferedOutputStream bos)
bos
- Output stream
public static org.springframework.http.ResponseEntity<String> getResponseEntityForMethodCall(BufferedOutputStream bos, org.springframework.http.HttpStatus status)
bos
- Output streamstatus
- HTTP response code
public static org.springframework.http.ResponseEntity<String> handle(JsonServiceRegistry service, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Class<?> clazz) throws IOException
service
- Service registry objectrequest
- HTTP request objectresponse
- HTTP response objectclazz
- Class
IOException
public static org.springframework.http.ResponseEntity<String> handle(JsonServiceRegistry service, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object obj) throws IOException
service
- Service registry objectrequest
- HTTP request objectresponse
- HTTP response objectobj
- Already instantiated object
IOException
public static <T> Object fromJson(String jsonAsString, Class<T> pojoClass) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonParseException, IOException
T
- jsonAsString
- JSON stringpojoClass
- POJO class
org.codehaus.jackson.map.JsonMappingException
org.codehaus.jackson.JsonParseException
IOException
public static <T> Object fromJson(FileReader fr, Class<T> pojoClass) throws org.codehaus.jackson.JsonParseException, IOException
T
- fr
- File stream to read JSON string.pojoClass
- POJO class
org.codehaus.jackson.JsonParseException
IOException
public static String toJson(Object pojo, boolean prettyPrint) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonGenerationException, IOException
pojo
- POJO objectprettyPrint
- JSON pretty print
org.codehaus.jackson.map.JsonMappingException
org.codehaus.jackson.JsonGenerationException
IOException
public static void toJson(Object pojo, FileWriter fw, boolean prettyPrint) throws org.codehaus.jackson.map.JsonMappingException, org.codehaus.jackson.JsonGenerationException, IOException
pojo
- POJO objectfw
- File stream to write JSON string.prettyPrint
- JSON pretty print
org.codehaus.jackson.map.JsonMappingException
org.codehaus.jackson.JsonGenerationException
IOException
public static org.codehaus.jackson.node.ArrayNode toJson(List<?> list)
list
- List
public static org.codehaus.jackson.node.ObjectNode toJson(Map<?,?> map)
map
- Map
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |