public abstract class

ParserBase

extends ParserMinimalBase
java.lang.Object
   ↳ com.fasterxml.jackson.core.JsonParser
     ↳ com.fasterxml.jackson.core.base.ParserMinimalBase
       ↳ com.fasterxml.jackson.core.base.ParserBase
Known Direct Subclasses

Class Overview

Intermediate base class used by all Jackson JsonParser implementations. Contains most common things that are independent of actual underlying input source

Summary

Constants
char CHAR_NULL
int INT_0
int INT_1
int INT_2
int INT_3
int INT_4
int INT_5
int INT_6
int INT_7
int INT_8
int INT_9
int INT_DECIMAL_POINT
int INT_E
int INT_MINUS
int INT_PLUS
int INT_e
int NR_BIGDECIMAL
int NR_BIGINT
int NR_DOUBLE
int NR_INT
int NR_LONG
int NR_UNKNOWN
[Expand]
Inherited Constants
From class com.fasterxml.jackson.core.base.ParserMinimalBase
Fields
protected byte[] _binaryValue We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue() will not need to decode data more than once.
protected ByteArrayBuilder _byteArrayBuilder ByteArrayBuilder is needed if 'getBinaryValue' is called.
protected boolean _closed Flag that indicates whether parser is closed or not.
protected long _currInputProcessed Number of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer).
protected int _currInputRow Current row location of current point in input buffer, starting from 1, if available.
protected int _currInputRowStart Current index of the first character of the current row in input buffer.
protected int _expLength Length of the exponent part of the number, if any, not including 'e' marker or sign, just digits.
protected int _fractLength Length of the fractional part (not including decimal point or exponent), in characters.
protected int _inputEnd Index of character after last available one in the buffer.
protected int _inputPtr Pointer to next available character in buffer
protected int _intLength Length of integer part of the number, in characters
protected final IOContext _ioContext I/O context for this reader.
protected boolean _nameCopied Flag set to indicate whether the field name is available from the name copy buffer or not (in addition to its String representation being available via read context)
protected char[] _nameCopyBuffer Temporary buffer that is needed if field name is accessed using getTextCharacters() method (instead of String returning alternatives)
protected JsonToken _nextToken Secondary token related to the next token after current one; used if its type is known.
protected int _numTypesValid Bitfield that indicates which numeric representations have been calculated for the current type
protected BigDecimal _numberBigDecimal
protected BigInteger _numberBigInt
protected double _numberDouble
protected int _numberInt
protected long _numberLong
protected boolean _numberNegative Flag that indicates whether numeric value has a negative value.
protected JsonReadContext _parsingContext 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 String values, including field names if necessary (name split across boundary, contains escape sequence, or access needed to char array)
protected int _tokenInputCol Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)
protected int _tokenInputRow Input row on which current token starts, 1-based
protected long _tokenInputTotal Total number of bytes/characters read before start of current token.
[Expand]
Inherited Fields
From class com.fasterxml.jackson.core.base.ParserMinimalBase
From class com.fasterxml.jackson.core.JsonParser
Protected Constructors
ParserBase(IOContext ctxt, int features)
Public Methods
ByteArrayBuilder _getByteArrayBuilder()
void close()
Closes the parser so that no further iteration or data access can be made; will also close the underlying input source if parser either owns the input source, or feature AUTO_CLOSE_SOURCE is enabled.
BigInteger getBigIntegerValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can not be used as a Java long primitive type due to its magnitude.
JsonLocation getCurrentLocation()
Method that returns location of the last processed character; usually for error reporting purposes
String getCurrentName()
Method that can be called to get the name associated with the current event.
BigDecimal getDecimalValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT or VALUE_NUMBER_INT.
double getDoubleValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT and it can be expressed as a Java double primitive type.
float getFloatValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT and it can be expressed as a Java float primitive type.
int getIntValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can be expressed as a value of Java int primitive type.
long getLongValue()
Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can be expressed as a Java long primitive type.
JsonParser.NumberType getNumberType()
If current token is of type VALUE_NUMBER_INT or VALUE_NUMBER_FLOAT, returns one of JsonParser.NumberType constants; otherwise returns null.
Number getNumberValue()
Generic number value accessor method that will work for all kinds of numeric values.
JsonReadContext getParsingContext()
Method that can be used to access current parsing context reader is in.
long getTokenCharacterOffset()
int getTokenColumnNr()
int getTokenLineNr()
JsonLocation getTokenLocation()
Method that return the starting location of the current token; that is, position of the first character from input that starts the current token.
boolean hasTextCharacters()
Method that can be used to determine whether calling of getTextCharacters() would be the most efficient way to access textual content for the event parser currently points to.
boolean isClosed()
Method that can be called to determine whether this parser is closed or not.
void overrideCurrentName(String name)
Method that can be used to change what is considered to be the current (field) name.
Protected Methods
abstract void _closeInput()
final int _decodeBase64Escape(Base64Variant b64variant, int ch, int index)
final int _decodeBase64Escape(Base64Variant b64variant, char ch, int index)
char _decodeEscaped()
Method that sub-classes must implement to support escaped sequences in base64-encoded sections.
abstract void _finishString()
void _handleEOF()
Method called when an EOF is encountered between tokens.
void _parseNumericValue(int expType)
Method that will parse actual numeric value out of a syntactically valid number value.
void _releaseBuffers()
Method called to release internal buffers owned by the base reader.
void _reportMismatchedEndMarker(int actCh, char expCh)
void convertNumberToBigDecimal()
void convertNumberToBigInteger()
void convertNumberToDouble()
void convertNumberToInt()
void convertNumberToLong()
abstract boolean loadMore()
final void loadMoreGuaranteed()
IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex, String msg)
IllegalArgumentException reportInvalidBase64Char(Base64Variant b64variant, int ch, int bindex)
void reportInvalidNumber(String msg)
void reportOverflowInt()
void reportOverflowLong()
void reportUnexpectedNumberChar(int ch, String comment)
final JsonToken reset(boolean negative, int intLen, int fractLen, int expLen)
final JsonToken resetAsNaN(String valueStr, double value)
final JsonToken resetFloat(boolean negative, int intLen, int fractLen, int expLen)
final JsonToken resetInt(boolean negative, int intLen)
[Expand]
Inherited Methods
From class com.fasterxml.jackson.core.base.ParserMinimalBase
From class com.fasterxml.jackson.core.JsonParser
From class java.lang.Object
From interface com.fasterxml.jackson.core.Versioned
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Constants

protected static final char CHAR_NULL

Constant Value: 0 (0x00000000)

protected static final int INT_0

Constant Value: 48 (0x00000030)

protected static final int INT_1

Constant Value: 49 (0x00000031)

protected static final int INT_2

Constant Value: 50 (0x00000032)

protected static final int INT_3

Constant Value: 51 (0x00000033)

protected static final int INT_4

Constant Value: 52 (0x00000034)

protected static final int INT_5

Constant Value: 53 (0x00000035)

protected static final int INT_6

Constant Value: 54 (0x00000036)

protected static final int INT_7

Constant Value: 55 (0x00000037)

protected static final int INT_8

Constant Value: 56 (0x00000038)

protected static final int INT_9

Constant Value: 57 (0x00000039)

protected static final int INT_DECIMAL_POINT

Constant Value: 46 (0x0000002e)

protected static final int INT_E

Constant Value: 69 (0x00000045)

protected static final int INT_MINUS

Constant Value: 45 (0x0000002d)

protected static final int INT_PLUS

Constant Value: 43 (0x0000002b)

protected static final int INT_e

Constant Value: 101 (0x00000065)

protected static final int NR_BIGDECIMAL

Constant Value: 16 (0x00000010)

protected static final int NR_BIGINT

Constant Value: 4 (0x00000004)

protected static final int NR_DOUBLE

Constant Value: 8 (0x00000008)

protected static final int NR_INT

Constant Value: 1 (0x00000001)

protected static final int NR_LONG

Constant Value: 2 (0x00000002)

protected static final int NR_UNKNOWN

Constant Value: 0 (0x00000000)

Fields

protected byte[] _binaryValue

We will hold on to decoded binary data, for duration of current event, so that multiple calls to getBinaryValue() will not need to decode data more than once.

protected ByteArrayBuilder _byteArrayBuilder

ByteArrayBuilder is needed if 'getBinaryValue' is called. If so, we better reuse it for remainder of content.

protected boolean _closed

Flag that indicates whether parser is closed or not. Gets set when parser is either closed by explicit call (close()) or when end-of-input is reached.

protected long _currInputProcessed

Number of characters/bytes that were contained in previous blocks (blocks that were already processed prior to the current buffer).

protected int _currInputRow

Current row location of current point in input buffer, starting from 1, if available.

protected int _currInputRowStart

Current index of the first character of the current row in input buffer. Needed to calculate column position, if necessary; benefit of not having column itself is that this only has to be updated once per line.

protected int _expLength

Length of the exponent part of the number, if any, not including 'e' marker or sign, just digits. Not used for pure integer values.

protected int _fractLength

Length of the fractional part (not including decimal point or exponent), in characters. Not used for pure integer values.

protected int _inputEnd

Index of character after last available one in the buffer.

protected int _inputPtr

Pointer to next available character in buffer

protected int _intLength

Length of integer part of the number, in characters

protected final IOContext _ioContext

I/O context for this reader. It handles buffer allocation for the reader.

protected boolean _nameCopied

Flag set to indicate whether the field name is available from the name copy buffer or not (in addition to its String representation being available via read context)

protected char[] _nameCopyBuffer

Temporary buffer that is needed if field name is accessed using getTextCharacters() method (instead of String returning alternatives)

protected JsonToken _nextToken

Secondary token related to the next token after current one; used if its type is known. This may be value token that follows FIELD_NAME, for example.

protected int _numTypesValid

Bitfield that indicates which numeric representations have been calculated for the current type

protected BigDecimal _numberBigDecimal

protected BigInteger _numberBigInt

protected double _numberDouble

protected int _numberInt

protected long _numberLong

protected boolean _numberNegative

Flag that indicates whether numeric value has a negative value. That is, whether its textual representation starts with minus character.

protected JsonReadContext _parsingContext

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 String values, including field names if necessary (name split across boundary, contains escape sequence, or access needed to char array)

protected int _tokenInputCol

Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)

protected int _tokenInputRow

Input row on which current token starts, 1-based

protected long _tokenInputTotal

Total number of bytes/characters read before start of current token. For big (gigabyte-sized) sizes are possible, needs to be long, unlike pointers and sizes related to in-memory buffers.

Protected Constructors

protected ParserBase (IOContext ctxt, int features)

Public Methods

public ByteArrayBuilder _getByteArrayBuilder ()

public void close ()

Closes the parser so that no further iteration or data access can be made; will also close the underlying input source if parser either owns the input source, or feature AUTO_CLOSE_SOURCE is enabled. Whether parser owns the input source depends on factory method that was used to construct instance (so check JsonFactory for details, but the general idea is that if caller passes in closable resource (such as InputStream or Reader) parser does NOT own the source; but if it passes a reference (such as java.io.File or java.net.URL and creates stream or reader it does own them.

Throws
IOException

public BigInteger getBigIntegerValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can not be used as a Java long primitive type due to its magnitude. It can also be called for VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDecimalValue() and then constructing a BigInteger from that value.

public JsonLocation getCurrentLocation ()

Method that returns location of the last processed character; usually for error reporting purposes

public String getCurrentName ()

Method that can be called to get the name associated with the current event.

public BigDecimal getDecimalValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT or VALUE_NUMBER_INT. No under/overflow exceptions are ever thrown.

public double getDoubleValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT and it can be expressed as a Java double primitive type. It can also be called for VALUE_NUMBER_INT; if so, it is equivalent to calling getLongValue() and then casting; except for possible overflow/underflow exception.

Note: if the value falls outside of range of Java double, a JsonParseException will be thrown to indicate numeric overflow/underflow.

public float getFloatValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_FLOAT and it can be expressed as a Java float primitive type. It can also be called for VALUE_NUMBER_INT; if so, it is equivalent to calling getLongValue() and then casting; except for possible overflow/underflow exception.

Note: if the value falls outside of range of Java float, a JsonParseException will be thrown to indicate numeric overflow/underflow.

public int getIntValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can be expressed as a value of Java int primitive type. It can also be called for VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDoubleValue() and then casting; except for possible overflow/underflow exception.

Note: if the resulting integer value falls outside range of Java int, a JsonParseException may be thrown to indicate numeric overflow/underflow.

public long getLongValue ()

Numeric accessor that can be called when the current token is of type VALUE_NUMBER_INT and it can be expressed as a Java long primitive type. It can also be called for VALUE_NUMBER_FLOAT; if so, it is equivalent to calling getDoubleValue() and then casting to int; except for possible overflow/underflow exception.

Note: if the token is an integer, but its value falls outside of range of Java long, a JsonParseException may be thrown to indicate numeric overflow/underflow.

public JsonParser.NumberType getNumberType ()

If current token is of type VALUE_NUMBER_INT or VALUE_NUMBER_FLOAT, returns one of JsonParser.NumberType constants; otherwise returns null.

public Number getNumberValue ()

Generic number value accessor method that will work for all kinds of numeric values. It will return the optimal (simplest/smallest possible) wrapper object that can express the numeric value just parsed.

public JsonReadContext getParsingContext ()

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. Contexts are hierarchically nested, and can be used for example for figuring out part of the input document that correspond to specific array or object (for highlighting purposes, or error reporting). Contexts can also be used for simple xpath-like matching of input, if so desired.

public long getTokenCharacterOffset ()

public int getTokenColumnNr ()

public int getTokenLineNr ()

public JsonLocation getTokenLocation ()

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 boolean hasTextCharacters ()

Method that can be used to determine whether calling of getTextCharacters() would be the most efficient way to access textual content for the event parser currently points to.

Default implementation simply returns false since only actual implementation class has knowledge of its internal buffering state. Implementations are strongly encouraged to properly override this method, to allow efficient copying of content by other code.

Returns
  • True if parser currently has character array that can be efficiently returned via getTextCharacters(); false means that it may or may not exist

public boolean isClosed ()

Method that can be called to determine whether this parser is closed or not. If it is closed, no new tokens can be retrieved by calling nextToken() (and the underlying stream may be closed). Closing may be due to an explicit call to close() or because parser has encountered end of input.

public void overrideCurrentName (String name)

Method that can be used to change what is considered to be the current (field) name. May be needed to support non-JSON data formats or unusual binding conventions; not needed for typical processing.

Note that use of this method should only be done as sort of last resort, as it is a work-around for regular operation.

Parameters
name Name to use as the current name; may be null.

Protected Methods

protected abstract void _closeInput ()

Throws
IOException

protected final int _decodeBase64Escape (Base64Variant b64variant, int ch, int index)

protected final int _decodeBase64Escape (Base64Variant b64variant, char ch, int index)

protected char _decodeEscaped ()

Method that sub-classes must implement to support escaped sequences in base64-encoded sections. Sub-classes that do not need base64 support can leave this as is

protected abstract void _finishString ()

protected void _handleEOF ()

Method called when an EOF is encountered between tokens. If so, it may be a legitimate EOF, but only iff there is no open non-root context.

protected void _parseNumericValue (int expType)

Method that will parse actual numeric value out of a syntactically valid number value. Type it will parse into depends on whether it is a floating point number, as well as its magnitude: smallest legal type (of ones available) is used for efficiency.

Parameters
expType Numeric type that we will immediately need, if any; mostly necessary to optimize handling of floating point numbers

protected void _releaseBuffers ()

Method called to release internal buffers owned by the base reader. This may be called along with _closeInput() (for example, when explicitly closing this reader instance), or separately (if need be).

Throws
IOException

protected void _reportMismatchedEndMarker (int actCh, char expCh)

protected void convertNumberToBigDecimal ()

protected void convertNumberToBigInteger ()

protected void convertNumberToDouble ()

protected void convertNumberToInt ()

protected void convertNumberToLong ()

protected abstract boolean loadMore ()

Throws
IOException

protected final void loadMoreGuaranteed ()

Throws
IOException

protected IllegalArgumentException reportInvalidBase64Char (Base64Variant b64variant, int ch, int bindex, String msg)

Parameters
bindex Relative index within base64 character unit; between 0 and 3 (as unit has exactly 4 characters)

protected IllegalArgumentException reportInvalidBase64Char (Base64Variant b64variant, int ch, int bindex)

protected void reportInvalidNumber (String msg)

protected void reportOverflowInt ()

protected void reportOverflowLong ()

protected void reportUnexpectedNumberChar (int ch, String comment)

protected final JsonToken reset (boolean negative, int intLen, int fractLen, int expLen)

protected final JsonToken resetAsNaN (String valueStr, double value)

protected final JsonToken resetFloat (boolean negative, int intLen, int fractLen, int expLen)

protected final JsonToken resetInt (boolean negative, int intLen)