com.fasterxml.jackson.dataformat.csv.impl
Class CsvWriter

java.lang.Object
  extended by com.fasterxml.jackson.dataformat.csv.impl.CsvWriter

public final class CsvWriter
extends Object

Low-level helper class that handles actual output of CSV, purely based on indexes given without worrying about reordering etc.


Field Summary
protected  BufferedValue[] _buffered
          And if output comes in shuffled order we will need to do bit of ordering.
protected  boolean _bufferRecyclable
          Flag that indicates whether the _outputBuffer is recycable (and needs to be returned to recycler once we are done) or not.
protected  char _cfgColumnSeparator
           
protected  char[] _cfgLineSeparator
           
protected  int _cfgLineSeparatorLength
           
protected  int _cfgMinSafeChar
          Lowest-valued character that is safe to output without using quotes around value
protected  char _cfgQuoteCharacter
           
protected  int _charsWritten
          Let's keep track of how many bytes have been output, may prove useful when debugging.
protected  com.fasterxml.jackson.core.io.IOContext _ioContext
           
protected  int _lastBuffered
          Index of the last buffered value
protected  int _nextColumnToWrite
          Index of column we expect to write next
protected  Writer _out
          Underlying Writer used for output.
protected  char[] _outputBuffer
          Intermediate buffer in which contents are buffered before being written using _out.
protected  int _outputEnd
          Offset to index after the last valid index in _outputBuffer.
protected  int _outputTail
          Pointer to the next available byte in _outputBuffer
protected static int MAX_QUOTE_CHECK
           
protected  BufferedValue[] NO_BUFFERED
           
protected static int SHORT_WRITE
           
 
Constructor Summary
CsvWriter(com.fasterxml.jackson.core.io.IOContext ctxt, Writer out, char columnSeparator, char quoteChar, char[] linefeed)
           
 
Method Summary
protected  void _buffer(int index, BufferedValue v)
           
protected  void _flushBuffer()
           
protected  boolean _mayNeedQuotes(String value, int length)
          Helper method that determines whether given String is likely to require quoting; check tries to optimize for speed.
 void _releaseBuffers()
           
 void _writeQuoted(String text)
           
protected  void appendColumnSeparator()
           
protected  void appendValue(boolean value)
           
protected  void appendValue(double value)
           
protected  void appendValue(int value)
           
protected  void appendValue(long value)
           
protected  void appendValue(String value)
           
 void close(boolean autoClose)
           
 void endRow()
           
 void flush(boolean flushStream)
           
 Object getOutputTarget()
           
 int nextColumnIndex()
           
 void write(int columnIndex, boolean value)
           
 void write(int columnIndex, char[] ch, int offset, int len)
           
 void write(int columnIndex, double value)
           
 void write(int columnIndex, int value)
           
 void write(int columnIndex, long value)
           
 void write(int columnIndex, String value)
           
 void writeColumnName(String name)
           
 void writeRaw(char c)
           
 void writeRaw(char[] text, int offset, int len)
           
 void writeRaw(String text)
           
 void writeRaw(String text, int start, int len)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT_WRITE

protected static final int SHORT_WRITE
See Also:
Constant Field Values

MAX_QUOTE_CHECK

protected static final int MAX_QUOTE_CHECK
See Also:
Constant Field Values

NO_BUFFERED

protected final BufferedValue[] NO_BUFFERED

_ioContext

protected final com.fasterxml.jackson.core.io.IOContext _ioContext

_out

protected final Writer _out
Underlying Writer used for output.


_cfgColumnSeparator

protected final char _cfgColumnSeparator

_cfgQuoteCharacter

protected final char _cfgQuoteCharacter

_cfgLineSeparator

protected final char[] _cfgLineSeparator

_cfgLineSeparatorLength

protected final int _cfgLineSeparatorLength

_cfgMinSafeChar

protected final int _cfgMinSafeChar
Lowest-valued character that is safe to output without using quotes around value


_nextColumnToWrite

protected int _nextColumnToWrite
Index of column we expect to write next


_buffered

protected BufferedValue[] _buffered
And if output comes in shuffled order we will need to do bit of ordering.


_lastBuffered

protected int _lastBuffered
Index of the last buffered value


_outputBuffer

protected char[] _outputBuffer
Intermediate buffer in which contents are buffered before being written using _out.


_bufferRecyclable

protected boolean _bufferRecyclable
Flag that indicates whether the _outputBuffer is recycable (and needs to be returned to recycler once we are done) or not.


_outputTail

protected int _outputTail
Pointer to the next available byte in _outputBuffer


_outputEnd

protected final int _outputEnd
Offset to index after the last valid index in _outputBuffer. Typically same as length of the buffer.


_charsWritten

protected int _charsWritten
Let's keep track of how many bytes have been output, may prove useful when debugging. This does not include bytes buffered in the output buffer, just bytes that have been written using underlying stream writer.

Constructor Detail

CsvWriter

public CsvWriter(com.fasterxml.jackson.core.io.IOContext ctxt,
                 Writer out,
                 char columnSeparator,
                 char quoteChar,
                 char[] linefeed)
Method Detail

getOutputTarget

public Object getOutputTarget()

nextColumnIndex

public int nextColumnIndex()

write

public void write(int columnIndex,
                  String value)
           throws IOException
Throws:
IOException

write

public void write(int columnIndex,
                  char[] ch,
                  int offset,
                  int len)
           throws IOException
Throws:
IOException

write

public void write(int columnIndex,
                  int value)
           throws IOException
Throws:
IOException

write

public void write(int columnIndex,
                  long value)
           throws IOException
Throws:
IOException

write

public void write(int columnIndex,
                  double value)
           throws IOException
Throws:
IOException

write

public void write(int columnIndex,
                  boolean value)
           throws IOException
Throws:
IOException

writeColumnName

public void writeColumnName(String name)
                     throws IOException
Throws:
IOException

endRow

public void endRow()
            throws IOException
Throws:
IOException

appendValue

protected void appendValue(String value)
                    throws IOException
Throws:
IOException

appendValue

protected void appendValue(int value)
                    throws IOException
Throws:
IOException

appendValue

protected void appendValue(long value)
                    throws IOException
Throws:
IOException

appendValue

protected void appendValue(double value)
                    throws IOException
Throws:
IOException

appendValue

protected void appendValue(boolean value)
                    throws IOException
Throws:
IOException

appendColumnSeparator

protected void appendColumnSeparator()
                              throws IOException
Throws:
IOException

_writeQuoted

public void _writeQuoted(String text)
                  throws IOException
Throws:
IOException

writeRaw

public void writeRaw(String text)
              throws IOException
Throws:
IOException

writeRaw

public void writeRaw(String text,
                     int start,
                     int len)
              throws IOException
Throws:
IOException

writeRaw

public void writeRaw(char[] text,
                     int offset,
                     int len)
              throws IOException,
                     com.fasterxml.jackson.core.JsonGenerationException
Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException

writeRaw

public void writeRaw(char c)
              throws IOException
Throws:
IOException

flush

public void flush(boolean flushStream)
           throws IOException
Throws:
IOException

close

public void close(boolean autoClose)
           throws IOException
Throws:
IOException

_mayNeedQuotes

protected final boolean _mayNeedQuotes(String value,
                                       int length)
Helper method that determines whether given String is likely to require quoting; check tries to optimize for speed.


_buffer

protected void _buffer(int index,
                       BufferedValue v)

_flushBuffer

protected final void _flushBuffer()
                           throws IOException
Throws:
IOException

_releaseBuffers

public void _releaseBuffers()


Copyright © 2012 fasterxml.com. All Rights Reserved.