@Override
    public Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion)
        throws IOException, XMLStreamException
    {
        /* First order of business: allocate input buffer. Not done during
         * construction for simplicity; that way config object need not be
         * passed before actual bootstrap method is called
         */
        /* Let's make sure buffer is at least 6 chars (to know '<?xml '
         * prefix), and preferably big enough to contain the whole declaration,
         *  but not too long to waste space -- it won't be reused
         * by the real input reader.
         */
        mCharBuffer = (cfg == null) ? new char[128] : cfg.allocSmallCBuffer(128); // 128 chars should be enough

        initialLoad(7);

        /* Only need 6 for signature ("<?xml\s"), but there may be a leading
         * BOM in there... and a valid xml declaration has to be longer
         * than 7 chars anyway (although, granted, shortest valid xml docl
         * is just 4 chars... "<a/>")
         */
        if (mInputEnd >= 7) {
            char c = mCharBuffer[mInputPtr];
            
            // BOM to skip?
            if (c == CHAR_BOM_MARKER) {
                c = mCharBuffer[++mInputPtr];
            }
            if (c == '<') {
                if (mCharBuffer[mInputPtr+1] == '?'
                    && mCharBuffer[mInputPtr+2] == 'x'
                    && mCharBuffer[mInputPtr+3] == 'm'
                    && mCharBuffer[mInputPtr+4] == 'l'
                    && mCharBuffer[mInputPtr+5] <= CHAR_SPACE) {
                    // Yup, got the declaration ok!
                    mInputPtr += 6; // skip declaration
                    readXmlDecl(mainDoc, xmlVersion);
                    
                    if (mFoundEncoding != null && mInputEncoding != null) {
                        verifyXmlEncoding(cfg);
                    }
                }
            } else {
                /* We may also get something that would be invalid xml
                 * ("garbage" char; neither '<' nor space). If so, and
                 * it's one of "well-known" cases, we can not only throw
                 * an exception but also indicate a clue as to what is likely
                 * to be wrong.
                 */
                /* Specifically, UTF-8 read via, say, ISO-8859-1 reader, can
                 * "leak" marker (0xEF, 0xBB, 0xBF). While we could just eat
                 * it, there's bound to be other problems cropping up, so let's
                 * inform about the problem right away.
                 */
                if (c == 0xEF) {
                    throw new WstxIOException("Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead");
                }
            }
        }
 
        /* Ok, now; do we have unused chars we have read that need to
         * be merged in?
         */
        if (mInputPtr < mInputEnd) {
            return new MergedReader(cfg, mIn, mCharBuffer, mInputPtr, mInputEnd);
        }

        return mIn;
    }
@ Override public Reader bootstrapInput ( ReaderConfig cfg , boolean mainDoc , int xmlVersion ) throws IOException , XMLStreamException { mCharBuffer = ( cfg == null ) ? new char [ 128 ] : cfg . allocSmallCBuffer ( 128 ) ; initialLoad ( 7 ) ; if ( mInputEnd >= 7 ) { char c = mCharBuffer [ mInputPtr ] ; if ( c == CHAR_BOM_MARKER ) { c = mCharBuffer [ ++ mInputPtr ] ; } if ( c == '<' ) { if ( mCharBuffer [ mInputPtr + 1 ] == '?' && mCharBuffer [ mInputPtr + 2 ] == 'x' && mCharBuffer [ mInputPtr + 3 ] == 'm' && mCharBuffer [ mInputPtr + 4 ] == 'l' && mCharBuffer [ mInputPtr + 5 ] <= CHAR_SPACE ) { mInputPtr += 6 ; readXmlDecl ( mainDoc , xmlVersion ) ; if ( mFoundEncoding != null && mInputEncoding != null ) { verifyXmlEncoding ( cfg ) ; } } } else { if ( c == 0xEF ) { throw new WstxIOException ( "Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead" ) ; } } } if ( mInputPtr < mInputEnd ) { return new MergedReader ( cfg , mIn , mCharBuffer , mInputPtr , mInputEnd ) ; } return mIn ; }
Method called to do actual bootstrapping.

@return Actual reader to use for reading xml content