public class JSONWriter extends Object
JSONReader
, 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)
.
Modifier and Type | Field and Description |
---|---|
protected int |
_features |
protected JsonGenerator |
_generator |
protected TimeZone |
_timezone |
protected TreeCodec |
_treeCodec |
protected boolean |
_writeNullValues |
protected ValueWriterLocator |
_writerLocator
Object that is used to dynamically find Bean (and custom type) value writers
|
Modifier | Constructor and Description |
---|---|
|
JSONWriter()
Constructor used for creating differently configured blueprint
instances
|
protected |
JSONWriter(JSONWriter base,
int features,
ValueWriterLocator loc,
TreeCodec tc,
JsonGenerator g)
Constructor for non-blueprint instances.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkUnknown(Object value) |
protected void |
_writeValue(Object value,
int type) |
protected String |
dateToString(Date v) |
boolean |
isEnabled(JSON.Feature f) |
protected String |
keyToString(Object rawKey) |
JSONWriter |
perOperationInstance(int features,
ValueWriterLocator loc,
TreeCodec tc,
JsonGenerator g) |
JSONWriter |
withCacheCheck(int features) |
void |
writeBeanValue(BeanPropertyWriter[] props,
Object bean) |
protected void |
writeBigDecimalField(String fieldName,
BigDecimal v) |
protected void |
writeBigDecimalValue(BigDecimal v) |
protected void |
writeBigIntegerField(String fieldName,
BigInteger v) |
protected void |
writeBigIntegerValue(BigInteger v) |
protected void |
writeBinaryField(String fieldName,
byte[] data) |
protected void |
writeBinaryValue(byte[] data) |
protected void |
writeBooleanArrayField(String fieldName,
boolean[] v) |
protected void |
writeBooleanArrayValue(boolean[] v) |
protected void |
writeBooleanField(String fieldName,
boolean v) |
protected void |
writeBooleanValue(boolean v) |
protected void |
writeCollectionField(String fieldName,
Collection<?> v) |
protected void |
writeCollectionValue(Collection<?> v) |
protected void |
writeDateField(String fieldName,
Date v) |
protected void |
writeDateValue(Date v) |
protected void |
writeDoubleField(String fieldName,
double v) |
protected void |
writeDoubleValue(double v) |
protected void |
writeEnumField(String fieldName,
Enum<?> v) |
protected void |
writeEnumValue(Enum<?> v) |
void |
writeField(String fieldName,
Object value,
int type) |
protected void |
writeIntArrayField(String fieldName,
int[] v) |
protected void |
writeIntArrayValue(int[] v) |
protected void |
writeIntField(String fieldName,
int v) |
protected void |
writeIntValue(int v) |
protected void |
writeIterableField(String fieldName,
Iterable<?> v) |
protected void |
writeIterableValue(Iterable<?> v) |
protected void |
writeListField(String fieldName,
List<?> v) |
protected void |
writeListValue(List<?> list) |
protected void |
writeLongArrayField(String fieldName,
long[] v) |
protected void |
writeLongArrayValue(long[] v) |
protected void |
writeLongField(String fieldName,
long v) |
protected void |
writeLongValue(long v) |
protected void |
writeMapField(String fieldName,
Map<?,?> v) |
protected void |
writeMapValue(Map<?,?> v) |
protected void |
writeNullField(SerializedString fieldName) |
protected void |
writeNullField(String fieldName) |
protected void |
writeNullValue() |
protected void |
writeObjectArrayField(String fieldName,
Object[] v) |
protected void |
writeObjectArrayValue(Object[] v) |
protected void |
writeStringField(String fieldName,
String v) |
protected void |
writeStringLikeField(String fieldName,
String v,
int actualType) |
protected void |
writeStringLikeValue(String v,
int actualType) |
protected void |
writeStringValue(String v) |
protected void |
writeTreeNodeField(String fieldName,
TreeNode v) |
protected void |
writeTreeNodeValue(TreeNode v) |
protected void |
writeUnknownField(String fieldName,
Object data) |
protected void |
writeUnknownValue(Object data) |
void |
writeValue(Object value)
Main entry point for non-blueprint instances: called for the root value to
write it out.
|
protected final TreeCodec _treeCodec
protected final ValueWriterLocator _writerLocator
protected final JsonGenerator _generator
protected final TimeZone _timezone
protected final int _features
protected final boolean _writeNullValues
public JSONWriter()
protected JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)
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 usepublic JSONWriter withCacheCheck(int features)
public JSONWriter perOperationInstance(int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)
public boolean isEnabled(JSON.Feature f)
public void writeValue(Object value) throws IOException
IOException
public void writeField(String fieldName, Object value, int type) throws IOException
IOException
protected void _writeValue(Object value, int type) throws IOException
IOException
protected void writeCollectionValue(Collection<?> v) throws IOException
IOException
protected void writeCollectionField(String fieldName, Collection<?> v) throws IOException
IOException
protected void writeIterableValue(Iterable<?> v) throws IOException
IOException
protected void writeIterableField(String fieldName, Iterable<?> v) throws IOException
IOException
protected void writeListValue(List<?> list) throws IOException
IOException
protected void writeListField(String fieldName, List<?> v) throws IOException
IOException
protected void writeMapValue(Map<?,?> v) throws IOException
IOException
protected void writeMapField(String fieldName, Map<?,?> v) throws IOException
IOException
protected void writeObjectArrayValue(Object[] v) throws IOException
IOException
protected void writeObjectArrayField(String fieldName, Object[] v) throws IOException
IOException
protected void writeIntArrayValue(int[] v) throws IOException
IOException
protected void writeIntArrayField(String fieldName, int[] v) throws IOException
IOException
protected void writeLongArrayValue(long[] v) throws IOException
IOException
protected void writeLongArrayField(String fieldName, long[] v) throws IOException
IOException
protected void writeBooleanArrayValue(boolean[] v) throws IOException
IOException
protected void writeBooleanArrayField(String fieldName, boolean[] v) throws IOException
IOException
protected void writeTreeNodeValue(TreeNode v) throws IOException
IOException
protected void writeTreeNodeField(String fieldName, TreeNode v) throws IOException
IOException
protected void writeBooleanValue(boolean v) throws IOException
IOException
protected void writeBooleanField(String fieldName, boolean v) throws IOException
IOException
protected void writeIntValue(int v) throws IOException
IOException
protected void writeIntField(String fieldName, int v) throws IOException
IOException
protected void writeLongValue(long v) throws IOException
IOException
protected void writeBigIntegerValue(BigInteger v) throws IOException
IOException
protected void writeBigIntegerField(String fieldName, BigInteger v) throws IOException
IOException
protected void writeLongField(String fieldName, long v) throws IOException
IOException
protected void writeDoubleValue(double v) throws IOException
IOException
protected void writeDoubleField(String fieldName, double v) throws IOException
IOException
protected void writeBigDecimalValue(BigDecimal v) throws IOException
IOException
protected void writeBigDecimalField(String fieldName, BigDecimal v) throws IOException
IOException
protected void writeStringValue(String v) throws IOException
IOException
protected void writeStringField(String fieldName, String v) throws IOException
IOException
protected void writeStringLikeValue(String v, int actualType) throws IOException
IOException
protected void writeStringLikeField(String fieldName, String v, int actualType) throws IOException
IOException
protected void writeBinaryValue(byte[] data) throws IOException
IOException
protected void writeBinaryField(String fieldName, byte[] data) throws IOException
IOException
protected void writeNullValue() throws IOException
IOException
protected void writeNullField(String fieldName) throws IOException
IOException
protected void writeNullField(SerializedString fieldName) throws IOException
IOException
protected void writeDateValue(Date v) throws IOException
IOException
protected void writeDateField(String fieldName, Date v) throws IOException
IOException
protected void writeEnumValue(Enum<?> v) throws IOException
IOException
protected void writeEnumField(String fieldName, Enum<?> v) throws IOException
IOException
public void writeBeanValue(BeanPropertyWriter[] props, Object bean) throws IOException
IOException
protected void writeUnknownValue(Object data) throws IOException
IOException
protected void writeUnknownField(String fieldName, Object data) throws IOException
IOException
protected void _checkUnknown(Object value) throws IOException
IOException
Copyright © 2020 FasterXML. All rights reserved.