Enum SmileGenerator.Feature
- java.lang.Object
-
- java.lang.Enum<SmileGenerator.Feature>
-
- com.fasterxml.jackson.dataformat.smile.SmileGenerator.Feature
-
- All Implemented Interfaces:
com.fasterxml.jackson.core.FormatFeature
,com.fasterxml.jackson.core.util.JacksonFeature
,java.io.Serializable
,java.lang.Comparable<SmileGenerator.Feature>
- Enclosing class:
- SmileGenerator
public static enum SmileGenerator.Feature extends java.lang.Enum<SmileGenerator.Feature> implements com.fasterxml.jackson.core.FormatFeature
Enumeration that defines all togglable features for Smile generators.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CHECK_SHARED_NAMES
Whether generator should check if it can "share" field names during generating content or not.CHECK_SHARED_STRING_VALUES
Whether generator should check if it can "share" short (at most 64 bytes encoded) String value during generating content or not.ENCODE_BINARY_AS_7BIT
Whether to use simple 7-bit per byte encoding for binary content when output.LENIENT_UTF_ENCODING
Feature that determines if an invalid surrogate encoding found in the incoming String should fail with an exception or silently be output as the Unicode 'REPLACEMENT CHARACTER' (U+FFFD) or not; if not, an exception will be thrown to indicate invalid content.WRITE_END_MARKER
Whether write byte marker that signifies end of logical content segment (SmileConstants.BYTE_MARKER_END_OF_CONTENT
) whenSmileGenerator.close()
is called or not.WRITE_HEADER
Whether to write 4-byte header sequence when starting output or not.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_defaultState
protected int
_mask
-
Constructor Summary
Constructors Modifier Constructor Description private
Feature(boolean defaultState)
-
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()
boolean
enabledIn(int flags)
int
getMask()
static SmileGenerator.Feature
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static SmileGenerator.Feature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
WRITE_HEADER
public static final SmileGenerator.Feature WRITE_HEADER
Whether to write 4-byte header sequence when starting output or not. If disabled, no header is written; this may be useful in embedded cases where context is enough to know that content is encoded using this format. Note, however, that omitting header means that default settings for shared names/string values can not be changed.Default setting is true, meaning that header will be written.
-
WRITE_END_MARKER
public static final SmileGenerator.Feature WRITE_END_MARKER
Whether write byte marker that signifies end of logical content segment (SmileConstants.BYTE_MARKER_END_OF_CONTENT
) whenSmileGenerator.close()
is called or not. This can be useful when outputting multiple adjacent logical content segments (documents) into single physical output unit (file).Default setting is false meaning that such marker is not written.
-
ENCODE_BINARY_AS_7BIT
public static final SmileGenerator.Feature ENCODE_BINARY_AS_7BIT
Whether to use simple 7-bit per byte encoding for binary content when output. This is necessary ensure that byte 0xFF will never be included in content output. For other data types this limitation is handled automatically. This setting is enabled by default, however, overhead for binary data (14% size expansion, processing overhead) is non-negligible. If no binary data is output, feature has no effect.Default setting is true, indicating that binary data is quoted as 7-bit bytes instead of written raw.
-
CHECK_SHARED_NAMES
public static final SmileGenerator.Feature CHECK_SHARED_NAMES
Whether generator should check if it can "share" field names during generating content or not. If enabled, can replace repeating field names with back references, which are more compact and should faster to decode. Downside is that there is some overhead for writing (need to track existing values, check), as well as decoding.Since field names tend to repeat quite often, this setting is enabled by default.
-
CHECK_SHARED_STRING_VALUES
public static final SmileGenerator.Feature CHECK_SHARED_STRING_VALUES
Whether generator should check if it can "share" short (at most 64 bytes encoded) String value during generating content or not. If enabled, can replace repeating Short String values with back references, which are more compact and should faster to decode. Downside is that there is some overhead for writing (need to track existing values, check), as well as decoding.Since efficiency of this option depends a lot on type of content being produced, this option is disabled by default, and should only be enabled if it is likely that same values repeat relatively often.
-
LENIENT_UTF_ENCODING
public static final SmileGenerator.Feature LENIENT_UTF_ENCODING
Feature that determines if an invalid surrogate encoding found in the incoming String should fail with an exception or silently be output as the Unicode 'REPLACEMENT CHARACTER' (U+FFFD) or not; if not, an exception will be thrown to indicate invalid content.Default value is
false
(for backwards compatibility) meaning that an invalid surrogate will result in exception (IllegalArgumentException
- Since:
- 2.13
-
-
Method Detail
-
values
public static SmileGenerator.Feature[] 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 (SmileGenerator.Feature c : SmileGenerator.Feature.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SmileGenerator.Feature 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.
-
enabledByDefault
public boolean enabledByDefault()
- Specified by:
enabledByDefault
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
enabledByDefault
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
getMask
public int getMask()
- Specified by:
getMask
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
getMask
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
enabledIn
public boolean enabledIn(int flags)
- Specified by:
enabledIn
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
enabledIn
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
-