Class CsvGenerator

java.lang.Object
tools.jackson.core.JsonGenerator
tools.jackson.core.base.GeneratorBase
tools.jackson.dataformat.csv.CsvGenerator
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, tools.jackson.core.Versioned

public class CsvGenerator extends tools.jackson.core.base.GeneratorBase
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected StringBuilder
    Accumulated contents of an array cell, if any
    protected int
    Additional counter that indicates number of value entries in the array.
    protected String
    Separator to use during writing of (simple) array value, to be encoded as a single column value, if any.
    protected final int
    Bit flag composed of bits that indicate which CsvWriteFeatures are enabled.
    protected boolean
    Flag that indicates that we need to write header line, if one is needed.
    protected boolean
    Flag set when a row has just been finished, used to distinguish between null values within a row vs null rows.
    protected int
    Index of column that we will be getting next, based on the property name call that was made.
    Decorator to use for decorating the column value to follow, if any; null if none.
    protected final CsvSchema
    Definition of columns being written, if available.
    protected boolean
    Flag set when property to write is unknown, and the matching value is to be skipped quietly.
    protected tools.jackson.core.util.SimpleStreamWriteContext
    When skipping output (for "unknown" output), outermost write context where skipping should occur
    protected tools.jackson.core.util.SimpleStreamWriteContext
    Object that keeps track of the current contextual state of the generator.
    protected CsvEncoder
     
    private static final CsvSchema
     
    protected static final long
     
    protected static final long
     

    Fields inherited from class tools.jackson.core.base.GeneratorBase

    _closed, _ioContext, _objectWriteContext, _streamWriteConstraints, _streamWriteFeatures, DEFAULT_BINARY_WRITE_CAPABILITIES, DEFAULT_TEXTUAL_WRITE_CAPABILITIES, DEFAULT_WRITE_CAPABILITIES, MAX_BIG_DECIMAL_SCALE, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST, WRITE_BINARY, WRITE_BOOLEAN, WRITE_NULL, WRITE_NUMBER, WRITE_RAW, WRITE_STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
    CsvGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, int csvFeatures, Writer out, CsvSchema schema, CsvCharacterEscapes characterEscapes)
     
    CsvGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, int csvFeatures, CsvEncoder csvWriter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    _addToArray(char[] value)
     
    protected void
     
    protected void
     
    protected final int
     
    protected void
     
    protected void
     
    protected void
    Method called when there is a problem related to mapping data (compared to a low-level generation); if so, should be surfaced as
    protected final void
     
    private final void
     
    final void
     
    boolean
     
    void
     
    final Object
     
    protected void
    Method called when the current row is complete; typically will flush possibly buffered column values, append linefeed and reset state appropriately.
    final void
     
    tools.jackson.core.io.CharacterEscapes
     
    tools.jackson.core.PrettyPrinter
     
    final boolean
     
    setCharacterEscapes(tools.jackson.core.io.CharacterEscapes esc)
     
    tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability>
     
    final tools.jackson.core.TokenStreamContext
     
    int
    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.
     
    tools.jackson.core.Version
     
    tools.jackson.core.JsonGenerator
    writeBinary(tools.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeBoolean(boolean state)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeName(tools.jackson.core.SerializableString name)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeNumber(double v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(float v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(int v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(long v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(short v)
     
    tools.jackson.core.JsonGenerator
    writeNumber(String encodedValue)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writePropertyId(long id)
     
    tools.jackson.core.JsonGenerator
    writeRaw(char c)
     
    tools.jackson.core.JsonGenerator
    writeRaw(char[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeRaw(String text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeRawUTF8String(byte[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
    writeRawValue(char[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeRawValue(String text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeString(char[] text, int offset, int len)
     
    tools.jackson.core.JsonGenerator
     
    tools.jackson.core.JsonGenerator
    writeString(tools.jackson.core.SerializableString sstr)
     
    tools.jackson.core.JsonGenerator
    writeUTF8String(byte[] text, int offset, int len)
     

    Methods inherited from class tools.jackson.core.base.GeneratorBase

    _asString, _checkRangeBoundsForByteArray, _checkRangeBoundsForCharArray, _checkRangeBoundsForString, _constructDefaultPrettyPrinter, _decodeSurrogate, _throwInternal, configure, has, ioContext, isClosed, isEnabled, objectWriteContext, streamWriteConstraints, streamWriteFeatures, writeBinary, writePOJO, writeRawValue, writeStartArray, writeStartObject, writeString, writeTree

    Methods inherited from class tools.jackson.core.JsonGenerator

    _constructWriteException, _constructWriteException, _constructWriteException, _constructWriteException, _copyCurrentContents, _copyCurrentContentsExact, _copyCurrentFloatValue, _copyCurrentFloatValueExact, _copyCurrentIntValue, _copyCurrentStringValue, _reportArgumentError, _reportError, _reportUnsupportedOperation, _reportUnsupportedOperation, _verifyOffsets, _wrapIOFailure, _writeTypePrefixUsingNative, _writeTypePrefixUsingWrapper, canWriteObjectId, canWriteTypeId, copyCurrentEvent, copyCurrentEventExact, copyCurrentStructure, copyCurrentStructureExact, getHighestNonEscapedChar, getSchema, writeArray, writeArray, writeArray, writeArray, writeArrayPropertyStart, writeBinary, writeBinary, writeBinary, writeBinaryProperty, writeBooleanProperty, writeEmbeddedObject, writeNullProperty, writeNumber, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeNumberProperty, writeObjectId, writeObjectPropertyStart, writeObjectRef, writePOJOProperty, writeRaw, writeStringProperty, writeTypeId, writeTypePrefix, writeTypeSuffix

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      private static final CsvSchema EMPTY_SCHEMA
    • _formatFeatures

      protected final int _formatFeatures
      Bit flag composed of bits that indicate which CsvWriteFeatures are enabled.
    • _schema

      protected final CsvSchema _schema
      Definition of columns being written, if available.
    • _writer

      protected CsvEncoder _writer
    • _streamWriteContext

      protected tools.jackson.core.util.SimpleStreamWriteContext _streamWriteContext
      Object that keeps track of the current contextual state of the generator.
    • _handleFirstLine

      protected boolean _handleFirstLine
      Flag 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 _nextColumnByName
      Index of column that we will be getting next, based on the property name call that was made.
    • _nextColumnDecorator

      protected CsvValueDecorator _nextColumnDecorator
      Decorator to use for decorating the column value to follow, if any; null if none.
      Since:
      2.18
    • _skipValue

      protected boolean _skipValue
      Flag set when property to write is unknown, and the matching value is to be skipped quietly.
    • _justFinishedRow

      protected boolean _justFinishedRow
      Flag set when a row has just been finished, used to distinguish between null values within a row vs null rows. Only relevant for Array-wrapped rows.
      Since:
      2.21
    • _arraySeparator

      protected String _arraySeparator
      Separator to use during writing of (simple) array value, to be encoded as a single column value, if any.
    • _arrayContents

      protected StringBuilder _arrayContents
      Accumulated contents of an array cell, if any
    • _arrayElements

      protected int _arrayElements
      Additional 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
    • _skipWithin

      protected tools.jackson.core.util.SimpleStreamWriteContext _skipWithin
      When skipping output (for "unknown" output), outermost write context where skipping should occur
  • Constructor Details

    • CsvGenerator

      public CsvGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, int csvFeatures, Writer out, CsvSchema schema, CsvCharacterEscapes characterEscapes)
    • CsvGenerator

      public CsvGenerator(tools.jackson.core.ObjectWriteContext writeCtxt, tools.jackson.core.io.IOContext ioCtxt, int streamWriteFeatures, int csvFeatures, CsvEncoder csvWriter)
  • Method Details

    • version

      public tools.jackson.core.Version version()
      Specified by:
      version in interface tools.jackson.core.Versioned
      Specified by:
      version in class tools.jackson.core.JsonGenerator
    • streamWriteContext

      public final tools.jackson.core.TokenStreamContext streamWriteContext()
      Specified by:
      streamWriteContext in class tools.jackson.core.JsonGenerator
    • currentValue

      public final Object currentValue()
      Specified by:
      currentValue in class tools.jackson.core.JsonGenerator
    • assignCurrentValue

      public final void assignCurrentValue(Object v)
      Specified by:
      assignCurrentValue in class tools.jackson.core.JsonGenerator
    • streamWriteOutputTarget

      public Object streamWriteOutputTarget()
      Specified by:
      streamWriteOutputTarget in class tools.jackson.core.JsonGenerator
    • streamWriteOutputBuffered

      public int streamWriteOutputBuffered()
      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.
      Specified by:
      streamWriteOutputBuffered in class tools.jackson.core.JsonGenerator
    • setCharacterEscapes

      public CsvGenerator setCharacterEscapes(tools.jackson.core.io.CharacterEscapes esc)
      Overrides:
      setCharacterEscapes in class tools.jackson.core.JsonGenerator
    • getCharacterEscapes

      public tools.jackson.core.io.CharacterEscapes getCharacterEscapes()
      Overrides:
      getCharacterEscapes in class tools.jackson.core.JsonGenerator
    • getPrettyPrinter

      public tools.jackson.core.PrettyPrinter getPrettyPrinter()
      Overrides:
      getPrettyPrinter in class tools.jackson.core.JsonGenerator
    • canOmitProperties

      public boolean canOmitProperties()
      Overrides:
      canOmitProperties in class tools.jackson.core.JsonGenerator
    • streamWriteCapabilities

      public tools.jackson.core.util.JacksonFeatureSet<tools.jackson.core.StreamWriteCapability> streamWriteCapabilities()
      Specified by:
      streamWriteCapabilities in class tools.jackson.core.JsonGenerator
    • writeName

      public tools.jackson.core.JsonGenerator writeName(String name) throws tools.jackson.core.JacksonException
      Specified by:
      writeName in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writePropertyId

      public tools.jackson.core.JsonGenerator writePropertyId(long id) throws tools.jackson.core.JacksonException
      Specified by:
      writePropertyId in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeName

      public tools.jackson.core.JsonGenerator writeName(tools.jackson.core.SerializableString name) throws tools.jackson.core.JacksonException
      Overrides:
      writeName in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • _writeFieldName

      private final void _writeFieldName(String name) throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • isEnabled

      public final boolean isEnabled(CsvWriteFeature f)
    • flush

      public final void flush()
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class tools.jackson.core.JsonGenerator
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class tools.jackson.core.base.GeneratorBase
    • _closeInput

      protected void _closeInput() throws IOException
      Specified by:
      _closeInput in class tools.jackson.core.base.GeneratorBase
      Throws:
      IOException
    • writeStartArray

      public tools.jackson.core.JsonGenerator writeStartArray() throws tools.jackson.core.JacksonException
      Specified by:
      writeStartArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartArray

      public tools.jackson.core.JsonGenerator writeStartArray(Object currValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeStartArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeEndArray

      public tools.jackson.core.JsonGenerator writeEndArray() throws tools.jackson.core.JacksonException
      Specified by:
      writeEndArray in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartObject

      public tools.jackson.core.JsonGenerator writeStartObject() throws tools.jackson.core.JacksonException
      Specified by:
      writeStartObject in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeStartObject

      public tools.jackson.core.JsonGenerator writeStartObject(Object currValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeStartObject in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeEndObject

      public tools.jackson.core.JsonGenerator writeEndObject() throws tools.jackson.core.JacksonException
      Specified by:
      writeEndObject in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeString

      public tools.jackson.core.JsonGenerator writeString(String text) throws tools.jackson.core.JacksonException
      Specified by:
      writeString in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeString

      public tools.jackson.core.JsonGenerator writeString(char[] text, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeString in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeString

      public tools.jackson.core.JsonGenerator writeString(tools.jackson.core.SerializableString sstr) throws tools.jackson.core.JacksonException
      Overrides:
      writeString in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • writeRawUTF8String

      public tools.jackson.core.JsonGenerator writeRawUTF8String(byte[] text, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeRawUTF8String in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeUTF8String

      public tools.jackson.core.JsonGenerator writeUTF8String(byte[] text, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeUTF8String in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(String text) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(String text, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(char[] text, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRaw

      public tools.jackson.core.JsonGenerator writeRaw(char c) throws tools.jackson.core.JacksonException
      Specified by:
      writeRaw in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeRawValue

      public tools.jackson.core.JsonGenerator writeRawValue(String text) throws tools.jackson.core.JacksonException
      Overrides:
      writeRawValue in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • writeRawValue

      public tools.jackson.core.JsonGenerator writeRawValue(String text, int offset, int len) throws tools.jackson.core.JacksonException
      Overrides:
      writeRawValue in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • writeRawValue

      public tools.jackson.core.JsonGenerator writeRawValue(char[] text, int offset, int len) throws tools.jackson.core.JacksonException
      Overrides:
      writeRawValue in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • writeBinary

      public tools.jackson.core.JsonGenerator writeBinary(tools.jackson.core.Base64Variant b64variant, byte[] data, int offset, int len) throws tools.jackson.core.JacksonException
      Specified by:
      writeBinary in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeBoolean

      public tools.jackson.core.JsonGenerator writeBoolean(boolean state) throws tools.jackson.core.JacksonException
      Specified by:
      writeBoolean in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNull

      public tools.jackson.core.JsonGenerator writeNull() throws tools.jackson.core.JacksonException
      Specified by:
      writeNull in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(short v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(int v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(long v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(BigInteger v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(double v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(float v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(BigDecimal v) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeNumber

      public tools.jackson.core.JsonGenerator writeNumber(String encodedValue) throws tools.jackson.core.JacksonException
      Specified by:
      writeNumber in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • writeOmittedProperty

      public tools.jackson.core.JsonGenerator writeOmittedProperty(String propName) throws tools.jackson.core.JacksonException
      Overrides:
      writeOmittedProperty in class tools.jackson.core.JsonGenerator
      Throws:
      tools.jackson.core.JacksonException
    • _verifyValueWrite

      protected final void _verifyValueWrite(String typeMsg) throws tools.jackson.core.JacksonException
      Specified by:
      _verifyValueWrite in class tools.jackson.core.base.GeneratorBase
      Throws:
      tools.jackson.core.JacksonException
    • _releaseBuffers

      protected void _releaseBuffers()
      Specified by:
      _releaseBuffers in class tools.jackson.core.base.GeneratorBase
    • _reportCsvWriteError

      protected void _reportCsvWriteError(String msg) throws tools.jackson.core.JacksonException
      Method called when there is a problem related to mapping data (compared to a low-level generation); if so, should be surfaced as
      Throws:
      tools.jackson.core.JacksonException
    • _columnIndex

      protected final int _columnIndex()
    • finishRow

      protected void finishRow() throws tools.jackson.core.JacksonException
      Method called when the current row is complete; typically will flush possibly buffered column values, append linefeed and reset state appropriately.
      Throws:
      tools.jackson.core.JacksonException
    • _handleFirstLine

      protected void _handleFirstLine() throws tools.jackson.core.JacksonException
      Throws:
      tools.jackson.core.JacksonException
    • _addToArray

      protected void _addToArray(String value)
    • _addToArray

      protected void _addToArray(char[] value)