Enum Class CBORWriteFeature

java.lang.Object
java.lang.Enum<CBORWriteFeature>
tools.jackson.dataformat.cbor.CBORWriteFeature
All Implemented Interfaces:
Serializable, Comparable<CBORWriteFeature>, Constable, tools.jackson.core.FormatFeature, tools.jackson.core.util.JacksonFeature

public enum CBORWriteFeature extends Enum<CBORWriteFeature> implements tools.jackson.core.FormatFeature
Enumeration that defines all togglable features for CBOR generator.

NOTE: in Jackson 2.x this was named CBORGenerator.Feature.

  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Feature that determines how binary tagged negative BigInteger values are encoded: either using CBOR standard encoding logic (as per spec), or using legacy Jackson encoding logic (encoding up to Jackson 2.19).
    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.
    Feature that determines if string references are generated based on the stringref) extension.
    Feature that determines whether generator should try to write doubles as floats: if true, will write a double as a 4-byte float if no precision loss will occur; if false, will always write a double as an 8-byte double.
    Feature that determines whether generator should try to use smallest (size-wise) integer representation: if true, will use smallest representation that is enough to retain value; if false, will use length indicated by argument type (4-byte for int, 8-byte for long and so on).
    Feature that determines whether CBOR "Self-Describe Tag" (value 55799, encoded as 3-byte sequence of 0xD9, 0xD9, 0xF7) should be written at the beginning of document or not.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
     
    private final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    CBORWriteFeature(boolean defaultState)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Method that calculates bit set (flags) of all features that are enabled by default.
    boolean
     
    boolean
    enabledIn(int flags)
     
    int
     
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • WRITE_MINIMAL_INTS

      public static final CBORWriteFeature WRITE_MINIMAL_INTS
      Feature that determines whether generator should try to use smallest (size-wise) integer representation: if true, will use smallest representation that is enough to retain value; if false, will use length indicated by argument type (4-byte for int, 8-byte for long and so on).

      Default value is true meaning that minimal representation is used when encoding.

    • WRITE_TYPE_HEADER

      public static final CBORWriteFeature WRITE_TYPE_HEADER
      Feature that determines whether CBOR "Self-Describe Tag" (value 55799, encoded as 3-byte sequence of 0xD9, 0xD9, 0xF7) should be written at the beginning of document or not.

      Default value is false meaning that type tag will not be written at the beginning of a new document.

    • LENIENT_UTF_ENCODING

      public static final CBORWriteFeature 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 (StreamWriteException).

    • STRINGREF

      public static final CBORWriteFeature STRINGREF
      Feature that determines if string references are generated based on the stringref) extension. This can save storage space, parsing time, and pool string memory when parsing. Readers of the output must also support the stringref extension to properly decode the data. Extra overhead may be added to generation time and memory usage to compute the shared binary and text strings.

      Default value is false meaning that the stringref extension will not be used.

    • WRITE_MINIMAL_DOUBLES

      public static final CBORWriteFeature WRITE_MINIMAL_DOUBLES
      Feature that determines whether generator should try to write doubles as floats: if true, will write a double as a 4-byte float if no precision loss will occur; if false, will always write a double as an 8-byte double.

      Default value is false meaning that doubles will always be written as 8-byte values.

    • ENCODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING

      public static final CBORWriteFeature ENCODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING
      Feature that determines how binary tagged negative BigInteger values are encoded: either using CBOR standard encoding logic (as per spec), or using legacy Jackson encoding logic (encoding up to Jackson 2.19). When enabled, uses CBOR standard specified encoding of negative values (e.g., -1 is encoded [0xC3, 0x41, 0x00]). When disabled, maintains behavior of versions prior to 3.0. (e.g., -1 is encoded [0xC3, 0x41, 0x01]) and uses legacy Jackson encoding.

      Note that there is the counterpart CBORReadFeature.DECODE_USING_STANDARD_NEGATIVE_BIGINT_ENCODING for encoding.

      The default value is true in Jackson 3.x (was false in Jackson 2.x).

  • Field Details

    • _defaultState

      private final boolean _defaultState
    • _mask

      private final int _mask
  • Constructor Details

    • CBORWriteFeature

      private CBORWriteFeature(boolean defaultState)
  • Method Details

    • values

      public static CBORWriteFeature[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CBORWriteFeature valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      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 interface tools.jackson.core.util.JacksonFeature
    • enabledIn

      public boolean enabledIn(int flags)
      Specified by:
      enabledIn in interface tools.jackson.core.util.JacksonFeature
    • getMask

      public int getMask()
      Specified by:
      getMask in interface tools.jackson.core.util.JacksonFeature