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

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

public final class CsvParserBootstrapper
extends Object

This class is used to determine the encoding of byte stream that is to contain CSV document. Since there is no real specification for how this should work with CSV, it will be based on rules used with JSON (which themselves are similar to those used with XML); main points are to check for BOM first, then look for multi-byted fixed-length encodings (UTF-16, UTF-32). And finally, if neither found, must decide between most likely alternatives, UTF-8 and Latin-1.


Field Summary
protected  boolean _bigEndian
           
protected  int _bytesPerChar
           
protected  com.fasterxml.jackson.core.io.IOContext _context
           
protected  InputStream _in
           
protected  byte[] _inputBuffer
           
protected  int _inputProcessed
          Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.
 
Constructor Summary
CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, char quoteChar, byte[] inputBuffer, int inputStart, int inputLen)
           
CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt, char quoteChar, InputStream in)
           
 
Method Summary
 CsvParser constructParser(int baseFeatures, int csvFeatures, com.fasterxml.jackson.core.ObjectCodec codec)
           
 Reader constructReader()
           
 com.fasterxml.jackson.core.JsonEncoding detectEncoding()
          Method that should be called after constructing an instace.
protected  boolean ensureLoaded(int minimum)
           
static com.fasterxml.jackson.core.format.MatchStrength hasCSVFormat(com.fasterxml.jackson.core.format.InputAccessor acc, char quoteChar, char separatorChar)
          Current implementation is not as thorough as one used by other data formats like JSON.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_context

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

_in

protected final InputStream _in

_inputBuffer

protected final byte[] _inputBuffer

_inputProcessed

protected int _inputProcessed
Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.

Note: includes possible BOMs, if those were part of the input.


_bigEndian

protected boolean _bigEndian

_bytesPerChar

protected int _bytesPerChar
Constructor Detail

CsvParserBootstrapper

public CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt,
                             char quoteChar,
                             InputStream in)

CsvParserBootstrapper

public CsvParserBootstrapper(com.fasterxml.jackson.core.io.IOContext ctxt,
                             char quoteChar,
                             byte[] inputBuffer,
                             int inputStart,
                             int inputLen)
Method Detail

detectEncoding

public com.fasterxml.jackson.core.JsonEncoding detectEncoding()
                                                       throws IOException,
                                                              com.fasterxml.jackson.core.JsonParseException
Method that should be called after constructing an instace. It will figure out encoding that content uses, to allow for instantiating a proper scanner object.

Throws:
IOException
com.fasterxml.jackson.core.JsonParseException

constructReader

public Reader constructReader()
                       throws IOException
Throws:
IOException

constructParser

public CsvParser constructParser(int baseFeatures,
                                 int csvFeatures,
                                 com.fasterxml.jackson.core.ObjectCodec codec)
                          throws IOException,
                                 com.fasterxml.jackson.core.JsonParseException
Throws:
IOException
com.fasterxml.jackson.core.JsonParseException

hasCSVFormat

public static com.fasterxml.jackson.core.format.MatchStrength hasCSVFormat(com.fasterxml.jackson.core.format.InputAccessor acc,
                                                                           char quoteChar,
                                                                           char separatorChar)
                                                                    throws IOException
Current implementation is not as thorough as one used by other data formats like JSON. But it should work, for now, and can be improved as necessary.

Throws:
IOException

ensureLoaded

protected boolean ensureLoaded(int minimum)
                        throws IOException
Throws:
IOException


Copyright © 2012 fasterxml.com. All Rights Reserved.