Class ByteSourceBootstrapper

  • All Implemented Interfaces:
    XmlConsts

    public final class ByteSourceBootstrapper
    extends InputBootstrapper
    Class that takes care of bootstrapping main document input from a byte-oriented input source: usually either an InputStream, or a block source like byte array.
    • Field Detail

      • _in

        protected final java.io.InputStream _in
        Underlying InputStream to use for reading content.
      • _inputBuffer

        protected final byte[] _inputBuffer
      • _inputPtr

        private int _inputPtr
      • _inputLen

        private int _inputLen
      • mBigEndian

        protected boolean mBigEndian
      • mBytesPerChar

        protected int mBytesPerChar
      • mHadBOM

        protected boolean mHadBOM
      • mByteSizeFound

        protected boolean mByteSizeFound
    • Constructor Detail

      • ByteSourceBootstrapper

        private ByteSourceBootstrapper​(ReaderConfig cfg,
                                       java.io.InputStream in)
      • ByteSourceBootstrapper

        private ByteSourceBootstrapper​(ReaderConfig cfg,
                                       byte[] inputBuffer,
                                       int inputStart,
                                       int inputLen)
    • Method Detail

      • construct

        public static ByteSourceBootstrapper construct​(ReaderConfig cfg,
                                                       java.io.InputStream in)
                                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • construct

        public static ByteSourceBootstrapper construct​(ReaderConfig cfg,
                                                       byte[] inputBuffer,
                                                       int inputStart,
                                                       int inputLen)
                                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • bootstrap

        public final XmlScanner bootstrap()
                                   throws javax.xml.stream.XMLStreamException
        Description copied from class: InputBootstrapper
        Main bootstrapping method, which will try to open the underlying input source, check its encoding, read xml declaration if there is one, and finally create a scanner for actual parsing.
        Specified by:
        bootstrap in class InputBootstrapper
        Throws:
        javax.xml.stream.XMLStreamException
      • doBootstrap

        public XmlScanner doBootstrap()
                               throws java.io.IOException,
                                      javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • determineStreamEncoding

        private void determineStreamEncoding()
                                      throws java.io.IOException
        Method called to figure out what the physical encoding of the file appears to be (in case it can be determined from BOM, or xml declaration, either of which may be present)
        Throws:
        java.io.IOException
      • hasXmlDeclaration

        protected boolean hasXmlDeclaration()
                                     throws java.io.IOException,
                                            javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • verifyXmlEncoding

        protected java.lang.String verifyXmlEncoding​(java.lang.String enc)
                                              throws javax.xml.stream.XMLStreamException
        Returns:
        Normalized encoding name
        Throws:
        javax.xml.stream.XMLStreamException
      • ensureLoaded

        protected boolean ensureLoaded​(int minimum)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • loadMore

        protected void loadMore()
                         throws java.io.IOException,
                                javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • getNext

        protected int getNext()
                       throws java.io.IOException,
                              javax.xml.stream.XMLStreamException
        Specified by:
        getNext in class InputBootstrapper
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • getNextAfterWs

        protected int getNextAfterWs​(boolean reqWs)
                              throws java.io.IOException,
                                     javax.xml.stream.XMLStreamException
        Specified by:
        getNextAfterWs in class InputBootstrapper
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • checkKeyword

        protected int checkKeyword​(java.lang.String exp)
                            throws java.io.IOException,
                                   javax.xml.stream.XMLStreamException
        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
        javax.xml.stream.XMLStreamException
      • readQuotedValue

        protected int readQuotedValue​(char[] kw,
                                      int quoteChar)
                               throws java.io.IOException,
                                      javax.xml.stream.XMLStreamException
        Specified by:
        readQuotedValue in class InputBootstrapper
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • nextByte

        protected byte nextByte()
                         throws java.io.IOException,
                                javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • skipSbWs

        protected int skipSbWs()
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • skipSbLF

        protected void skipSbLF​(byte lfByte)
                         throws java.io.IOException,
                                javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • checkSbKeyword

        protected int checkSbKeyword​(java.lang.String expected)
                              throws java.io.IOException,
                                     javax.xml.stream.XMLStreamException
        Returns:
        First character that does not match expected, if any; CHAR_NULL if match succeeded
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • nextMultiByte

        protected int nextMultiByte()
                             throws java.io.IOException,
                                    javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • skipMbWs

        protected int skipMbWs()
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • skipMbLF

        protected void skipMbLF​(int lf)
                         throws java.io.IOException,
                                javax.xml.stream.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • checkMbKeyword

        protected int checkMbKeyword​(java.lang.String expected)
                              throws java.io.IOException,
                                     javax.xml.stream.XMLStreamException
        Returns:
        First character that does not match expected, if any; CHAR_NULL if match succeeded
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • verifyEncoding

        private void verifyEncoding​(java.lang.String id,
                                    int bpc)
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • verifyEncoding

        private void verifyEncoding​(java.lang.String id,
                                    int bpc,
                                    boolean bigEndian)
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportWeirdUCS4

        private void reportWeirdUCS4​(java.lang.String type)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • reportEBCDIC

        private void reportEBCDIC()
                           throws java.io.IOException
        Throws:
        java.io.IOException