Enum StreamWriteFeature
- java.lang.Object
-
- java.lang.Enum<StreamWriteFeature>
-
- com.fasterxml.jackson.core.StreamWriteFeature
-
- All Implemented Interfaces:
JacksonFeature
,java.io.Serializable
,java.lang.Comparable<StreamWriteFeature>
public enum StreamWriteFeature extends java.lang.Enum<StreamWriteFeature> implements JacksonFeature
Token writer (generator) features not-specific to any particular format backend. Eventual replacement for non-JSON-specificJsonGenerator.Feature
s.- Since:
- 2.10
-
-
Enum Constant Summary
Enum Constants Enum Constant Description AUTO_CLOSE_CONTENT
Feature that determines what happens when the generator is closed while there are still unmatchedJsonToken.START_ARRAY
orJsonToken.START_OBJECT
entries in output content.AUTO_CLOSE_TARGET
Feature that determines whether generator will automatically close underlying output target that is NOT owned by the generator.FLUSH_PASSED_TO_STREAM
Feature that specifies that calls toJsonGenerator.flush()
will cause matchingflush()
to underlyingOutputStream
orWriter
; if disabled this will not be done.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.STRICT_DUPLICATE_DETECTION
Feature that determines whetherJsonGenerator
will explicitly check that no duplicate JSON Object field names are written.WRITE_BIGDECIMAL_AS_PLAIN
Feature that determines whetherBigDecimal
entries are serialized usingBigDecimal.toPlainString()
to prevent values to be written using scientific notation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default.boolean
enabledByDefault()
Accessor for checking whether this feature is enabled by default.boolean
enabledIn(int flags)
Convenience method for checking whether feature is enabled in given bitmask.int
getMask()
Returns bit mask for this feature instance; must be a single bit, that is of form1 << N
.JsonGenerator.Feature
mappedFeature()
static StreamWriteFeature
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static StreamWriteFeature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
AUTO_CLOSE_TARGET
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 underlyingOutputStream
andWriter
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 toJsonGenerator.close()
.Feature is enabled by default.
-
AUTO_CLOSE_CONTENT
public static final StreamWriteFeature AUTO_CLOSE_CONTENT
Feature that determines what happens when the generator is closed while there are still unmatchedJsonToken.START_ARRAY
orJsonToken.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.
-
FLUSH_PASSED_TO_STREAM
public static final StreamWriteFeature FLUSH_PASSED_TO_STREAM
Feature that specifies that calls toJsonGenerator.flush()
will cause matchingflush()
to underlyingOutputStream
orWriter
; 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 (likeObjectMapper
or third party libraries).Feature is enabled by default.
-
WRITE_BIGDECIMAL_AS_PLAIN
public static final StreamWriteFeature WRITE_BIGDECIMAL_AS_PLAIN
Feature that determines whetherBigDecimal
entries are serialized usingBigDecimal.toPlainString()
to prevent values to be written using scientific notation.NOTE: only affects generators that serialize
BigDecimal
s 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.
-
STRICT_DUPLICATE_DETECTION
public static final StreamWriteFeature STRICT_DUPLICATE_DETECTION
Feature that determines whetherJsonGenerator
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 aJsonGenerationException
; 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.
-
IGNORE_UNKNOWN
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, aJsonProcessingException
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
-
-
Method Detail
-
values
public static StreamWriteFeature[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (StreamWriteFeature c : StreamWriteFeature.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static StreamWriteFeature valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
collectDefaults
public static int collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default.- Returns:
- Bit mask of all features that are enabled by default
-
enabledByDefault
public boolean enabledByDefault()
Description copied from interface:JacksonFeature
Accessor for checking whether this feature is enabled by default.- Specified by:
enabledByDefault
in interfaceJacksonFeature
- Returns:
- Whether this instance is enabled by default or not
-
enabledIn
public boolean enabledIn(int flags)
Description copied from interface:JacksonFeature
Convenience method for checking whether feature is enabled in given bitmask.- Specified by:
enabledIn
in interfaceJacksonFeature
- Parameters:
flags
- Bit field that contains a set of enabled features of this type- Returns:
- True if this feature is enabled in passed bit field
-
getMask
public int getMask()
Description copied from interface:JacksonFeature
Returns bit mask for this feature instance; must be a single bit, that is of form1 << N
.- Specified by:
getMask
in interfaceJacksonFeature
- Returns:
- Bit mask of this feature
-
mappedFeature
public JsonGenerator.Feature mappedFeature()
-
-