1 package com.fasterxml.jackson.core; 2 3 import com.fasterxml.jackson.core.util.JacksonFeature; 4 5 /** 6 * Set of on/off capabilities that a {@link JsonGenerator} for given format 7 * (or in case of buffering, original format) has. 8 * Used in some cases to adjust aspects of things like content conversions and 9 * coercions by format-agnostic functionality. 10 * Specific or expected usage documented by individual capability entry Javadocs. 11 * 12 * @since 2.12 13 */ 14 public enum StreamWriteCapability 15 implements JacksonFeature 16 { 17 /** 18 * Capability that indicates that the data format is able to express binary 19 * data natively, without using textual encoding like Base64. 20 *<p> 21 * Capability is currently enabled for all binary formats and none of textual 22 * formats. 23 */ 24 CAN_WRITE_BINARY_NATIVELY(false), 25 26 /** 27 * Capability that indicates that the data format is able to write 28 * "formatted numbers": that is, output of numbers is done as Strings 29 * and caller is allowed to pass in logical number values as Strings. 30 *<p> 31 * Capability is currently enabled for most textual formats and none of binary 32 * formats. 33 */ 34 CAN_WRITE_FORMATTED_NUMBERS(false) 35 ; 36 37 /** 38 * Whether feature is enabled or disabled by default. 39 */ 40 private final boolean _defaultState; 41 42 private final int _mask; 43 StreamWriteCapability(boolean defaultState)44 private StreamWriteCapability(boolean defaultState) { 45 _defaultState = defaultState; 46 _mask = (1 << ordinal()); 47 } 48 49 @Override enabledByDefault()50 public boolean enabledByDefault() { return _defaultState; } 51 @Override enabledIn(int flags)52 public boolean enabledIn(int flags) { return (flags & _mask) != 0; } 53 @Override getMask()54 public int getMask() { return _mask; } 55 } 56