/** * Method that calculates bit set (flags) of all features that * are enabled by default. */ public static int collectDefaults() { int flags = 0; for (JsonWriteFeature f : values()) { if (f.enabledByDefault()) { flags |= f.getMask(); } } return flags; }
private JsonWriteFeature(boolean defaultState) { _defaultState = defaultState; _mask = (1 << ordinal()); }
/** * Check whether specified generator feature is enabled. */ public final boolean isEnabled(JsonWriteFeature f) { return (_formatWriteFeatures & f.getMask()) != 0; }
public JsonGeneratorImpl(ObjectWriteContext writeCtxt, IOContext ctxt, int streamWriteFeatures, int formatWriteFeatures, SerializableString rvs, CharacterEscapes charEsc, PrettyPrinter pp, int maxNonEscaped) { super(writeCtxt, streamWriteFeatures); _ioContext = ctxt; _formatWriteFeatures = formatWriteFeatures; // By default we use this feature to determine additional quoting if (JsonWriteFeature.ESCAPE_NON_ASCII.enabledIn(formatWriteFeatures)) { // note! Lowest effective value is 127 (0 is used as marker, but values // from 1 through 126 have no effect different from 127), so: maxNonEscaped = 127; } _maximumNonEscapedChar = maxNonEscaped; _cfgUnqNames = !JsonWriteFeature.QUOTE_FIELD_NAMES.enabledIn(formatWriteFeatures); _rootValueSeparator = rvs; _cfgPrettyPrinter = pp; // 03-Oct-2017, tatu: Not clean (shouldn't call non-static methods from ctor), // but for now best way to avoid code duplication setCharacterEscapes(charEsc); }
@Override public void writeNumber(double d) throws IOException { if (_cfgNumbersAsStrings || (JsonWriteFeature.WRITE_NAN_AS_STRINGS.enabledIn(_formatWriteFeatures) && ((Double.isNaN(d) || Double.isInfinite(d))))) { writeString(String.valueOf(d)); return; } // What is the max length for doubles? 40 chars? _verifyValueWrite(WRITE_NUMBER); writeRaw(String.valueOf(d)); }
@Override public void writeNumber(float f) throws IOException { if (_cfgNumbersAsStrings || (JsonWriteFeature.WRITE_NAN_AS_STRINGS.enabledIn(_formatWriteFeatures) && ((Float.isNaN(f) || Float.isInfinite(f))))) { writeString(String.valueOf(f)); return; } // What is the max length for floats? _verifyValueWrite(WRITE_NUMBER); writeRaw(String.valueOf(f)); }
public JsonFactoryBuilder disable(JsonWriteFeature f) { _formatWriteFeatures &= ~f.getMask(); return this; }
@Override public void writeNumber(double d) throws IOException { if (_cfgNumbersAsStrings || (((Double.isNaN(d) || Double.isInfinite(d)) && JsonWriteFeature.WRITE_NAN_AS_STRINGS.enabledIn(_formatWriteFeatures)))) { writeString(String.valueOf(d)); return; } // What is the max length for doubles? 40 chars? _verifyValueWrite(WRITE_NUMBER); writeRaw(String.valueOf(d)); }
public JsonFactoryBuilder enable(JsonWriteFeature f) { _formatWriteFeatures |= f.getMask(); return this; }
@Override public void writeNumber(float f) throws IOException { if (_cfgNumbersAsStrings || // [JACKSON-139] (((Float.isNaN(f) || Float.isInfinite(f)) && JsonWriteFeature.WRITE_NAN_AS_STRINGS.enabledIn(_formatWriteFeatures)))) { writeString(String.valueOf(f)); return; } // What is the max length for floats? _verifyValueWrite(WRITE_NUMBER); writeRaw(String.valueOf(f)); }