Class ReaderBootstrapper


  • public final class ReaderBootstrapper
    extends InputBootstrapper
    Input bootstrap class used when input comes from a Reader; in this case, encoding is already known, and thus encoding from XML declaration (if any) is only double-checked, not really used.

    Note: since the actual Reader to use after bootstrapping is pre-constructed, the local input buffer can (and should) be quite small.

    • Field Detail

      • mIn

        final java.io.Reader mIn
        Underlying Reader to use for reading content.
      • mInputEncoding

        final java.lang.String mInputEncoding
        Encoding identifier processing application passed in; if not null, will be compared to actual xml declaration based encoding (if declaration found)
      • mCharBuffer

        private char[] mCharBuffer
      • mInputPtr

        private int mInputPtr
      • mInputEnd

        private int mInputEnd
    • Constructor Detail

      • ReaderBootstrapper

        private ReaderBootstrapper​(java.lang.String pubId,
                                   SystemId sysId,
                                   java.io.Reader r,
                                   java.lang.String appEncoding)
    • Method Detail

      • getInstance

        public static ReaderBootstrapper getInstance​(java.lang.String pubId,
                                                     SystemId sysId,
                                                     java.io.Reader r,
                                                     java.lang.String appEncoding)
        Parameters:
        r - Eventual reader that will be reading actual content, after bootstrapping finishes
        appEncoding - Encoding that application declared; may be null. If not null, will be compared to actual declaration found; and incompatibility reported as a potential (but not necessarily fatal) problem.
      • bootstrapInput

        public java.io.Reader bootstrapInput​(ReaderConfig cfg,
                                             boolean mainDoc,
                                             int xmlVersion)
                                      throws java.io.IOException,
                                             javax.xml.stream.XMLStreamException
        Method called to do actual bootstrapping.
        Specified by:
        bootstrapInput in class InputBootstrapper
        xmlVersion - Optional xml version identifier of the main parsed document (if not bootstrapping the main document). Currently only relevant for checking that XML 1.0 document does not include XML 1.1 external parsed entities. If null, no checks will be done; when bootstrapping parsing of the main document, null should be passed for this argument.
        Returns:
        Actual reader to use for reading xml content
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • getInputEncoding

        public java.lang.String getInputEncoding()
        Description copied from class: InputBootstrapper
        Actual character encoding used by the underlying input source; may have been passed by the application, or auto-detected by byte stream boot strapper (can not be determined from a Reader source).
        Specified by:
        getInputEncoding in class InputBootstrapper
        Returns:
        Input encoding in use, if it could be determined or was passed by the calling application
      • getInputTotal

        public int getInputTotal()
        Specified by:
        getInputTotal in class InputBootstrapper
        Returns:
        Total number of characters read from bootstrapped input (stream, reader)
      • verifyXmlEncoding

        protected void verifyXmlEncoding​(ReaderConfig cfg)
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • initialLoad

        protected boolean initialLoad​(int minimum)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • checkKeyword

        protected int checkKeyword​(java.lang.String exp)
                            throws java.io.IOException,
                                   WstxException
        Specified by:
        checkKeyword in class InputBootstrapper
        Returns:
        First character that does not match expected, if any; CHAR_NULL if match succeeded
        Throws:
        java.io.IOException
        WstxException
      • skipCRLF

        protected void skipCRLF​(char lf)
                         throws java.io.IOException,
                                WstxException
        Throws:
        java.io.IOException
        WstxException