Package com.fasterxml.jackson.jr.ob.impl
Class JSONWriter
- java.lang.Object
-
- com.fasterxml.jackson.jr.ob.impl.JSONWriter
-
public class JSONWriter extends java.lang.Object
Object that handles serialization of simple Objects into underlying data format (usually JSON). UnlikeJSONReader
, writer does actually implement write methods itself and uses delegation for only some special cases.Life-cycle is such that initial instance (called blueprint) is constructed first (including possible configuration using mutant factory methods). This blueprint object acts as a factory, and is never used for direct writing; instead, per-call instance is created by calling
perOperationInstance(int, com.fasterxml.jackson.jr.ob.impl.ValueWriterLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonGenerator)
.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_features
protected com.fasterxml.jackson.core.JsonGenerator
_generator
protected java.util.TimeZone
_timezone
protected com.fasterxml.jackson.core.TreeCodec
_treeCodec
protected boolean
_writeNullValues
protected ValueWriterLocator
_writerLocator
Object that is used to dynamically find Bean (and custom type) value writers
-
Constructor Summary
Constructors Modifier Constructor Description JSONWriter()
Constructor used for creating differently configured blueprint instancesprotected
JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g)
Constructor for non-blueprint instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkUnknown(java.lang.Object value)
protected void
_writeValue(java.lang.Object value, int type)
protected java.lang.String
dateToString(java.util.Date v)
boolean
isEnabled(JSON.Feature f)
protected java.lang.String
keyToString(java.lang.Object rawKey)
JSONWriter
perOperationInstance(int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g)
JSONWriter
withCacheCheck(int features)
void
writeBeanValue(BeanPropertyWriter[] props, java.lang.Object bean)
protected void
writeBigDecimalField(java.lang.String fieldName, java.math.BigDecimal v)
protected void
writeBigDecimalValue(java.math.BigDecimal v)
protected void
writeBigIntegerField(java.lang.String fieldName, java.math.BigInteger v)
protected void
writeBigIntegerValue(java.math.BigInteger v)
protected void
writeBinaryField(java.lang.String fieldName, byte[] data)
protected void
writeBinaryValue(byte[] data)
protected void
writeBooleanArrayField(java.lang.String fieldName, boolean[] v)
protected void
writeBooleanArrayValue(boolean[] v)
protected void
writeBooleanField(java.lang.String fieldName, boolean v)
protected void
writeBooleanValue(boolean v)
protected void
writeCollectionField(java.lang.String fieldName, java.util.Collection<?> v)
protected void
writeCollectionValue(java.util.Collection<?> v)
protected void
writeDateField(java.lang.String fieldName, java.util.Date v)
protected void
writeDateValue(java.util.Date v)
protected void
writeDoubleField(java.lang.String fieldName, double v)
protected void
writeDoubleValue(double v)
protected void
writeEnumField(java.lang.String fieldName, java.lang.Enum<?> v)
protected void
writeEnumValue(java.lang.Enum<?> v)
void
writeField(java.lang.String fieldName, java.lang.Object value, int type)
protected void
writeIntArrayField(java.lang.String fieldName, int[] v)
protected void
writeIntArrayValue(int[] v)
protected void
writeIntField(java.lang.String fieldName, int v)
protected void
writeIntValue(int v)
protected void
writeIterableField(java.lang.String fieldName, java.lang.Iterable<?> v)
protected void
writeIterableValue(java.lang.Iterable<?> v)
protected void
writeListField(java.lang.String fieldName, java.util.List<?> v)
protected void
writeListValue(java.util.List<?> list)
protected void
writeLongArrayField(java.lang.String fieldName, long[] v)
protected void
writeLongArrayValue(long[] v)
protected void
writeLongField(java.lang.String fieldName, long v)
protected void
writeLongValue(long v)
protected void
writeMapField(java.lang.String fieldName, java.util.Map<?,?> v)
protected void
writeMapValue(java.util.Map<?,?> v)
protected void
writeNullField(com.fasterxml.jackson.core.io.SerializedString fieldName)
protected void
writeNullField(java.lang.String fieldName)
protected void
writeNullValue()
protected void
writeObjectArrayField(java.lang.String fieldName, java.lang.Object[] v)
protected void
writeObjectArrayValue(java.lang.Object[] v)
protected void
writeStringField(java.lang.String fieldName, java.lang.String v)
protected void
writeStringLikeField(java.lang.String fieldName, java.lang.String v, int actualType)
protected void
writeStringLikeValue(java.lang.String v, int actualType)
protected void
writeStringValue(java.lang.String v)
protected void
writeTreeNodeField(java.lang.String fieldName, com.fasterxml.jackson.core.TreeNode v)
protected void
writeTreeNodeValue(com.fasterxml.jackson.core.TreeNode v)
protected void
writeUnknownField(java.lang.String fieldName, java.lang.Object data)
protected void
writeUnknownValue(java.lang.Object data)
void
writeValue(java.lang.Object value)
Main entry point for non-blueprint instances: called for the root value to write it out.
-
-
-
Field Detail
-
_treeCodec
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
-
_writerLocator
protected final ValueWriterLocator _writerLocator
Object that is used to dynamically find Bean (and custom type) value writers
-
_generator
protected final com.fasterxml.jackson.core.JsonGenerator _generator
-
_timezone
protected final java.util.TimeZone _timezone
-
_features
protected final int _features
-
_writeNullValues
protected final boolean _writeNullValues
-
-
Constructor Detail
-
JSONWriter
public JSONWriter()
Constructor used for creating differently configured blueprint instances
-
JSONWriter
protected JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g)
Constructor for non-blueprint instances.- Parameters:
base
- Blueprint instance to base settings of the new instance onfeatures
- Active features for the write operationloc
- Helper object to use for dynamically located value writerstc
- TreeCodec to use for writing tree values, if anyg
- Underlying streaming encoder to use
-
-
Method Detail
-
withCacheCheck
public JSONWriter withCacheCheck(int features)
-
perOperationInstance
public JSONWriter perOperationInstance(int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g)
-
isEnabled
public boolean isEnabled(JSON.Feature f)
- Since:
- 2.11
-
writeValue
public void writeValue(java.lang.Object value) throws java.io.IOException
Main entry point for non-blueprint instances: called for the root value to write it out.- Throws:
java.io.IOException
-
writeField
public void writeField(java.lang.String fieldName, java.lang.Object value, int type) throws java.io.IOException
- Throws:
java.io.IOException
-
_writeValue
protected void _writeValue(java.lang.Object value, int type) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCollectionValue
protected void writeCollectionValue(java.util.Collection<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCollectionField
protected void writeCollectionField(java.lang.String fieldName, java.util.Collection<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIterableValue
protected void writeIterableValue(java.lang.Iterable<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIterableField
protected void writeIterableField(java.lang.String fieldName, java.lang.Iterable<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeListValue
protected void writeListValue(java.util.List<?> list) throws java.io.IOException
- Throws:
java.io.IOException
-
writeListField
protected void writeListField(java.lang.String fieldName, java.util.List<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeMapValue
protected void writeMapValue(java.util.Map<?,?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeMapField
protected void writeMapField(java.lang.String fieldName, java.util.Map<?,?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeObjectArrayValue
protected void writeObjectArrayValue(java.lang.Object[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeObjectArrayField
protected void writeObjectArrayField(java.lang.String fieldName, java.lang.Object[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIntArrayValue
protected void writeIntArrayValue(int[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIntArrayField
protected void writeIntArrayField(java.lang.String fieldName, int[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeLongArrayValue
protected void writeLongArrayValue(long[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeLongArrayField
protected void writeLongArrayField(java.lang.String fieldName, long[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBooleanArrayValue
protected void writeBooleanArrayValue(boolean[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBooleanArrayField
protected void writeBooleanArrayField(java.lang.String fieldName, boolean[] v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTreeNodeValue
protected void writeTreeNodeValue(com.fasterxml.jackson.core.TreeNode v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTreeNodeField
protected void writeTreeNodeField(java.lang.String fieldName, com.fasterxml.jackson.core.TreeNode v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBooleanValue
protected void writeBooleanValue(boolean v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBooleanField
protected void writeBooleanField(java.lang.String fieldName, boolean v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIntValue
protected void writeIntValue(int v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeIntField
protected void writeIntField(java.lang.String fieldName, int v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeLongValue
protected void writeLongValue(long v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBigIntegerValue
protected void writeBigIntegerValue(java.math.BigInteger v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBigIntegerField
protected void writeBigIntegerField(java.lang.String fieldName, java.math.BigInteger v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeLongField
protected void writeLongField(java.lang.String fieldName, long v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDoubleValue
protected void writeDoubleValue(double v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDoubleField
protected void writeDoubleField(java.lang.String fieldName, double v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBigDecimalValue
protected void writeBigDecimalValue(java.math.BigDecimal v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBigDecimalField
protected void writeBigDecimalField(java.lang.String fieldName, java.math.BigDecimal v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringValue
protected void writeStringValue(java.lang.String v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringField
protected void writeStringField(java.lang.String fieldName, java.lang.String v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringLikeValue
protected void writeStringLikeValue(java.lang.String v, int actualType) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringLikeField
protected void writeStringLikeField(java.lang.String fieldName, java.lang.String v, int actualType) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBinaryValue
protected void writeBinaryValue(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBinaryField
protected void writeBinaryField(java.lang.String fieldName, byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
writeNullValue
protected void writeNullValue() throws java.io.IOException
- Throws:
java.io.IOException
-
writeNullField
protected void writeNullField(java.lang.String fieldName) throws java.io.IOException
- Throws:
java.io.IOException
-
writeNullField
protected void writeNullField(com.fasterxml.jackson.core.io.SerializedString fieldName) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDateValue
protected void writeDateValue(java.util.Date v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeDateField
protected void writeDateField(java.lang.String fieldName, java.util.Date v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEnumValue
protected void writeEnumValue(java.lang.Enum<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEnumField
protected void writeEnumField(java.lang.String fieldName, java.lang.Enum<?> v) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBeanValue
public void writeBeanValue(BeanPropertyWriter[] props, java.lang.Object bean) throws java.io.IOException
- Throws:
java.io.IOException
-
writeUnknownValue
protected void writeUnknownValue(java.lang.Object data) throws java.io.IOException
- Throws:
java.io.IOException
-
writeUnknownField
protected void writeUnknownField(java.lang.String fieldName, java.lang.Object data) throws java.io.IOException
- Throws:
java.io.IOException
-
_checkUnknown
protected void _checkUnknown(java.lang.Object value) throws java.io.IOException
- Throws:
java.io.IOException
-
keyToString
protected java.lang.String keyToString(java.lang.Object rawKey)
-
dateToString
protected java.lang.String dateToString(java.util.Date v)
- Since:
- 2.7
-
-