JsonParser implementation used to expose CSV documents
in form that allows other Jackson functionality to deal
with it.
Implementation is based on a state-machine that pulls information
using CsvDecoder.
| Modifier and Type | Field and Description |
|---|---|
| protected String | |
| protected String | _arrayValue
Contents of the cell, to be split into distinct array values. |
| protected int | _arrayValueStart
Pointer to the first character of the next array value to return. |
| protected byte[] | _binaryValue
We will hold on to decoded binary data, for duration of
current event, so that multiple calls to
|
| protected ByteArrayBuilder | |
| protected boolean | |
| protected boolean | |
| protected int | _columnCount
Number of columns defined by schema. |
| protected int | _columnIndex
Index of the column we are exposing |
| protected String | _currentName
Name of column that we exposed most recently, accessible after
|
| protected String | _currentValue
String value for the current column, if accessed. |
| protected int | |
| protected String | |
| protected final CsvDecoder | _reader
Thing that actually reads the CSV content |
| protected CsvSchema | _schema
Definition of columns being read. |
| protected int | _state
Current logical state of the parser; one of |
| protected SimpleStreamReadContext | _streamReadContext
Information about parser context, context in which the next token is to be parsed (root, array, object). |
| protected final TextBuffer | _textBuffer
Buffer that contains contents of all values after processing of doubled-quotes, escaped characters. |
| private static final CsvSchema | |
| private static final int | |
| protected static final int | STATE_DOC_END
State in which end marker is returned; either
null (if no array wrapping), or
|
| protected static final int | STATE_DOC_START
Initial state before anything is read from document. |
| protected static final int | STATE_IN_ARRAY
State in which a column value has been determined to be of an array type, and will need to be split into multiple values. |
| protected static final int | STATE_MISSING_NAME
State in which we should expose name token for a "missing column"
(for which placeholder `null` value is to be added as well);
see |
| protected static final int | STATE_MISSING_VALUE
State in which we should expose `null` value token as a value for
"missing" column;
see |
| protected static final int | STATE_NAMED_VALUE
State in which value matching property name will be returned. |
| protected static final int | STATE_NEXT_ENTRY
State in which next entry will be available, returning
either |
| protected static final int | STATE_RECORD_START
State before logical start of a record, in which next
token to return will be |
| protected static final int | STATE_SKIP_EXTRA_COLUMNS
State in which we have encountered more column values than there should be, and need to basically skip extra values if callers tries to advance parser state. |
| protected static final int | STATE_UNNAMED_VALUE
State in which "unnamed" value (entry in an array) will be returned, if one available; otherwise end-array is returned. |
| protected static final JacksonFeatureSet | STREAM_READ_CAPABILITIES
CSV is slightly different from defaults, having essentially untyped scalars except if indicated by schema |
| Access | Constructor and Description |
|---|---|
| public | CsvParser(ObjectReadContext readCtxt, IOContext ioCtxt, int stdFeatures, int csvFeatures, CsvSchema schema, Reader reader)
|
| Modifier and Type | Method and Description |
|---|---|
| protected void | _closeInput()
Implements abstract tools. Abstract method for sub-classes to implement; to be called by
|
| public ByteArrayBuilder | |
| protected JsonToken | |
| protected void | _handleEOF()
Implements abstract tools. Method sub-classes need to implement to check whether end-of-content is allowed at the current decoding position: formats often want to verify the all start/end token pairs match, for example. |
| protected JsonToken | |
| protected JsonToken | _handleMissingColumns()
Helper method called when end of row occurs before finding values for all schema-specified columns. |
| protected JsonToken | |
| protected JsonToken | |
| protected JsonToken | |
| protected JsonToken | |
| protected final JsonToken | _handleObjectRowEnd()
Helper method called to handle details of state update when end of logical record occurs. |
| protected JsonToken | |
| protected JsonToken | _handleStartDoc()
Method called to handle details of initializing things to return the very first token. |
| protected JsonToken | |
| protected boolean | _isNullValue(String value)
Helper method called to check whether specified String value should be considered "null" value, if so configured. |
| protected void | |
| protected void | _releaseBuffers()
Implements abstract tools. Method called to release internal buffers owned by the base reader. |
| public <T> T | _reportCsvReadError(String msg, Object... args)
Method called when there is a problem related to mapping CSV columns to property names, i.e. is CSV-specific aspect |
| public <T> T | |
| protected <T> T | |
| public <T> T | |
| protected void | |
| protected final JsonToken | |
| protected void | |
| protected void | |
| public JacksonException | |
| public void | assignCurrentValue(Object v)
Implements abstract tools. Helper method, usually equivalent to:
|
| public boolean | canReadObjectId()
Overrides tools. Introspection method that may be called to see if the underlying data format supports some kind of Object Ids natively (many do not; for example, JSON doesn't). |
| public boolean | canReadTypeId()
Overrides tools. Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't). |
| public JsonParser | configure(CsvReadFeature f, boolean state)
Method for enabling or disabling specified CSV feature
(check |
| public TokenStreamLocation | currentLocation()
Implements abstract tools. Method that returns location of the last processed character; usually for error reporting purposes. |
| public String | currentName()
Implements abstract tools. Method that can be called to get the name associated with
the current token: for |
| public TokenStreamLocation | currentTokenLocation()
Implements abstract tools. Method that return the starting location of the current token; that is, position of the first character from input that starts the current token. |
| public Object | currentValue()
Implements abstract tools. Helper method, usually equivalent to:
Note that "current value" is NOT populated (or used) by Streaming parser; it is only used by higher-level data-binding functionality. |
| public JsonParser | disable(CsvReadFeature f)
Method for disabling specified CSV feature
(check |
| public JsonParser | enable(CsvReadFeature f)
Method for enabling specified CSV feature
(check |
| public BigInteger | getBigIntegerValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public byte[] | getBinaryValue(Base64Variant variant)
Implements abstract tools. Method that can be used to read (and consume -- results may not be accessible using other methods after the call) base64-encoded binary data included in the current textual JSON value. |
| public BigDecimal | getDecimalValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public double | getDoubleValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public Object | getEmbeddedObject()
Overrides tools. Accessor that can be called if (and only if) the current token
is |
| public float | getFloatValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public int | getIntValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public long | getLongValue()
Implements abstract tools. Numeric accessor that can be called when the current
token is of type |
| public JsonParser. | getNumberType()
Implements abstract tools. If current token is of type
|
| public Number | getNumberValue()
Implements abstract tools. Generic number value accessor method that will work for all kinds of numeric values. |
| public Number | getNumberValueExact()
Overrides tools. Method similar to |
| public CsvSchema | getSchema()
Overrides tools. Accessor for getting active schema definition: it may be "empty" (no column definitions), but will never be null since it defaults to an empty schema (and default configuration) |
| public String | getString()
Implements abstract tools. Method for accessing textual representation of the current token;
if no current token (before first call to |
| public int | getString(Writer w)
Overrides tools. Method to read the textual representation of the current token in chunks and pass it to the given Writer. |
| public char[] | getStringCharacters()
Implements abstract tools. Method similar to |
| public int | getStringLength()
Implements abstract tools. Accessor used with |
| public int | getStringOffset()
Implements abstract tools. Accessor used with |
| public boolean | hasStringCharacters()
Implements abstract tools. Method that can be used to determine whether calling of
|
| public boolean | |
| public boolean | isExpectedNumberIntToken()
Overrides tools. Similar to |
| public boolean | isExpectedStartArrayToken()
Overrides tools. We need to override this method to support coercion from basic String value into array, in cases where schema does not specify actual type. |
| public boolean | isNaN()
Implements abstract tools. Accessor for checking whether current token is a special "not-a-number" (NaN) token (including both "NaN" AND positive/negative infinity!). |
| public boolean | nextName(SerializableString str)
Overrides tools. Method that fetches next token (as if calling |
| public String | nextName()
Overrides tools. Method that fetches next token (as if calling |
| public String | nextStringValue()
Overrides tools. Method that fetches next token (as if calling |
| public JsonToken | nextToken()
Implements abstract tools. Main iteration method, which will advance stream enough to determine type of the next token, if any. |
| public int | releaseBuffered(Writer out)
Overrides tools. Method that can be called to push back any content that has been read but not consumed by the parser. |
| public JacksonFeatureSet | streamReadCapabilities()
Overrides tools. Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly). |
| public TokenStreamContext | streamReadContext()
Implements abstract tools. Method that can be used to access current parsing context reader is in. There are 3 different types: root, array and object contexts, with slightly different available information. |
| public Object | streamReadInputSource()
Implements abstract tools. Method that can be used to get access to object that is used
to access input being parsed; this is usually either
|
| public Version | version()
Implements abstract tools. Implements tools. Accessor for getting version of the core package, given a parser instance. |