JSON
Version 1.0

org.codehaus.jackson.impl
Class ReaderBasedParserBase

java.lang.Object
  extended by org.codehaus.jackson.JsonParser
      extended by org.codehaus.jackson.impl.ReaderBasedParserBase
Direct Known Subclasses:
ReaderBasedNumericParser

public abstract class ReaderBasedParserBase
extends JsonParser

This is a simple low-level input reader base class, used by JSON parser. The reason for sub-classing (over composition) is due to need for direct access to character buffers and positions.

Author:
Tatu Saloranta

Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.jackson.JsonParser
JsonParser.NumberType
 
Field Summary
protected  long mCurrInputProcessed
          Number of characters that were contained in previous blocks (blocks that were already processed prior to the current buffer).
protected  int mCurrInputRow
          Current row location of current point in input buffer, starting from 1
protected  int mCurrInputRowStart
          Current index of the first character of the current row in input buffer.
protected  JsonToken mCurrToken
           
protected  char[] mInputBuffer
          Current buffer from which data is read; generally data is read into buffer from input source, but not always (especially when using nested input contexts when expanding parsed entity references etc).
protected  int mInputLen
          Index of character after last available one in the buffer.
protected  int mInputPtr
          Pointer to next available character in buffer
protected  IOContext mIOContext
          I/O context for this reader.
protected  Reader mReader
          Reader that can be used for reading more content, if one in use.
protected  TextBuffer mTextBuffer
          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 mTokenInputCol
          Column on input row that current token starts; 0-based (although in the end it'll be converted to 1-based)
protected  int mTokenInputRow
          Input row on which current token starts, 1-based
protected  long mTokenInputTotal
          Total number of characters read before start of current token.
 
Constructor Summary
protected ReaderBasedParserBase(IOContext ctxt, Reader r)
           
 
Method Summary
protected  void closeReader()
           
protected static String getCharDesc(int ch)
           
abstract  JsonLocation getCurrentLocation()
          Method that returns location of the last processed character; usually for error reporting purposes.
protected  char getNextChar(String eofMsg)
           
 long getTokenCharacterOffset()
           
 int getTokenColumnNr()
           
 int getTokenLineNr()
           
protected  boolean loadMore()
           
protected  void markLF()
           
protected  void markLF(int inputPtr)
           
protected  void releaseBuffers()
          Method called to release internal buffers owned by the base reader.
protected  void reportError(String msg)
           
protected  void reportInvalidEOF(String msg)
           
protected  void reportUnexpectedChar(int ch, String comment)
           
protected  void skipCR()
           
protected  void skipLF()
           
protected  void throwInternal()
           
protected  void wrapError(String msg, Throwable t)
           
 
Methods inherited from class org.codehaus.jackson.JsonParser
close, getCurrentName, getCurrentToken, getDecimalValue, getDoubleValue, getIntValue, getLongValue, getNumberType, getNumberValue, getParsingContext, getText, getTextCharacters, getTextLength, getTextOffset, getTokenLocation, hasCurrentToken, nextToken
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mIOContext

protected final IOContext mIOContext
I/O context for this reader. It handles buffer allocation for the reader.


mReader

protected Reader mReader
Reader that can be used for reading more content, if one in use. May be null, if input comes just as a full buffer, or if Reader has been closed.


mCurrToken

protected JsonToken mCurrToken

mInputBuffer

protected char[] mInputBuffer
Current buffer from which data is read; generally data is read into buffer from input source, but not always (especially when using nested input contexts when expanding parsed entity references etc).


mInputPtr

protected int mInputPtr
Pointer to next available character in buffer


mInputLen

protected int mInputLen
Index of character after last available one in the buffer.


mCurrInputProcessed

protected long mCurrInputProcessed
Number of characters that were contained in previous blocks (blocks that were already processed prior to the current buffer).


mCurrInputRow

protected int mCurrInputRow
Current row location of current point in input buffer, starting from 1


mCurrInputRowStart

protected int mCurrInputRowStart
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.


mTokenInputTotal

protected long mTokenInputTotal
Total number of 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.


mTokenInputRow

protected int mTokenInputRow
Input row on which current token starts, 1-based


mTokenInputCol

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


mTextBuffer

protected final TextBuffer mTextBuffer
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)

Constructor Detail

ReaderBasedParserBase

protected ReaderBasedParserBase(IOContext ctxt,
                                Reader r)
Method Detail

getTokenCharacterOffset

public final long getTokenCharacterOffset()

getTokenLineNr

public final int getTokenLineNr()

getTokenColumnNr

public final int getTokenColumnNr()

skipCR

protected final void skipCR()
                     throws IOException
Throws:
IOException

skipLF

protected final void skipLF()
                     throws IOException
Throws:
IOException

markLF

protected final void markLF()

markLF

protected final void markLF(int inputPtr)

loadMore

protected final boolean loadMore()
                          throws IOException
Throws:
IOException

getNextChar

protected char getNextChar(String eofMsg)
                    throws IOException,
                           JsonParseException
Throws:
IOException
JsonParseException

closeReader

protected void closeReader()
                    throws IOException
Throws:
IOException

releaseBuffers

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

Throws:
IOException

getCurrentLocation

public abstract JsonLocation getCurrentLocation()
Description copied from class: JsonParser
Method that returns location of the last processed character; usually for error reporting purposes.

Specified by:
getCurrentLocation in class JsonParser

getCharDesc

protected static String getCharDesc(int ch)

reportUnexpectedChar

protected void reportUnexpectedChar(int ch,
                                    String comment)
                             throws JsonParseException
Throws:
JsonParseException

reportInvalidEOF

protected void reportInvalidEOF(String msg)
                         throws JsonParseException
Throws:
JsonParseException

reportError

protected void reportError(String msg)
                    throws JsonParseException
Throws:
JsonParseException

wrapError

protected void wrapError(String msg,
                         Throwable t)
                  throws JsonParseException
Throws:
JsonParseException

throwInternal

protected void throwInternal()

JSON
Version 1.0

Apache License, Version 2.0