Top Description Fields Constructors Methods
com.fasterxml.jackson.core

public final Enum StreamWriteFeature

extends Enum<StreamWriteFeature>
implements JacksonFeature
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.util.JacksonFeature
Imports
java.io.OutputStream, .Writer, java.math.BigDecimal, com.fasterxml.jackson.core.util.JacksonFeature

Token writer (generator) features not-specific to any particular format backend. Eventual replacement for non-JSON-specific com.fasterxml.jackson.core.JsonGenerator.Features.
Since
2.10

Field Summary

Modifier and TypeField and Description
private final boolean
_defaultState

Whether feature is enabled or disabled by default.

private final JsonGenerator.Feature
_mappedFeature

For backwards compatibility we may need to map to one of existing JsonParser.Features; if so, this is the feature to enable/disable.

private final int
public static final StreamWriteFeature
AUTO_CLOSE_CONTENT

Feature that determines what happens when the generator is closed while there are still unmatched JsonToken#START_ARRAY or JsonToken#START_OBJECT entries in output content.

public static final StreamWriteFeature
AUTO_CLOSE_TARGET

Feature that determines whether generator will automatically close underlying output target that is NOT owned by the generator.

public static final StreamWriteFeature
FLUSH_PASSED_TO_STREAM

Feature that specifies that calls to JsonGenerator#flush will cause matching flush() to underlying OutputStream or Writer; if disabled this will not be done.

public static final StreamWriteFeature
IGNORE_UNKNOWN

Feature that determines what to do if the underlying data format requires knowledge of all properties to output, and if no definition is found for a property that caller tries to write.

public static final StreamWriteFeature
STRICT_DUPLICATE_DETECTION

Feature that determines whether JsonGenerator will explicitly check that no duplicate JSON Object field names are written.

public static final StreamWriteFeature
USE_FAST_DOUBLE_WRITER

Feature that determines whether to use standard Java code to write floats/doubles (default) or use the Schubfach algorithm which is faster.

public static final StreamWriteFeature
WRITE_BIGDECIMAL_AS_PLAIN

Feature that determines whether java.math.BigDecimal entries are serialized using java.math.BigDecimal#toPlainString() to prevent values to be written using scientific notation.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

Bit mask of all features that are enabled by default
collectDefaults
()

Method that calculates bit set (flags) of all features that are enabled by default.

public boolean
enabledByDefault()

Implements com.fasterxml.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.
public boolean
enabledIn(int
Bit field that contains a set of enabled features of this type
flags
)

Implements com.fasterxml.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.
public int
getMask()

Implements com.fasterxml.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.
public JsonGenerator.Feature
public static StreamWriteFeature
public static StreamWriteFeature[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

_defaultStateback to summary
private final boolean _defaultState

Whether feature is enabled or disabled by default.

_mappedFeatureback to summary
private final JsonGenerator.Feature _mappedFeature

For backwards compatibility we may need to map to one of existing JsonParser.Features; if so, this is the feature to enable/disable.

_maskback to summary
private final int _mask
AUTO_CLOSE_CONTENTback to summary
public static final StreamWriteFeature AUTO_CLOSE_CONTENT

Feature that determines what happens when the generator is closed while there are still unmatched JsonToken#START_ARRAY or JsonToken#START_OBJECT entries in output content. If enabled, such Array(s) and/or Object(s) are automatically closed (that is, matching END_ token write call is made for all open scopes); if disabled, no additional write calls are made.

Feature is enabled by default.

AUTO_CLOSE_TARGETback to summary
public static final StreamWriteFeature AUTO_CLOSE_TARGET

Feature that determines whether generator will automatically close underlying output target that is NOT owned by the generator. If disabled, calling application has to separately close the underlying OutputStream and Writer instances used to create the generator. If enabled, generator will handle closing, as long as generator itself gets closed: this happens when end-of-input is encountered, or generator is closed by a call to JsonGenerator#close.

Feature is enabled by default.

FLUSH_PASSED_TO_STREAMback to summary
public static final StreamWriteFeature FLUSH_PASSED_TO_STREAM

Feature that specifies that calls to JsonGenerator#flush will cause matching flush() to underlying OutputStream or Writer; if disabled this will not be done. Main reason to disable this feature is to prevent flushing at generator level, if it is not possible to prevent method being called by other code (like ObjectMapper or third party libraries).

Feature is enabled by default.

IGNORE_UNKNOWNback to summary
public static final StreamWriteFeature IGNORE_UNKNOWN

Feature that determines what to do if the underlying data format requires knowledge of all properties to output, and if no definition is found for a property that caller tries to write. If enabled, such properties will be quietly ignored; if disabled, a JsonProcessingException will be thrown to indicate the problem. Typically most textual data formats do NOT require schema information (although some do, such as CSV), whereas many binary data formats do require definitions (such as Avro, protobuf), although not all (Smile, CBOR, BSON and MessagePack do not).

Note that support for this feature is implemented by individual data format module, if (and only if) it makes sense for the format in question. For JSON, for example, this feature has no effect as properties need not be pre-defined.

Feature is disabled by default, meaning that if the underlying data format requires knowledge of all properties to output, attempts to write an unknown property will result in a JsonProcessingException

STRICT_DUPLICATE_DETECTIONback to summary
public static final StreamWriteFeature STRICT_DUPLICATE_DETECTION

Feature that determines whether JsonGenerator will explicitly check that no duplicate JSON Object field names are written. If enabled, generator will check all names within context and report duplicates by throwing a JsonGenerationException; if disabled, no such checking will be done. Assumption in latter case is that caller takes care of not trying to write duplicate names.

Note that enabling this feature will incur performance overhead due to having to store and check additional information.

Feature is disabled by default.

USE_FAST_DOUBLE_WRITERback to summary
public static final StreamWriteFeature USE_FAST_DOUBLE_WRITER

Feature that determines whether to use standard Java code to write floats/doubles (default) or use the Schubfach algorithm which is faster. The latter approach may lead to small differences in the precision of the float/double that is written to the JSON output.

Feature is disabled by default, meaning that slower JDK default conversions are used.

Annotations
@SuppressWarnings:deprecation
Since
2.14
WRITE_BIGDECIMAL_AS_PLAINback to summary
public static final StreamWriteFeature WRITE_BIGDECIMAL_AS_PLAIN

Feature that determines whether java.math.BigDecimal entries are serialized using java.math.BigDecimal#toPlainString() to prevent values to be written using scientific notation.

Note

only affects generators that serialize java.math.BigDecimals using textual representation (textual formats but potentially some binary formats).

Feature is disabled by default, so default output mode is used; this generally depends on how BigDecimal has been created.

Constructor Detail

StreamWriteFeatureback to summary
private StreamWriteFeature(JsonGenerator.Feature mappedTo)

Method Detail

collectDefaultsback to summary
public static int collectDefaults()

Method that calculates bit set (flags) of all features that are enabled by default.

Returns:int

Bit mask of all features that are enabled by default

enabledByDefaultback to summary
public boolean enabledByDefault()

Implements com.fasterxml.jackson.core.util.JacksonFeature.enabledByDefault.

Doc from com.fasterxml.jackson.core.util.JacksonFeature.enabledByDefault.

Accessor for checking whether this feature is enabled by default.

Returns:boolean

Whether this instance is enabled by default or not

Annotations
@Override
enabledInback to summary
public boolean enabledIn(int flags)

Implements com.fasterxml.jackson.core.util.JacksonFeature.enabledIn.

Doc from com.fasterxml.jackson.core.util.JacksonFeature.enabledIn.

Convenience method for checking whether feature is enabled in given bitmask.

Parameters
flags:int

Bit field that contains a set of enabled features of this type

Returns:boolean

True if this feature is enabled in passed bit field

Annotations
@Override
getMaskback to summary
public int getMask()

Implements com.fasterxml.jackson.core.util.JacksonFeature.getMask.

Doc from com.fasterxml.jackson.core.util.JacksonFeature.getMask.

Returns bit mask for this feature instance; must be a single bit, that is of form 1 << N.

Returns:int

Bit mask of this feature

Annotations
@Override
mappedFeatureback to summary
public JsonGenerator.Feature mappedFeature()
valueOfback to summary
public static StreamWriteFeature valueOf(String name)
valuesback to summary
public static StreamWriteFeature[] values()