Package com.fasterxml.jackson.core.json
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,java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
UTF8JsonGenerator,WriterBasedJsonGenerator
public abstract class JsonGeneratorImpl extends GeneratorBase
Intermediate base class shared by JSON-backed generators likeUTF8JsonGeneratorandWriterBasedJsonGenerator.- Since:
- 2.1
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.core.JsonGenerator
JsonGenerator.Feature
-
-
Field Summary
-
Fields inherited from class com.fasterxml.jackson.core.base.GeneratorBase
SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST
-
-
Constructor Summary
Constructors Constructor Description JsonGeneratorImpl(IOContext ctxt, int features, ObjectCodec codec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonGeneratordisable(JsonGenerator.Feature f)Method for disabling specified features (checkJsonGenerator.Featurefor list of features)JsonGeneratorenable(JsonGenerator.Feature f)Method for enabling specified parser features: checkJsonGenerator.Featurefor list of available features.CharacterEscapesgetCharacterEscapes()Method for accessing custom escapes factory uses forJsonGenerators it creates.intgetHighestEscapedChar()Accessor method for testing what is the highest unescaped character configured for this generator.JsonGeneratorsetCharacterEscapes(CharacterEscapes esc)Method for defining custom escapes factory uses forJsonGenerators it creates.JsonGeneratorsetHighestNonEscapedChar(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).JsonGeneratorsetRootValueSeparator(SerializableString sep)Method that allows overriding String used for separating root-level JSON values (default is single space character)Versionversion()Implemented with standard version number detection algorithm, typically using a simple generated class, with information extracted from Maven project file during build.voidwriteStringField(java.lang.String fieldName, java.lang.String value)Convenience method for outputting a field entry ("member") that has a String value.-
Methods inherited from class com.fasterxml.jackson.core.base.GeneratorBase
close, flush, getCodec, getCurrentValue, getFeatureMask, getOutputContext, isClosed, isEnabled, overrideStdFeatures, setCodec, setCurrentValue, setFeatureMask, useDefaultPrettyPrinter, writeBinary, writeFieldName, writeObject, writeRawValue, writeRawValue, writeRawValue, writeRawValue, writeStartObject, writeString, writeTree
-
Methods inherited from class com.fasterxml.jackson.core.JsonGenerator
canOmitFields, canUseSchema, canWriteBinaryNatively, canWriteFormattedNumbers, canWriteObjectId, canWriteTypeId, configure, copyCurrentEvent, copyCurrentStructure, getFormatFeatures, getOutputBuffered, getOutputTarget, getPrettyPrinter, getSchema, isEnabled, overrideFormatFeatures, setPrettyPrinter, setSchema, 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, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writeOmittedField, writeRaw, writeRaw, writeRaw, writeRaw, writeRaw, writeRawUTF8String, writeStartArray, writeStartArray, writeStartArray, writeStartArray, writeStartObject, writeStartObject, writeString, writeString, writeString, writeTypeId, writeTypePrefix, writeTypeSuffix, writeUTF8String
-
-
-
-
Constructor Detail
-
JsonGeneratorImpl
public JsonGeneratorImpl(IOContext ctxt, int features, ObjectCodec codec)
-
-
Method Detail
-
version
public Version 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
-
enable
public JsonGenerator enable(JsonGenerator.Feature f)
Description copied from class:JsonGeneratorMethod for enabling specified parser features: checkJsonGenerator.Featurefor list of available features.- Overrides:
enablein classGeneratorBase- Returns:
- Generator itself (this), to allow chaining
-
disable
public JsonGenerator disable(JsonGenerator.Feature f)
Description copied from class:JsonGeneratorMethod for disabling specified features (checkJsonGenerator.Featurefor list of features)- Overrides:
disablein classGeneratorBase- Returns:
- Generator itself (this), to allow chaining
-
setHighestNonEscapedChar
public JsonGenerator setHighestNonEscapedChar(int charCode)
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.
-
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
public JsonGenerator setCharacterEscapes(CharacterEscapes esc)
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
-
getCharacterEscapes
public CharacterEscapes getCharacterEscapes()
Method for accessing custom escapes factory uses forJsonGenerators it creates.- Overrides:
getCharacterEscapesin classJsonGenerator
-
setRootValueSeparator
public JsonGenerator setRootValueSeparator(SerializableString sep)
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
-
writeStringField
public final void writeStringField(java.lang.String fieldName, java.lang.String value) throws java.io.IOExceptionDescription copied from class:JsonGeneratorConvenience method for outputting a field entry ("member") that has a String value. Equivalent to:writeFieldName(fieldName); writeString(value);
Note: many performance-sensitive implementations override this method
- Overrides:
writeStringFieldin classJsonGenerator- Throws:
java.io.IOException
-
-