Class DJsonContext
- java.lang.Object
-
- io.ebeaninternal.server.text.json.DJsonContext
-
- All Implemented Interfaces:
JsonContext
,SpiJsonContext
public class DJsonContext extends Object implements SpiJsonContext
Default implementation of JsonContext.
-
-
Constructor Summary
Constructors Constructor Description DJsonContext(SpiEbeanServer server, com.fasterxml.jackson.core.JsonFactory jsonFactory, TypeManager typeManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> DJsonBeanReader<T>
createBeanReader(BeanType<T> beanType, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options)
Create and return a new bean reading for the bean type given the JSON options and source.<T> DJsonBeanReader<T>
createBeanReader(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options)
Create and return a new bean reading for the bean type given the JSON options and source.com.fasterxml.jackson.core.JsonGenerator
createGenerator(Writer writer)
Create and return a new JsonGenerator for the given writer.SpiJsonReader
createJsonRead(BeanType<?> beanType, String json)
Create a Json Reader for reading the JSON content.SpiJsonWriter
createJsonWriter(com.fasterxml.jackson.core.JsonGenerator gen, JsonWriteOptions options)
Create a Json Writer for writing beans as JSON.SpiJsonWriter
createJsonWriter(Writer writer)
Create a Json Writer for writing beans as JSON supplying a writer.com.fasterxml.jackson.core.JsonParser
createParser(Reader reader)
Create and return a new JsonParser for the given reader.boolean
isSupportedType(Type genericType)
Return true if the type is known as an Entity bean or a List Set or Map of entity beans.<T> T
toBean(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser)
Convert json parser input into a Bean of a specific type.<T> T
toBean(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options)
Convert json parser input into a Bean of a specific type additionally using JsonReadOptions..<T> T
toBean(Class<T> cls, Reader jsonReader)
Convert json reader input into a Bean of a specific type.<T> T
toBean(Class<T> cls, Reader jsonReader, JsonReadOptions options)
Convert json reader input into a Bean of a specific type additionally using JsonReadOptions.<T> T
toBean(Class<T> cls, String json)
Convert json string input into a Bean of a specific type.<T> T
toBean(Class<T> cls, String json, JsonReadOptions options)
Convert json string input into a Bean of a specific type additionally using JsonReadOptions.String
toJson(Object o)
Return the bean or collection as JSON string.void
toJson(Object value, com.fasterxml.jackson.core.JsonGenerator generator)
Write the bean or collection to the JsonGenerator.void
toJson(Object value, com.fasterxml.jackson.core.JsonGenerator generator, FetchPath fetchPath)
Write the bean or collection to the JsonGenerator using the FetchPath.void
toJson(Object o, com.fasterxml.jackson.core.JsonGenerator generator, JsonWriteOptions options)
Deprecated in favour of using PathProperties by itself.String
toJson(Object value, FetchPath fetchPath)
Return the bean or collection as JSON string using FetchPath.String
toJson(Object o, JsonWriteOptions options)
Deprecated in favour of using PathProperties by itself.void
toJson(Object o, Writer writer)
Write the bean or collection in JSON format to the writer.void
toJson(Object o, Writer writer, FetchPath fetchPath)
Write the bean or collection as json to the writer using the FetchPath.void
toJson(Object o, Writer writer, JsonWriteOptions options)
Deprecated in favour of using PathProperties by itself.String
toJsonPretty(Object value)
Return the bean or collection as JSON string in pretty format.<T> List<T>
toList(Class<T> cls, com.fasterxml.jackson.core.JsonParser src)
Convert json parser input into a list of beans of a specific type.<T> List<T>
toList(Class<T> cls, com.fasterxml.jackson.core.JsonParser src, JsonReadOptions options)
Convert json parser input into a list of beans of a specific type additionally using JsonReadOptions.<T> List<T>
toList(Class<T> cls, Reader jsonReader)
Convert json reader input into a list of beans of a specific type.<T> List<T>
toList(Class<T> cls, Reader jsonReader, JsonReadOptions options)
Convert json reader input into a list of beans of a specific type additionally using JsonReadOptions.<T> List<T>
toList(Class<T> cls, String json)
Convert json string input into a list of beans of a specific type.<T> List<T>
toList(Class<T> cls, String json, JsonReadOptions options)
Convert json string input into a list of beans of a specific type additionally using JsonReadOptions.Object
toObject(Type genericType, com.fasterxml.jackson.core.JsonParser jsonParser)
Use the genericType to determine if this should be converted into a List or bean.Object
toObject(Type genericType, Reader json)
Use the genericType to determine if this should be converted into a List or bean.Object
toObject(Type genericType, String json)
Use the genericType to determine if this should be converted into a List or bean.void
writeScalar(com.fasterxml.jackson.core.JsonGenerator generator, Object scalarValue)
Write a scalar types known to Ebean to Jackson.
-
-
-
Constructor Detail
-
DJsonContext
public DJsonContext(SpiEbeanServer server, com.fasterxml.jackson.core.JsonFactory jsonFactory, TypeManager typeManager)
-
-
Method Detail
-
writeScalar
public void writeScalar(com.fasterxml.jackson.core.JsonGenerator generator, Object scalarValue) throws IOException
Description copied from interface:JsonContext
Write a scalar types known to Ebean to Jackson.Ebean has built in support for java8 and Joda types as well as the other standard JDK types like URI, URL, UUID etc. This is a fast simple way to write any of those types to Jackson.
- Specified by:
writeScalar
in interfaceJsonContext
- Throws:
IOException
-
isSupportedType
public boolean isSupportedType(Type genericType)
Description copied from interface:JsonContext
Return true if the type is known as an Entity bean or a List Set or Map of entity beans.- Specified by:
isSupportedType
in interfaceJsonContext
-
createGenerator
public com.fasterxml.jackson.core.JsonGenerator createGenerator(Writer writer) throws JsonIOException
Description copied from interface:JsonContext
Create and return a new JsonGenerator for the given writer.- Specified by:
createGenerator
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
createParser
public com.fasterxml.jackson.core.JsonParser createParser(Reader reader) throws JsonIOException
Description copied from interface:JsonContext
Create and return a new JsonParser for the given reader.- Specified by:
createParser
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, String json) throws JsonIOException
Description copied from interface:JsonContext
Convert json string input into a Bean of a specific type.- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, String json, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json string input into a Bean of a specific type additionally using JsonReadOptions.- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, Reader jsonReader) throws JsonIOException
Description copied from interface:JsonContext
Convert json reader input into a Bean of a specific type.- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, Reader jsonReader, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json reader input into a Bean of a specific type additionally using JsonReadOptions.- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser) throws JsonIOException
Description copied from interface:JsonContext
Convert json parser input into a Bean of a specific type.- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toBean
public <T> T toBean(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json parser input into a Bean of a specific type additionally using JsonReadOptions..- Specified by:
toBean
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
createBeanReader
public <T> DJsonBeanReader<T> createBeanReader(Class<T> cls, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Create and return a new bean reading for the bean type given the JSON options and source.Note that JsonOption provides an option for setting a persistence context and also enabling further lazy loading. Further lazy loading requires a persistence context so if that is set on then a persistence context is created if there is not one set.
- Specified by:
createBeanReader
in interfaceJsonContext
- Throws:
JsonIOException
-
createBeanReader
public <T> DJsonBeanReader<T> createBeanReader(BeanType<T> beanType, com.fasterxml.jackson.core.JsonParser parser, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Create and return a new bean reading for the bean type given the JSON options and source.Note that JsonOption provides an option for setting a persistence context and also enabling further lazy loading. Further lazy loading requires a persistence context so if that is set on then a persistence context is created if there is not one set.
- Specified by:
createBeanReader
in interfaceJsonContext
- Throws:
JsonIOException
-
toList
public <T> List<T> toList(Class<T> cls, String json) throws JsonIOException
Description copied from interface:JsonContext
Convert json string input into a list of beans of a specific type.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toList
public <T> List<T> toList(Class<T> cls, String json, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json string input into a list of beans of a specific type additionally using JsonReadOptions.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toList
public <T> List<T> toList(Class<T> cls, Reader jsonReader) throws JsonIOException
Description copied from interface:JsonContext
Convert json reader input into a list of beans of a specific type.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toList
public <T> List<T> toList(Class<T> cls, Reader jsonReader, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json reader input into a list of beans of a specific type additionally using JsonReadOptions.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toList
public <T> List<T> toList(Class<T> cls, com.fasterxml.jackson.core.JsonParser src) throws JsonIOException
Description copied from interface:JsonContext
Convert json parser input into a list of beans of a specific type.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toList
public <T> List<T> toList(Class<T> cls, com.fasterxml.jackson.core.JsonParser src, JsonReadOptions options) throws JsonIOException
Description copied from interface:JsonContext
Convert json parser input into a list of beans of a specific type additionally using JsonReadOptions.- Specified by:
toList
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toObject
public Object toObject(Type genericType, String json) throws JsonIOException
Description copied from interface:JsonContext
Use the genericType to determine if this should be converted into a List or bean.- Specified by:
toObject
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toObject
public Object toObject(Type genericType, Reader json) throws JsonIOException
Description copied from interface:JsonContext
Use the genericType to determine if this should be converted into a List or bean.- Specified by:
toObject
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toObject
public Object toObject(Type genericType, com.fasterxml.jackson.core.JsonParser jsonParser) throws JsonIOException
Description copied from interface:JsonContext
Use the genericType to determine if this should be converted into a List or bean.- Specified by:
toObject
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public void toJson(Object value, com.fasterxml.jackson.core.JsonGenerator generator) throws JsonIOException
Description copied from interface:JsonContext
Write the bean or collection to the JsonGenerator.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public void toJson(Object value, com.fasterxml.jackson.core.JsonGenerator generator, FetchPath fetchPath) throws JsonIOException
Description copied from interface:JsonContext
Write the bean or collection to the JsonGenerator using the FetchPath.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
-
toJson
public void toJson(Object o, com.fasterxml.jackson.core.JsonGenerator generator, JsonWriteOptions options) throws JsonIOException
Description copied from interface:JsonContext
Deprecated in favour of using PathProperties by itself. Write json to the JsonGenerator using the JsonWriteOptions.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
-
toJson
public void toJson(Object o, Writer writer) throws JsonIOException
Description copied from interface:JsonContext
Write the bean or collection in JSON format to the writer.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public String toJson(Object value, FetchPath fetchPath) throws JsonIOException
Description copied from interface:JsonContext
Return the bean or collection as JSON string using FetchPath.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public void toJson(Object o, Writer writer, FetchPath fetchPath) throws JsonIOException
Description copied from interface:JsonContext
Write the bean or collection as json to the writer using the FetchPath.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
-
toJson
public void toJson(Object o, Writer writer, JsonWriteOptions options) throws JsonIOException
Description copied from interface:JsonContext
Deprecated in favour of using PathProperties by itself. With additional options.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJsonPretty
public String toJsonPretty(Object value) throws JsonIOException
Description copied from interface:JsonContext
Return the bean or collection as JSON string in pretty format.- Specified by:
toJsonPretty
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public String toJson(Object o) throws JsonIOException
Description copied from interface:JsonContext
Return the bean or collection as JSON string.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
toJson
public String toJson(Object o, JsonWriteOptions options) throws JsonIOException
Description copied from interface:JsonContext
Deprecated in favour of using PathProperties by itself. Convert a bean or collection to json string.- Specified by:
toJson
in interfaceJsonContext
- Throws:
JsonIOException
- When IOException occurs
-
createJsonRead
public SpiJsonReader createJsonRead(BeanType<?> beanType, String json)
Description copied from interface:SpiJsonContext
Create a Json Reader for reading the JSON content.- Specified by:
createJsonRead
in interfaceSpiJsonContext
-
createJsonWriter
public SpiJsonWriter createJsonWriter(Writer writer)
Description copied from interface:SpiJsonContext
Create a Json Writer for writing beans as JSON supplying a writer.- Specified by:
createJsonWriter
in interfaceSpiJsonContext
-
createJsonWriter
public SpiJsonWriter createJsonWriter(com.fasterxml.jackson.core.JsonGenerator gen, JsonWriteOptions options)
Description copied from interface:SpiJsonContext
Create a Json Writer for writing beans as JSON.- Specified by:
createJsonWriter
in interfaceSpiJsonContext
-
-