Class JSONPropertyWriter
java.lang.Object
org.nuxeo.ecm.automation.core.util.JSONPropertyWriter
Helper to marshaling properties into JSON.
- Since:
- 7.1
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected DateTimeFormat
The date time format.protected String
The baseUrl that can be used to locate blob content.protected String
The prefix to append to field name.protected boolean
Whether or not this writer write empty list or object.protected boolean
Whether or not this writer write null values. -
Constructor Summary
ModifierConstructorDescriptionprotected
Instantiate a JSONPropertyWriter.protected
JSONPropertyWriter
(JSONPropertyWriter writer) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic JSONPropertyWriter
create()
dateTimeFormat
(DateTimeFormat dateTimeFormat) filesBaseUrl
(String filesBaseUrl) protected void
writeBlobProperty
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) writeEmpty
(boolean writeEmpty) protected void
writeListProperty
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) protected void
writeMapProperty
(com.fasterxml.jackson.core.JsonGenerator jg, ComplexProperty prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) writeNull
(boolean writeNull) void
writeProperty
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop) Converts the value of the given core property to JSON.protected void
writeProperty
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) Converts the value of the given core property to JSON.static void
writePropertyValue
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, DateTimeFormat dateTimeFormat, String filesBaseUrl) Converts the value of the given core property to JSON.protected void
writeScalarProperty
(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter)
-
Field Details
-
dateTimeFormat
The date time format.- Since:
- 9.1
-
filesBaseUrl
The baseUrl that can be used to locate blob content.- Since:
- 9.1
-
prefix
The prefix to append to field name.- Since:
- 9.1
-
writeNull
protected boolean writeNullWhether or not this writer write null values.- Since:
- 9.1
-
writeEmpty
protected boolean writeEmptyWhether or not this writer write empty list or object.- Since:
- 9.1
-
-
Constructor Details
-
JSONPropertyWriter
protected JSONPropertyWriter()Instantiate a JSONPropertyWriter. -
JSONPropertyWriter
Copy constructor.- Since:
- 9.1
-
-
Method Details
-
create
- Returns:
- a
JSONPropertyWriter
instance withDateTimeFormat.W3C
as date time formatter. - Since:
- 9.1
-
dateTimeFormat
- Returns:
- this
JSONPropertyWriter
filled with the previous configuration and the input dateTimeFormat. - Since:
- 9.1
-
filesBaseUrl
- Parameters:
filesBaseUrl
- the baseUrl that can be used to locate blob content- Returns:
- this
JSONPropertyWriter
filled with the previous configuration and the input filesBaseUrl. - Since:
- 9.1
-
prefix
- Parameters:
prefix
- the prefix to append for each property- Returns:
- this
JSONPropertyWriter
filled with the previous configuration and the input prefix. - Since:
- 9.1
-
writeNull
- Parameters:
writeNull
- whether or not this writer might write null values- Returns:
- this
JSONPropertyWriter
filled with the previous configuration and the input writeNull value. - Since:
- 9.1
-
writeEmpty
- Parameters:
writeEmpty
- whether or not this writer might write empty array/list/object- Returns:
- this
JSONPropertyWriter
filled with the previous configuration and the input writeEmpty value. - Since:
- 9.1
-
writeProperty
public void writeProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop) throws PropertyException, IOException Converts the value of the given core property to JSON.- Throws:
PropertyException
IOException
- Since:
- 9.1
- Implementation Note:
- CAUTION: this method will write the field name to
JsonGenerator
with its prefix without writing the start and the end of object.
-
writeProperty
protected void writeProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException Converts the value of the given core property to JSON.- Parameters:
fieldNameWriter
- the field name writer is used to write the field name depending on writer configuration, this parameter also allows us to handle different cases: field with prefix, field under complex property, or nothing for arrays and lists- Throws:
PropertyException
IOException
-
writeScalarProperty
protected void writeScalarProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyException
IOException
-
writeListProperty
protected void writeListProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyException
IOException
-
writeMapProperty
protected void writeMapProperty(com.fasterxml.jackson.core.JsonGenerator jg, ComplexProperty prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyException
IOException
-
writeBlobProperty
protected void writeBlobProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyException
IOException
-
writePropertyValue
public static void writePropertyValue(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, DateTimeFormat dateTimeFormat, String filesBaseUrl) throws PropertyException, IOException Converts the value of the given core property to JSON. The given filesBaseUrl is the baseUrl that can be used to locate blob content and is useful to generate blob URLs.- Throws:
PropertyException
IOException
-