org.codehaus.jackson.impl
Class StreamBasedParserBase
java.lang.Object
org.codehaus.jackson.JsonParser
org.codehaus.jackson.impl.JsonParserMinimalBase
org.codehaus.jackson.impl.JsonParserBase
org.codehaus.jackson.impl.JsonNumericParserBase
org.codehaus.jackson.impl.StreamBasedParserBase
- All Implemented Interfaces:
- Closeable, Versioned
- Direct Known Subclasses:
- SmileParser, Utf8StreamParser
public abstract class StreamBasedParserBase
- extends JsonNumericParserBase
This is a simple low-level input reader base class, used by
JSON parser. It is used when underlying input source is
a byte stream such as InputStream
.
The reason for sub-classing (over composition)
is due to need for direct access to low-level byte buffers
and positions.
- Author:
- Tatu Saloranta
Field Summary |
protected boolean |
_bufferRecyclable
Flag that indicates whether the input buffer is recycable (and
needs to be returned to recycler once we are done) or not. |
protected byte[] |
_inputBuffer
Current buffer from which data is read; generally data is read into
buffer from input source, but in some cases pre-loaded buffer
is handed to the parser. |
protected InputStream |
_inputStream
Input stream that can be used for reading more content, if one
in use. |
Fields inherited from class org.codehaus.jackson.impl.JsonNumericParserBase |
_expLength, _fractLength, _intLength, _numberBigDecimal, _numberBigInt, _numberDouble, _numberInt, _numberLong, _numberNegative, _numTypesValid, CHAR_NULL, INT_0, INT_1, INT_2, INT_3, INT_4, INT_5, INT_6, INT_7, INT_8, INT_9, INT_DECIMAL_POINT, INT_e, INT_E, INT_MINUS, INT_PLUS, NR_BIGDECIMAL, NR_BIGINT, NR_DOUBLE, NR_INT, NR_LONG, NR_UNKNOWN |
Fields inherited from class org.codehaus.jackson.impl.JsonParserBase |
_binaryValue, _byteArrayBuilder, _closed, _currInputProcessed, _currInputRow, _currInputRowStart, _inputEnd, _inputPtr, _ioContext, _nameCopied, _nameCopyBuffer, _nextToken, _parsingContext, _textBuffer, _tokenInputCol, _tokenInputRow, _tokenInputTotal |
Fields inherited from class org.codehaus.jackson.impl.JsonParserMinimalBase |
INT_APOSTROPHE, INT_ASTERISK, INT_b, INT_BACKSLASH, INT_COLON, INT_COMMA, INT_CR, INT_f, INT_LBRACKET, INT_LCURLY, INT_LF, INT_n, INT_QUOTE, INT_r, INT_RBRACKET, INT_RCURLY, INT_SLASH, INT_SPACE, INT_t, INT_TAB, INT_u |
Method Summary |
protected void |
_closeInput()
|
protected boolean |
_loadToHaveAtLeast(int minAvailable)
Helper method that will try to load at least specified number bytes in
input buffer, possible moving existing data around if necessary |
protected void |
_releaseBuffers()
Method called to release internal buffers owned by the base
reader. |
Object |
getInputSource()
Method that can be used to get access to object that is used
to access input being parsed; this is usually either
InputStream or Reader , depending on what
parser was constructed with. |
protected boolean |
loadMore()
|
int |
releaseBuffered(OutputStream out)
Method that can be called to push back any content that
has been read but not consumed by the parser. |
Methods inherited from class org.codehaus.jackson.impl.JsonNumericParserBase |
_parseNumericValue, convertNumberToBigDecimal, convertNumberToBigInteger, convertNumberToDouble, convertNumberToInt, convertNumberToLong, getBigIntegerValue, getDecimalValue, getDoubleValue, getFloatValue, getIntValue, getLongValue, getNumberType, getNumberValue, reportInvalidNumber, reportOverflowInt, reportOverflowLong, reportUnexpectedNumberChar, reset, resetAsNaN, resetFloat, resetInt |
Methods inherited from class org.codehaus.jackson.impl.JsonParserBase |
_decodeBase64, _finishString, _getByteArrayBuilder, _handleEOF, _reportMismatchedEndMarker, close, getCurrentLocation, getCurrentName, getParsingContext, getTokenCharacterOffset, getTokenColumnNr, getTokenLineNr, getTokenLocation, hasTextCharacters, isClosed, loadMoreGuaranteed, version |
Methods inherited from class org.codehaus.jackson.impl.JsonParserMinimalBase |
_constructError, _getCharDesc, _handleUnrecognizedCharacterEscape, _reportError, _reportInvalidEOF, _reportInvalidEOF, _reportInvalidEOFInValue, _reportUnexpectedChar, _throwInternal, _throwInvalidSpace, _throwUnquotedSpace, _wrapError, getBinaryValue, getText, getTextCharacters, getTextLength, getTextOffset, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsLong, nextToken, skipChildren |
Methods inherited from class org.codehaus.jackson.JsonParser |
_constructError, canUseSchema, clearCurrentToken, configure, disable, disableFeature, enable, enableFeature, getBinaryValue, getBooleanValue, getByteValue, getCodec, getCurrentToken, getEmbeddedObject, getLastClearedToken, getShortValue, getValueAsBoolean, getValueAsDouble, getValueAsInt, getValueAsLong, hasCurrentToken, isEnabled, isExpectedStartArrayToken, isFeatureEnabled, nextValue, readValueAs, readValueAs, readValueAsTree, releaseBuffered, setCodec, setFeature, setSchema |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_inputStream
protected InputStream _inputStream
- Input stream 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 the stream has been closed.
_inputBuffer
protected byte[] _inputBuffer
- Current buffer from which data is read; generally data is read into
buffer from input source, but in some cases pre-loaded buffer
is handed to the parser.
_bufferRecyclable
protected boolean _bufferRecyclable
- Flag that indicates whether the input buffer is recycable (and
needs to be returned to recycler once we are done) or not.
If it is not, it also means that parser can NOT modify underlying
buffer.
StreamBasedParserBase
protected StreamBasedParserBase(IOContext ctxt,
int features,
InputStream in,
byte[] inputBuffer,
int start,
int end,
boolean bufferRecyclable)
releaseBuffered
public int releaseBuffered(OutputStream out)
throws IOException
- Description copied from class:
JsonParser
- Method that can be called to push back any content that
has been read but not consumed by the parser. This is usually
done after reading all content of interest using parser.
Content is released by writing it to given stream if possible;
if underlying input is byte-based it can released, if not (char-based)
it can not.
- Overrides:
releaseBuffered
in class JsonParser
- Returns:
- -1 if the underlying content source is not byte based
(that is, input can not be sent to
OutputStream
;
otherwise number of bytes released (0 if there was nothing to release)
- Throws:
IOException
- if write to stream threw exception
getInputSource
public Object getInputSource()
- Description copied from class:
JsonParser
- Method that can be used to get access to object that is used
to access input being parsed; this is usually either
InputStream
or Reader
, depending on what
parser was constructed with.
Note that returned value may be null in some cases; including
case where parser implementation does not want to exposed raw
source to caller.
In cases where input has been decorated, object returned here
is the decorated version; this allows some level of interaction
between users of parser and decorator object.
In general use of this accessor should be considered as
"last effort", i.e. only used if no other mechanism is applicable.
- Overrides:
getInputSource
in class JsonParser
loadMore
protected final boolean loadMore()
throws IOException
- Specified by:
loadMore
in class JsonParserBase
- Throws:
IOException
_loadToHaveAtLeast
protected final boolean _loadToHaveAtLeast(int minAvailable)
throws IOException
- Helper method that will try to load at least specified number bytes in
input buffer, possible moving existing data around if necessary
- Throws:
IOException
- Since:
- 1.6
_closeInput
protected void _closeInput()
throws IOException
- Specified by:
_closeInput
in class JsonParserBase
- 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
_closeInput()
(for
example, when explicitly closing this reader instance), or
separately (if need be).
- Overrides:
_releaseBuffers
in class JsonParserBase
- Throws:
IOException