Package com.anaptecs.jeaf.json.impl
Class JSONToolsImpl
- java.lang.Object
-
- com.anaptecs.jeaf.json.impl.JSONToolsImpl
-
- All Implemented Interfaces:
com.anaptecs.jeaf.json.api.JSONTools
@ToolsImplementation(toolsInterface=com.anaptecs.jeaf.json.api.JSONTools.class) public class JSONToolsImpl extends java.lang.Object implements com.anaptecs.jeaf.json.api.JSONToolsClass provides an implementation of JEAF JSON Tools- Author:
- JEAF Development Team
-
-
Constructor Summary
Constructors Constructor Description JSONToolsImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.ObjectMappergetDefaultObjectMapper()Method returns a JSONObjectMapperthat is configured as defined usingObjectMapperConfigandModuleFactory.<T> Tread(byte[] pBytes, com.anaptecs.jeaf.json.api.ObjectType pResultType)Method deserializes the passed byte array into an object of the passed type.<T> Tread(byte[] pBytes, java.lang.Class<T> pResultType)Method deserializes the passed byte array into an object of the passed type.<T> Tread(java.io.File pFile, com.anaptecs.jeaf.json.api.ObjectType pResultType)Method deserializes the data from the passed file into an object of the passed type.<T> Tread(java.io.File pFile, java.lang.Class<T> pResultType)Method deserializes the data from the passed file into an object of the passed type.<T> Tread(java.io.InputStream pInputStream, com.anaptecs.jeaf.json.api.ObjectType pResultType)Method deserializes the data of passed stream into an object of the passed type.<T> Tread(java.io.InputStream pInputStream, java.lang.Class<T> pResultType)Method deserializes the data of passed stream into an object of the passed type.<T> Tread(java.io.Reader pReader, com.anaptecs.jeaf.json.api.ObjectType pResultType)Method deserializes the data from the passed reader into an object of the passed type.<T> Tread(java.io.Reader pReader, java.lang.Class<T> pResultType)Method deserializes the data from the passed reader into an object of the passed type.<T> Tread(java.lang.String pString, com.anaptecs.jeaf.json.api.ObjectType pResultType)Method deserializes the passed string into an object of the passed type.<T> Tread(java.lang.String pString, java.lang.Class<T> pResultType)Method deserializes the passed string into an object of the passed type.<T> TreadToCollection(byte[] pBytes, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType)Method deserializes the passed string into aListof objects of the passed type.<T> TreadToCollection(java.io.File pFile, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType)Method deserializes the data from the passed file into aListof objects of the passed type.<T> TreadToCollection(java.io.InputStream pInputStream, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType)Method deserializes the data of passed stream into aListof objects of the passed type.<T> TreadToCollection(java.io.Reader pReader, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType)Method deserializes the data from the passed reader into aListof objects of the passed type.<T> TreadToCollection(java.lang.String pString, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType)Method deserializes the passed string into aListof objects of the passed type.voidwriteObject(java.lang.Object pObject, java.io.File pFile)Method serializes the passed object to the passed file.voidwriteObject(java.lang.Object pObject, java.io.OutputStream pOutputStream)Method serializes the passed object to the passed stream.voidwriteObject(java.lang.Object pObject, java.io.Writer pWriter)Method serializes the passed object to the passed writer.voidwriteObjects(java.util.Collection<?> pObjects, java.io.File pFile, java.lang.Class<?> pObjectType)Method serializes the passedCollectionto the passed file.voidwriteObjects(java.util.Collection<?> pObjects, java.io.OutputStream pOutputStream, java.lang.Class<?> pObjectType)Method serializes the passedCollectionto the passed stream.voidwriteObjects(java.util.Collection<?> pObjects, java.io.Writer pWriter, java.lang.Class<?> pObjectType)Method serializes the passedCollectionto the passed writer.byte[]writeObjectsToBytes(java.util.Collection<?> pObjects, java.lang.Class<?> pObjectType)Method serializes the passedCollectionas byte array.java.lang.StringwriteObjectsToString(java.util.Collection<?> pObjects, java.lang.Class<?> pObjectType)Method serializes the passedCollectionas string.byte[]writeObjectToBytes(java.lang.Object pObject)Method serializes the passed object as byte array.java.lang.StringwriteObjectToString(java.lang.Object pObject)Method serializes the passed object as string.
-
-
-
Method Detail
-
getDefaultObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getDefaultObjectMapper()
Method returns a JSONObjectMapperthat is configured as defined usingObjectMapperConfigandModuleFactory.- Specified by:
getDefaultObjectMapperin interfacecom.anaptecs.jeaf.json.api.JSONTools- Returns:
ObjectMapperObject mapper that should be used for JSON serialization.
-
writeObject
public void writeObject(java.lang.Object pObject, java.io.OutputStream pOutputStream) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passed object to the passed stream.- Specified by:
writeObjectin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObject- Object that should be serialized as JSON. The parameter may be null.pOutputStream- Stream to which the object should be written. The parameter must not be null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObject
public void writeObject(java.lang.Object pObject, java.io.Writer pWriter) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passed object to the passed writer.- Specified by:
writeObjectin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObject- Object that should be serialized as JSON. The parameter may be null.pWriter- Writer to which the object should be written. The parameter must not be null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObject
public void writeObject(java.lang.Object pObject, java.io.File pFile) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passed object to the passed file.- Specified by:
writeObjectin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObject- Object that should be serialized as JSON. The parameter may be null.pFile- File to which the object should be written. The parameter must not be null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjectToString
public java.lang.String writeObjectToString(java.lang.Object pObject) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passed object as string.- Specified by:
writeObjectToStringin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObject- Object that should be serialized as JSON. The parameter may be null.- Returns:
StringJSON serialized object as String. The method never returns null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjectToBytes
public byte[] writeObjectToBytes(java.lang.Object pObject) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passed object as byte array.- Specified by:
writeObjectToBytesin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObject- Object that should be serialized as JSON. The parameter may be null.- Returns:
- byte[] JSON serialized object as byte array. The method never returns null.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjects
public void writeObjects(java.util.Collection<?> pObjects, java.io.OutputStream pOutputStream, java.lang.Class<?> pObjectType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passedCollectionto the passed stream.- Specified by:
writeObjectsin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObjects- Collection of objects that should be serialized as JSON. The parameter may be null.pOutputStream- Stream to which the object should be written. The parameter must not be null.pObjectType-Classobject representing the type of objects that are inside the collection. As type info of Java generics is not present at runtime this information has to be passed as additional parameter.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjects
public void writeObjects(java.util.Collection<?> pObjects, java.io.Writer pWriter, java.lang.Class<?> pObjectType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passedCollectionto the passed writer.- Specified by:
writeObjectsin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObjects- Collection of objects that should be serialized as JSON. The parameter may be null.pWriter- Writer to which the object should be written. The parameter must not be null.pObjectType-Classobject representing the type of objects that are inside the collection. As type info of Java generics is not present at runtime this information has to be passed as additional parameter.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjects
public void writeObjects(java.util.Collection<?> pObjects, java.io.File pFile, java.lang.Class<?> pObjectType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passedCollectionto the passed file.- Specified by:
writeObjectsin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObjects- Collection of objects that should be serialized as JSON. The parameter may be null.pFile- File to which the object should be written. The parameter must not be null.pObjectType-Classobject representing the type of objects that are inside the collection. As type info of Java generics is not present at runtime this information has to be passed as additional parameter.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjectsToString
public java.lang.String writeObjectsToString(java.util.Collection<?> pObjects, java.lang.Class<?> pObjectType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passedCollectionas string.- Specified by:
writeObjectsToStringin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObjects- Collection of objects that should be serialized as JSON. The parameter may be null.pObjectType-Classobject representing the type of objects that are inside the collection. As type info of Java generics is not present at runtime this information has to be passed as additional parameter.- Returns:
StringJSON serialized object as String. The method never returns null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
writeObjectsToBytes
public byte[] writeObjectsToBytes(java.util.Collection<?> pObjects, java.lang.Class<?> pObjectType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod serializes the passedCollectionas byte array.- Specified by:
writeObjectsToBytesin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pObjects- Collection of objects that should be serialized as JSON. The parameter may be null.pObjectType-Classobject representing the type of objects that are inside the collection. As type info of Java generics is not present at runtime this information has to be passed as additional parameter.- Returns:
StringJSON serialized object as String. The method never returns null.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during serialization
-
read
public <T> T read(java.io.InputStream pInputStream, java.lang.Class<T> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data of passed stream into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pInputStream- Stream from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.io.Reader pReader, java.lang.Class<T> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed reader into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pReader- Reader from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.io.File pFile, java.lang.Class<T> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed file into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pFile- File from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.lang.String pString, java.lang.Class<T> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed string into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pString- String from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(byte[] pBytes, java.lang.Class<T> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed byte array into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pBytes- Byte array from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.lang.String pString, com.anaptecs.jeaf.json.api.ObjectType pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed string into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pString- String from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(byte[] pBytes, com.anaptecs.jeaf.json.api.ObjectType pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed byte array into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pBytes- Byte array from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.io.InputStream pInputStream, com.anaptecs.jeaf.json.api.ObjectType pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data of passed stream into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pInputStream- Stream from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.io.Reader pReader, com.anaptecs.jeaf.json.api.ObjectType pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed reader into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pReader- Reader from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
read
public <T> T read(java.io.File pFile, com.anaptecs.jeaf.json.api.ObjectType pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed file into an object of the passed type.- Specified by:
readin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pFile- File from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
- T Object of passed type that was created. The method may return null if null was serialized.
- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
readToCollection
public <T> T readToCollection(java.io.InputStream pInputStream, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data of passed stream into aListof objects of the passed type.- Specified by:
readToCollectionin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pInputStream- Stream from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
ListList of objects of passed type that was created from the JSON data. The method may return null if null was serialized.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
readToCollection
public <T> T readToCollection(java.io.Reader pReader, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed reader into aListof objects of the passed type.- Specified by:
readToCollectionin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pReader- Reader from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
ListList of objects of passed type that was created from the JSON data. The method may return null if null was serialized.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
readToCollection
public <T> T readToCollection(java.io.File pFile, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the data from the passed file into aListof objects of the passed type.- Specified by:
readToCollectionin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pFile- File from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
ListList of objects of passed type that was created from the JSON data. The method may return null if null was serialized.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
readToCollection
public <T> T readToCollection(java.lang.String pString, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed string into aListof objects of the passed type.- Specified by:
readToCollectionin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pString- String from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
ListList of objects of passed type that was created from the JSON data. The method may return null if null was serialized.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
readToCollection
public <T> T readToCollection(byte[] pBytes, java.lang.Class<? extends java.util.Collection> pCollectionType, java.lang.Class<?> pResultType) throws com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemExceptionMethod deserializes the passed string into aListof objects of the passed type.- Specified by:
readToCollectionin interfacecom.anaptecs.jeaf.json.api.JSONTools- Parameters:
pBytes- Byte array from which the data should be read. The parameter must not be null.pResultType- Type of the object that should be created. The parameter must not be null.- Returns:
ListList of objects of passed type that was created from the JSON data. The method may return null if null was serialized.- Throws:
com.anaptecs.jeaf.xfun.api.errorhandling.JEAFSystemException- if an error occurs during deserialization
-
-