Class JsonGeneratorImpl
java.lang.Object
com.fasterxml.jackson.core.JsonGenerator
com.fasterxml.jackson.core.base.GeneratorBase
com.fasterxml.jackson.core.json.JsonGeneratorImpl
- All Implemented Interfaces:
Versioned, Closeable, Flushable, AutoCloseable
- Direct Known Subclasses:
UTF8JsonGenerator, WriterBasedJsonGenerator
Intermediate base class shared by JSON-backed generators
like
UTF8JsonGenerator and WriterBasedJsonGenerator.- Since:
- 2.1
-
Nested Class Summary
Nested classes/interfaces inherited from class JsonGenerator
JsonGenerator.Feature -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag that is set if quoting is not to be added around JSON Object property names.protected booleanWrite Hex values with uppercase lettersprotected CharacterEscapesDefinition of custom character escapes to use for generators created by this factory, if any.protected intValue between 128 (0x80) and 65535 (0xFFFF) that indicates highest Unicode code point that will not need escaping; or 0 to indicate that all characters can be represented without escaping.protected int[]Currently active set of output escape code definitions (whether and how to escape or not) for 7-bit ASCII range (first 128 character codes).protected SerializableStringSeparator to use, if any, between root-level values.protected final StreamWriteConstraintsprotected static final JacksonFeatureSet<StreamWriteCapability> Default capabilities for JSON generator implementations which do not different from "general textual" defaultsprotected static final int[]This is the default set of escape codes, over 7-bit ASCII range (first 128 character codes), used for single-byte UTF-8 characters.Fields inherited from class GeneratorBase
_cfgNumbersAsStrings, _closed, _features, _ioContext, _objectCodec, _writeContext, DERIVED_FEATURES_MASK, MAX_BIG_DECIMAL_SCALE, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST, WRITE_BINARY, WRITE_BOOLEAN, WRITE_NULL, WRITE_NUMBER, WRITE_RAW, WRITE_STRINGFields inherited from class JsonGenerator
_cfgPrettyPrinter, DEFAULT_BINARY_WRITE_CAPABILITIES, DEFAULT_TEXTUAL_WRITE_CAPABILITIES, DEFAULT_WRITE_CAPABILITIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_checkStdFeatureChanges(int newFeatureFlags, int changedFeatures) Helper method called to verify changes to standard features.protected void_reportCantWriteValueExpectName(String typeMsg) protected void_verifyPrettyValueWrite(String typeMsg, int status) Method for disabling specified feature (checkJsonGenerator.Featurefor list of features)Method for enabling specified generator feature: checkJsonGenerator.Featurefor list of available features.Method for accessing custom escapes factory uses forJsonGenerators it creates.intAccessor method for testing what is the highest unescaped character configured for this generator.Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly).Method for defining custom escapes factory uses forJsonGenerators it creates.setHighestNonEscapedChar(int charCode) Method that can be called to request that generator escapes all character codes above specified code point (if positive value); or, to not escape any characters except for ones that must be escaped for the data format (if -1).Method that allows overriding String used for separating root-level JSON values (default is single space character)Get the constraints to apply when performing streaming writes.version()Implemented with standard version number detection algorithm, typically using a simple generated class, with information extracted from Maven project file during build.Methods inherited from class GeneratorBase
_asString, _checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _checkRangeBoundsForString, _constructDefaultPrettyPrinter, _decodeSurrogate, _releaseBuffers, _verifyValueWrite, assignCurrentValue, close, currentValue, flush, getCodec, getFeatureMask, getOutputContext, ioContext, isClosed, isEnabled, overrideStdFeatures, setCodec, setFeatureMask, useDefaultPrettyPrinter, writeBinary, writeFieldName, writeObject, writeRawValue, writeRawValue, writeRawValue, writeRawValue, writeStartObject, writeString, writeTreeMethods inherited from class JsonGenerator
_constructWriteException, _constructWriteException, _constructWriteException, _constructWriteException, _copyCurrentContents, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportError, _reportUnsupportedOperation, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, canOmitFields, canUseSchema, canWriteBinaryNatively, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, configure, copyCurrentEvent, copyCurrentEventExact, copyCurrentStructure, getCurrentValue, getFormatFeatures, getOutputBuffered, getOutputTarget, getPrettyPrinter, getSchema, isEnabled, overrideFormatFeatures, setCurrentValue, setPrettyPrinter, setSchema, writeArray, writeArray, writeArray, writeArray, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBoolean, writeBooleanField, writeEmbeddedObject, writeEndArray, writeEndObject, writeFieldId, writeFieldName, writeNull, writeNullField, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writeOmittedField, writePOJO, writePOJOField, writeRaw, writeRaw, writeRaw, writeRaw, writeRaw, writeRawUTF8String, writeStartArray, writeStartArray, writeStartArray, writeStartArray, writeStartObject, writeStartObject, writeString, writeString, writeString, writeStringField, writeTypeId, writeTypePrefix, writeTypeSuffix, writeUTF8String
-
Field Details
-
sOutputEscapes
protected static final int[] sOutputEscapesThis is the default set of escape codes, over 7-bit ASCII range (first 128 character codes), used for single-byte UTF-8 characters. -
JSON_WRITE_CAPABILITIES
Default capabilities for JSON generator implementations which do not different from "general textual" defaults- Since:
- 2.12
-
_streamWriteConstraints
- Since:
- 2.16
-
_outputEscapes
protected int[] _outputEscapesCurrently active set of output escape code definitions (whether and how to escape or not) for 7-bit ASCII range (first 128 character codes). Defined separately to make potentially customizable -
_maximumNonEscapedChar
protected int _maximumNonEscapedCharValue between 128 (0x80) and 65535 (0xFFFF) that indicates highest Unicode code point that will not need escaping; or 0 to indicate that all characters can be represented without escaping. Typically used to force escaping of some portion of character set; for example to always escape non-ASCII characters (if value was 127).NOTE: not all sub-classes make use of this setting.
-
_characterEscapes
Definition of custom character escapes to use for generators created by this factory, if any. If null, standard data format specific escapes are used. -
_rootValueSeparator
Separator to use, if any, between root-level values.- Since:
- 2.1
-
_cfgUnqNames
protected boolean _cfgUnqNamesFlag that is set if quoting is not to be added around JSON Object property names.- Since:
- 2.7
-
_cfgWriteHexUppercase
protected boolean _cfgWriteHexUppercaseWrite Hex values with uppercase letters- Since:
- 2.14
-
-
Constructor Details
-
JsonGeneratorImpl
-
-
Method Details
-
version
Description copied from class:GeneratorBaseImplemented with standard version number detection algorithm, typically using a simple generated class, with information extracted from Maven project file during build.- Specified by:
versionin interfaceVersioned- Overrides:
versionin classGeneratorBase- Returns:
- Version number of the generator (version of the jar that contains generator implementation class)
-
streamWriteConstraints
Description copied from class:JsonGeneratorGet the constraints to apply when performing streaming writes.- Overrides:
streamWriteConstraintsin classJsonGenerator
-
enable
Description copied from class:JsonGeneratorMethod for enabling specified generator feature: checkJsonGenerator.Featurefor list of available features.- Overrides:
enablein classGeneratorBase- Parameters:
f- Feature to enable- Returns:
- This generator, to allow call chaining
-
disable
Description copied from class:JsonGeneratorMethod for disabling specified feature (checkJsonGenerator.Featurefor list of features)- Overrides:
disablein classGeneratorBase- Parameters:
f- Feature to disable- Returns:
- This generator, to allow call chaining
-
_checkStdFeatureChanges
protected void _checkStdFeatureChanges(int newFeatureFlags, int changedFeatures) Description copied from class:GeneratorBaseHelper method called to verify changes to standard features.- Overrides:
_checkStdFeatureChangesin classGeneratorBase- Parameters:
newFeatureFlags- Bitflag of standard features after they were changedchangedFeatures- Bitflag of standard features for which setting did change
-
setHighestNonEscapedChar
Description copied from class:JsonGeneratorMethod that can be called to request that generator escapes all character codes above specified code point (if positive value); or, to not escape any characters except for ones that must be escaped for the data format (if -1). To force escaping of all non-ASCII characters, for example, this method would be called with value of 127.Note that generators are NOT required to support setting of value higher than 127, because there are other ways to affect quoting (or lack thereof) of character codes between 0 and 127. Not all generators support concept of escaping, either; if so, calling this method will have no effect.
Default implementation does nothing; sub-classes need to redefine it according to rules of supported data format.
- Overrides:
setHighestNonEscapedCharin classJsonGenerator- Parameters:
charCode- Either -1 to indicate that no additional escaping is to be done; or highest code point not to escape (meaning higher ones will be), if positive value.- Returns:
- This generator, to allow call chaining
-
getHighestEscapedChar
public int getHighestEscapedChar()Description copied from class:JsonGeneratorAccessor method for testing what is the highest unescaped character configured for this generator. This may be either positive value (when escaping configuration has been set and is in effect), or 0 to indicate that no additional escaping is in effect. Some generators may not support additional escaping: for example, generators for binary formats that do not use escaping should simply return 0.- Overrides:
getHighestEscapedCharin classJsonGenerator- Returns:
- Currently active limitation for highest non-escaped character, if defined; or 0 to indicate no additional escaping is performed.
-
setCharacterEscapes
Description copied from class:JsonGeneratorMethod for defining custom escapes factory uses forJsonGenerators it creates.Default implementation does nothing and simply returns this instance.
- Overrides:
setCharacterEscapesin classJsonGenerator- Parameters:
esc-CharacterEscapesto configure this generator to use, if any;nullif none- Returns:
- This generator, to allow call chaining
-
getCharacterEscapes
Method for accessing custom escapes factory uses forJsonGenerators it creates.- Overrides:
getCharacterEscapesin classJsonGenerator- Returns:
CharacterEscapesconfigured for this generator, if any;nullif none
-
setRootValueSeparator
Description copied from class:JsonGeneratorMethod that allows overriding String used for separating root-level JSON values (default is single space character)Default implementation throws
UnsupportedOperationException.- Overrides:
setRootValueSeparatorin classJsonGenerator- Parameters:
sep- Separator to use, if any; null means that no separator is automatically added- Returns:
- This generator, to allow call chaining
-
getWriteCapabilities
Description copied from class:JsonGeneratorAccessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly).- Overrides:
getWriteCapabilitiesin classJsonGenerator- Returns:
- Set of write capabilities for content written using this generator
-
_verifyPrettyValueWrite
- Throws:
IOException
-
_reportCantWriteValueExpectName
- Throws:
IOException
-