Class StreamBasedParserBase

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Versioned

    @Deprecated
    public abstract class StreamBasedParserBase
    extends JsonParserBase
    Deprecated.
    Since 1.9, sub-classes should just embed code from here
    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 Detail

      • _inputStream

        protected java.io.InputStream _inputStream
        Deprecated.
        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
        Deprecated.
        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
        Deprecated.
        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.

    • Constructor Detail

      • StreamBasedParserBase

        protected StreamBasedParserBase​(IOContext ctxt,
                                        int features,
                                        java.io.InputStream in,
                                        byte[] inputBuffer,
                                        int start,
                                        int end,
                                        boolean bufferRecyclable)
        Deprecated.
    • Method Detail

      • releaseBuffered

        public int releaseBuffered​(java.io.OutputStream out)
                            throws java.io.IOException
        Deprecated.
        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:
        java.io.IOException - if write to stream threw exception
      • getInputSource

        public java.lang.Object getInputSource()
        Deprecated.
        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 java.io.IOException
        Deprecated.
        Specified by:
        loadMore in class JsonParserBase
        Throws:
        java.io.IOException
      • _loadToHaveAtLeast

        protected final boolean _loadToHaveAtLeast​(int minAvailable)
                                            throws java.io.IOException
        Deprecated.
        Helper method that will try to load at least specified number bytes in input buffer, possible moving existing data around if necessary
        Throws:
        java.io.IOException
        Since:
        1.6
      • _closeInput

        protected void _closeInput()
                            throws java.io.IOException
        Deprecated.
        Specified by:
        _closeInput in class JsonParserBase
        Throws:
        java.io.IOException
      • _releaseBuffers

        protected void _releaseBuffers()
                                throws java.io.IOException
        Deprecated.
        Description copied from class: JsonParserBase
        Method called to release internal buffers owned by the base reader. This may be called along with JsonParserBase._closeInput() (for example, when explicitly closing this reader instance), or separately (if need be).
        Overrides:
        _releaseBuffers in class JsonParserBase
        Throws:
        java.io.IOException