Class JsonParserBase

All Implemented Interfaces:
Closeable, AutoCloseable, Versioned
Direct Known Subclasses:
NonBlockingJsonParserBase, ReaderBasedJsonParser, UTF8DataInputJsonParser, UTF8StreamJsonParser

public abstract class JsonParserBase extends ParserBase
Another intermediate base class, only used by actual JSON-backed parser implementations.
Since:
3.0
  • Field Details

    • _formatReadFeatures

      protected int _formatReadFeatures
      Bit flag for JsonReadFeatures that are enabled.
    • _streamReadContext

      protected JsonReadContext _streamReadContext
      Information about parser context, context in which the next token is to be parsed (root, array, object).
    • _nextToken

      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 JsonToken.PROPERTY_NAME, for example.
    • _nameCopied

      protected boolean _nameCopied
      Flag set to indicate whether the Object property name is available from the name copy buffer or not (in addition to its String representation being available via read context)
  • Constructor Details

    • JsonParserBase

      protected JsonParserBase(ObjectReadContext readCtxt, IOContext ctxt, int streamReadFeatures, int formatReadFeatures)
  • Method Details

    • version

      public Version version()
      Description copied from class: JsonParser
      Accessor for getting version of the core package, given a parser instance. Left for sub-classes to implement.
      Specified by:
      version in interface Versioned
      Specified by:
      version in class JsonParser
      Returns:
      Version of the component
    • streamReadCapabilities

      public JacksonFeatureSet<StreamReadCapability> streamReadCapabilities()
      Description copied from class: JsonParser
      Accessor for getting metadata on capabilities of this parser, based on underlying data format being read (directly or indirectly).
      Overrides:
      streamReadCapabilities in class ParserMinimalBase
      Returns:
      Set of read capabilities for content to read via this parser
    • streamReadContext

      public TokenStreamContext streamReadContext()
      Description copied from class: JsonParser
      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.

      NOTE: method was called getParsingContext() in Jackson 2.x

      Specified by:
      streamReadContext in class JsonParser
      Returns:
      Stream output context (TokenStreamContext) associated with this parser
    • currentValue

      public Object currentValue()
      Description copied from class: JsonParser
      Helper method, usually equivalent to: getParsingContext().currentValue();

      Note that "current value" is NOT populated (or used) by Streaming parser; it is only used by higher-level data-binding functionality. The reason it is included here is that it can be stored and accessed hierarchically, and gets passed through data-binding.

      Overrides:
      currentValue in class ParserBase
      Returns:
      "Current value" for the current input context this parser has
    • assignCurrentValue

      public void assignCurrentValue(Object v)
      Description copied from class: JsonParser
      Helper method, usually equivalent to: getParsingContext().assignCurrentValue(v);
      Overrides:
      assignCurrentValue in class ParserBase
      Parameters:
      v - "Current value" to assign to the current input context of this parser
    • currentName

      public String currentName()
      Method that can be called to get the name associated with the current event.
      Specified by:
      currentName in class JsonParser
      Returns:
      Name of the current property name, if any, in the parsing context (null if none)
    • hasStringCharacters

      public boolean hasStringCharacters()
      Description copied from class: JsonParser
      Method that can be used to determine whether calling of JsonParser.getStringCharacters() would be the most efficient way to access String value for the event parser currently points to (compared to JsonParser.getString()).
      Overrides:
      hasStringCharacters in class ParserBase
      Returns:
      True if parser currently has character array that can be efficiently returned via JsonParser.getStringCharacters(); false means that it may or may not exist
    • createChildArrayContext

      protected void createChildArrayContext(int lineNr, int colNr) throws JacksonException
      Throws:
      JacksonException
    • createChildObjectContext

      protected void createChildObjectContext(int lineNr, int colNr) throws JacksonException
      Throws:
      JacksonException
    • _parseNumericValue

      protected void _parseNumericValue(int expType) throws JacksonException, InputCoercionException
      Description copied from class: ParserBase
      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.
      Specified by:
      _parseNumericValue in class ParserBase
      Parameters:
      expType - Numeric type that we will immediately need, if any; mostly necessary to optimize handling of floating point numbers
      Throws:
      JacksonIOException - for low-level read issues
      InputCoercionException - if the current token not of numeric type
      StreamReadException - for number decoding problems
      JacksonException
    • _parseIntValue

      protected int _parseIntValue() throws JacksonException
      Specified by:
      _parseIntValue in class ParserBase
      Throws:
      JacksonException
    • _reportTooLongIntegral

      protected void _reportTooLongIntegral(int expType, String rawNum) throws JacksonException
      Throws:
      JacksonException
    • isEnabled

      public boolean isEnabled(JsonReadFeature f)
    • currentNameInBuffer

      protected char[] currentNameInBuffer()
    • _handleUnrecognizedCharacterEscape

      protected char _handleUnrecognizedCharacterEscape(char ch) throws StreamReadException
      Throws:
      StreamReadException
    • _reportMismatchedEndMarker

      protected void _reportMismatchedEndMarker(int actCh, char expCh) throws StreamReadException
      Throws:
      StreamReadException
    • _reportExtraEndMarker

      protected void _reportExtraEndMarker(int actCh) throws StreamReadException
      Throws:
      StreamReadException
    • _throwUnquotedSpace

      protected void _throwUnquotedSpace(int i, String ctxtDesc) throws StreamReadException
      Throws:
      StreamReadException
    • _validJsonTokenList

      protected String _validJsonTokenList()
    • _validJsonValueList

      protected String _validJsonValueList()
    • _isAllowedCtrlCharRS

      protected boolean _isAllowedCtrlCharRS(int i)