Class JSONPropertyWriter
java.lang.Object
org.nuxeo.ecm.automation.core.util.JSONPropertyWriter
Helper to marshaling properties into JSON.
- Since:
- 7.1
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DateTimeFormatThe date time format.protected StringThe baseUrl that can be used to locate blob content.protected StringThe prefix to append to field name.protected booleanWhether or not this writer write empty list or object.protected booleanWhether or not this writer write null values. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate a JSONPropertyWriter.protectedJSONPropertyWriter(JSONPropertyWriter writer) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic JSONPropertyWritercreate()dateTimeFormat(DateTimeFormat dateTimeFormat) filesBaseUrl(String filesBaseUrl) protected voidwriteBlobProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) writeEmpty(boolean writeEmpty) protected voidwriteListProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) protected voidwriteMapProperty(com.fasterxml.jackson.core.JsonGenerator jg, ComplexProperty prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) writeNull(boolean writeNull) voidwriteProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop) Converts the value of the given core property to JSON.protected voidwriteProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) Converts the value of the given core property to JSON.static voidwritePropertyValue(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, DateTimeFormat dateTimeFormat, String filesBaseUrl) Converts the value of the given core property to JSON.protected voidwriteScalarProperty(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
JSONPropertyWriterinstance withDateTimeFormat.W3Cas date time formatter. - Since:
- 9.1
-
dateTimeFormat
- Returns:
- this
JSONPropertyWriterfilled 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
JSONPropertyWriterfilled with the previous configuration and the input filesBaseUrl. - Since:
- 9.1
-
prefix
- Parameters:
prefix- the prefix to append for each property- Returns:
- this
JSONPropertyWriterfilled 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
JSONPropertyWriterfilled 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
JSONPropertyWriterfilled 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:
PropertyExceptionIOException- Since:
- 9.1
- Implementation Note:
- CAUTION: this method will write the field name to
JsonGeneratorwith 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:
PropertyExceptionIOException
-
writeScalarProperty
protected void writeScalarProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyExceptionIOException
-
writeListProperty
protected void writeListProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyExceptionIOException
-
writeMapProperty
protected void writeMapProperty(com.fasterxml.jackson.core.JsonGenerator jg, ComplexProperty prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyExceptionIOException
-
writeBlobProperty
protected void writeBlobProperty(com.fasterxml.jackson.core.JsonGenerator jg, Property prop, JSONPropertyWriter.PropertyConsumer fieldNameWriter) throws PropertyException, IOException - Throws:
PropertyExceptionIOException
-
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:
PropertyExceptionIOException
-