Class CsvGenerator
java.lang.Object
com.fasterxml.jackson.core.JsonGenerator
com.fasterxml.jackson.core.base.GeneratorBase
com.fasterxml.jackson.dataformat.csv.CsvGenerator
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, Closeable, Flushable, AutoCloseable
public class CsvGenerator
extends com.fasterxml.jackson.core.base.GeneratorBase
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration that defines all togglable features for CSV writers (if any: currently none) -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBuilderAccumulated contents of an array cell, if anyprotected intAdditional counter that indicates number of value entries in the array.protected StringSeparator to use during writing of (simple) array value, to be encoded as a single column value, if any.protected com.fasterxml.jackson.core.io.CharacterEscapesprotected intBit flag composed of bits that indicate whichCsvGenerator.Features are enabled.protected booleanFlag that indicates that we need to write header line, if one is needed.protected intIndex of column that we will be getting next, based on field name call that was made.protected CsvSchemaDefinition of columns being written, if available.protected booleanFlag set when property to write is unknown, and the matching value is to be skipped quietly.protected SimpleTokenWriteContextWhen skipping output (for "unknown" output), outermost write context where skipping should occurprotected final com.fasterxml.jackson.core.StreamWriteConstraintsprotected SimpleTokenWriteContextCurrent context, in form we can use it (GeneratorBase has untyped reference; left as null)protected CsvEncoderprivate static final CsvSchemaprotected static final longprotected static final longFields inherited from class com.fasterxml.jackson.core.base.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 com.fasterxml.jackson.core.JsonGenerator
_cfgPrettyPrinter, DEFAULT_BINARY_WRITE_CAPABILITIES, DEFAULT_TEXTUAL_WRITE_CAPABILITIES, DEFAULT_WRITE_CAPABILITIES -
Constructor Summary
ConstructorsConstructorDescriptionCsvGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int jsonFeatures, int csvFeatures, com.fasterxml.jackson.core.ObjectCodec codec, CsvEncoder csvWriter) CsvGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int jsonFeatures, int csvFeatures, com.fasterxml.jackson.core.ObjectCodec codec, Writer out, CsvSchema schema) -
Method Summary
Modifier and TypeMethodDescriptionprotected void_addToArray(char[] value) protected void_addToArray(String value) protected final intprotected voidprotected voidprotected voidMethod called when there is a problem related to mapping data (compared to a low-level generation); if so, should be surfaced asprotected final void_verifyValueWrite(String typeMsg) private final void_writeFieldName(String name) booleanbooleancanUseSchema(com.fasterxml.jackson.core.FormatSchema schema) booleanvoidclose()configure(CsvGenerator.Feature f, boolean state) protected voidMethod called when the current row is complete; typically will flush possibly buffered column values, append linefeed and reset state appropriately.final voidflush()com.fasterxml.jackson.core.io.CharacterEscapesintintNOTE: while this method will return some information on amount of data buffered, it may be an incomplete view as some buffering happens at a higher level, as not-yet-serialized values.com.fasterxml.jackson.core.util.JacksonFeatureSet<com.fasterxml.jackson.core.StreamWriteCapability> final booleancom.fasterxml.jackson.core.JsonGeneratoroverrideFormatFeatures(int values, int mask) com.fasterxml.jackson.core.JsonGeneratorsetCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) setPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp) No way (or need) to indent anything, so let's block any attempts.voidsetSchema(com.fasterxml.jackson.core.FormatSchema schema) com.fasterxml.jackson.core.StreamWriteConstraintsNo way (or need) to indent anything, so let's block any attempts.com.fasterxml.jackson.core.Versionversion()voidwriteBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) voidwriteBoolean(boolean state) final voidfinal voidfinal voidwriteFieldName(com.fasterxml.jackson.core.SerializableString name) final voidwriteFieldName(String name) voidvoidwriteNumber(double v) voidwriteNumber(float v) voidwriteNumber(int v) voidwriteNumber(long v) voidwriteNumber(String encodedValue) voidvoidvoidwriteOmittedField(String fieldName) voidwriteRaw(char c) voidwriteRaw(char[] text, int offset, int len) voidvoidvoidwriteRawUTF8String(byte[] text, int offset, int len) voidwriteRawValue(char[] text, int offset, int len) voidwriteRawValue(String text) voidwriteRawValue(String text, int offset, int len) final voidfinal voidvoidwriteString(char[] text, int offset, int len) final voidwriteString(com.fasterxml.jackson.core.SerializableString sstr) voidwriteString(String text) voidwriteUTF8String(byte[] text, int offset, int len) Methods inherited from class com.fasterxml.jackson.core.base.GeneratorBase
_asString, _checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _checkRangeBoundsForString, _checkStdFeatureChanges, _constructDefaultPrettyPrinter, _decodeSurrogate, assignCurrentValue, currentValue, disable, enable, getCodec, getFeatureMask, ioContext, isClosed, isEnabled, overrideStdFeatures, setCodec, setFeatureMask, writeBinary, writeObject, writeRawValue, writeStartObject, writeTreeMethods inherited from class com.fasterxml.jackson.core.JsonGenerator
_constructWriteException, _constructWriteException, _constructWriteException, _constructWriteException, _copyCurrentContents, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportError, _reportUnsupportedOperation, _reportUnsupportedOperation, _throwInternal, _verifyOffsets, _writeSimpleObject, canWriteBinaryNatively, canWriteObjectId, canWriteTypeId, configure, copyCurrentEvent, copyCurrentEventExact, copyCurrentStructure, getCurrentValue, getHighestEscapedChar, getPrettyPrinter, getSchema, isEnabled, setCurrentValue, setHighestNonEscapedChar, setRootValueSeparator, writeArray, writeArray, writeArray, writeArray, writeArrayFieldStart, writeBinary, writeBinary, writeBinary, writeBinaryField, writeBooleanField, writeEmbeddedObject, writeFieldId, writeNullField, writeNumber, writeNumber, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeNumberField, writeObjectField, writeObjectFieldStart, writeObjectId, writeObjectRef, writePOJO, writePOJOField, writeRaw, writeStartArray, writeStartArray, writeStartArray, writeStartObject, writeString, writeStringField, writeTypeId, writeTypePrefix, writeTypeSuffix
-
Field Details
-
MIN_INT_AS_LONG
protected static final long MIN_INT_AS_LONG- See Also:
-
MAX_INT_AS_LONG
protected static final long MAX_INT_AS_LONG- See Also:
-
EMPTY_SCHEMA
-
_streamWriteConstraints
protected final com.fasterxml.jackson.core.StreamWriteConstraints _streamWriteConstraints- Since:
- 2.16
-
_formatFeatures
protected int _formatFeaturesBit flag composed of bits that indicate whichCsvGenerator.Features are enabled. -
_schema
Definition of columns being written, if available. -
_writer
-
_tokenWriteContext
Current context, in form we can use it (GeneratorBase has untyped reference; left as null)- Since:
- 2.11
-
_characterEscapes
protected com.fasterxml.jackson.core.io.CharacterEscapes _characterEscapes -
_handleFirstLine
protected boolean _handleFirstLineFlag that indicates that we need to write header line, if one is needed. Used because schema may be specified after instance is constructed. -
_nextColumnByName
protected int _nextColumnByNameIndex of column that we will be getting next, based on field name call that was made. -
_skipValue
protected boolean _skipValueFlag set when property to write is unknown, and the matching value is to be skipped quietly.- Since:
- 2.5
-
_arraySeparator
Separator to use during writing of (simple) array value, to be encoded as a single column value, if any.- Since:
- 2.5
-
_arrayContents
Accumulated contents of an array cell, if any -
_arrayElements
protected int _arrayElementsAdditional counter that indicates number of value entries in the array. Needed because `null` entries do not add content, but need to be separated by array cell separator- Since:
- 2.7
-
_skipWithin
When skipping output (for "unknown" output), outermost write context where skipping should occur- Since:
- 2.7
-
-
Constructor Details
-
CsvGenerator
-
CsvGenerator
public CsvGenerator(com.fasterxml.jackson.core.io.IOContext ctxt, int jsonFeatures, int csvFeatures, com.fasterxml.jackson.core.ObjectCodec codec, CsvEncoder csvWriter)
-
-
Method Details
-
version
public com.fasterxml.jackson.core.Version version()- Specified by:
versionin interfacecom.fasterxml.jackson.core.Versioned- Overrides:
versionin classcom.fasterxml.jackson.core.base.GeneratorBase
-
useDefaultPrettyPrinter
No way (or need) to indent anything, so let's block any attempts. (should we throw an exception instead?)- Overrides:
useDefaultPrettyPrinterin classcom.fasterxml.jackson.core.base.GeneratorBase
-
setPrettyPrinter
No way (or need) to indent anything, so let's block any attempts. (should we throw an exception instead?)- Overrides:
setPrettyPrinterin classcom.fasterxml.jackson.core.JsonGenerator
-
getOutputTarget
- Overrides:
getOutputTargetin classcom.fasterxml.jackson.core.JsonGenerator
-
getOutputBuffered
public int getOutputBuffered()NOTE: while this method will return some information on amount of data buffered, it may be an incomplete view as some buffering happens at a higher level, as not-yet-serialized values.- Overrides:
getOutputBufferedin classcom.fasterxml.jackson.core.JsonGenerator
-
getOutputContext
- Overrides:
getOutputContextin classcom.fasterxml.jackson.core.base.GeneratorBase
-
setSchema
public void setSchema(com.fasterxml.jackson.core.FormatSchema schema) - Overrides:
setSchemain classcom.fasterxml.jackson.core.JsonGenerator
-
getFormatFeatures
public int getFormatFeatures()- Overrides:
getFormatFeaturesin classcom.fasterxml.jackson.core.JsonGenerator
-
overrideFormatFeatures
public com.fasterxml.jackson.core.JsonGenerator overrideFormatFeatures(int values, int mask) - Overrides:
overrideFormatFeaturesin classcom.fasterxml.jackson.core.JsonGenerator
-
setCharacterEscapes
public com.fasterxml.jackson.core.JsonGenerator setCharacterEscapes(com.fasterxml.jackson.core.io.CharacterEscapes esc) - Overrides:
setCharacterEscapesin classcom.fasterxml.jackson.core.JsonGenerator
-
getCharacterEscapes
public com.fasterxml.jackson.core.io.CharacterEscapes getCharacterEscapes()- Overrides:
getCharacterEscapesin classcom.fasterxml.jackson.core.JsonGenerator
-
canUseSchema
public boolean canUseSchema(com.fasterxml.jackson.core.FormatSchema schema) - Overrides:
canUseSchemain classcom.fasterxml.jackson.core.JsonGenerator
-
canOmitFields
public boolean canOmitFields()- Overrides:
canOmitFieldsin classcom.fasterxml.jackson.core.JsonGenerator
-
canWriteFormattedNumbers
public boolean canWriteFormattedNumbers()- Overrides:
canWriteFormattedNumbersin classcom.fasterxml.jackson.core.JsonGenerator
-
getWriteCapabilities
public com.fasterxml.jackson.core.util.JacksonFeatureSet<com.fasterxml.jackson.core.StreamWriteCapability> getWriteCapabilities()- Overrides:
getWriteCapabilitiesin classcom.fasterxml.jackson.core.JsonGenerator
-
writeFieldName
- Specified by:
writeFieldNamein classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeFieldName
public final void writeFieldName(com.fasterxml.jackson.core.SerializableString name) throws IOException - Overrides:
writeFieldNamein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
_writeFieldName
- Throws:
IOException
-
isEnabled
-
configure
-
enable
-
disable
-
streamWriteConstraints
public com.fasterxml.jackson.core.StreamWriteConstraints streamWriteConstraints()- Overrides:
streamWriteConstraintsin classcom.fasterxml.jackson.core.JsonGenerator
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeStartArray
- Specified by:
writeStartArrayin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeEndArray
- Specified by:
writeEndArrayin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeStartObject
- Specified by:
writeStartObjectin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeEndObject
- Specified by:
writeEndObjectin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeString
- Specified by:
writeStringin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeString
- Specified by:
writeStringin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeString
public final void writeString(com.fasterxml.jackson.core.SerializableString sstr) throws IOException - Overrides:
writeStringin classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeRawUTF8String
- Specified by:
writeRawUTF8Stringin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeUTF8String
- Specified by:
writeUTF8Stringin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeRawValue
- Overrides:
writeRawValuein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
writeBinary
public void writeBinary(com.fasterxml.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) throws IOException, com.fasterxml.jackson.core.JsonGenerationException - Specified by:
writeBinaryin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOExceptioncom.fasterxml.jackson.core.JsonGenerationException
-
writeBoolean
- Specified by:
writeBooleanin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNull
- Specified by:
writeNullin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeNumber
- Specified by:
writeNumberin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
writeOmittedField
- Overrides:
writeOmittedFieldin classcom.fasterxml.jackson.core.JsonGenerator- Throws:
IOException
-
_verifyValueWrite
- Specified by:
_verifyValueWritein classcom.fasterxml.jackson.core.base.GeneratorBase- Throws:
IOException
-
_releaseBuffers
protected void _releaseBuffers()- Specified by:
_releaseBuffersin classcom.fasterxml.jackson.core.base.GeneratorBase
-
_reportMappingError
Method called when there is a problem related to mapping data (compared to a low-level generation); if so, should be surfaced as- Throws:
IOException- Since:
- 2.7
-
_columnIndex
protected final int _columnIndex() -
finishRow
Method called when the current row is complete; typically will flush possibly buffered column values, append linefeed and reset state appropriately.- Throws:
IOException
-
_handleFirstLine
- Throws:
IOException
-
_addToArray
-
_addToArray
protected void _addToArray(char[] value)
-