Package com.fasterxml.aalto.in
Class ByteSourceBootstrapper
java.lang.Object
com.fasterxml.aalto.in.InputBootstrapper
com.fasterxml.aalto.in.ByteSourceBootstrapper
- All Implemented Interfaces:
XmlConsts
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final InputStream
Underlying InputStream to use for reading content.protected final byte[]
private int
private int
private static final byte
private static final byte
private static final byte
protected boolean
protected boolean
protected int
protected boolean
Fields inherited from class com.fasterxml.aalto.in.InputBootstrapper
_config, _inputProcessed, _inputRow, _inputRowStart, ERR_XMLDECL_END_MARKER, ERR_XMLDECL_EXP_ATTRVAL, ERR_XMLDECL_EXP_EQ, ERR_XMLDECL_EXP_SPACE, ERR_XMLDECL_KW_ENCODING, ERR_XMLDECL_KW_STANDALONE, ERR_XMLDECL_KW_VERSION, mDeclaredXmlVersion, mFoundEncoding, mKeyword, mStandalone
Fields inherited from interface com.fasterxml.aalto.util.XmlConsts
CHAR_CR, CHAR_LF, CHAR_NULL, CHAR_SPACE, MAX_UNICODE_CHAR, STAX_DEFAULT_OUTPUT_ENCODING, STAX_DEFAULT_OUTPUT_VERSION, XML_DECL_KW_ENCODING, XML_DECL_KW_STANDALONE, XML_DECL_KW_VERSION, XML_SA_NO, XML_SA_YES, XML_V_10, XML_V_10_STR, XML_V_11, XML_V_11_STR, XML_V_UNKNOWN
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ByteSourceBootstrapper
(ReaderConfig cfg, byte[] inputBuffer, int inputStart, int inputLen) private
-
Method Summary
Modifier and TypeMethodDescriptionfinal XmlScanner
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.protected int
checkKeyword
(String exp) protected int
checkMbKeyword
(String expected) protected int
checkSbKeyword
(String expected) static ByteSourceBootstrapper
construct
(ReaderConfig cfg, byte[] inputBuffer, int inputStart, int inputLen) static ByteSourceBootstrapper
construct
(ReaderConfig cfg, InputStream in) private void
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)protected boolean
ensureLoaded
(int minimum) protected Location
protected int
getNext()
protected int
getNextAfterWs
(boolean reqWs) protected boolean
protected void
loadMore()
protected byte
nextByte()
protected int
protected void
pushback()
protected int
readQuotedValue
(char[] kw, int quoteChar) private void
private void
reportWeirdUCS4
(String type) protected void
skipMbLF
(int lf) protected int
skipMbWs()
protected void
skipSbLF
(byte lfByte) protected int
skipSbWs()
private void
verifyEncoding
(String id, int bpc) private void
verifyEncoding
(String id, int bpc, boolean bigEndian) protected String
verifyXmlEncoding
(String enc) Methods inherited from class com.fasterxml.aalto.in.InputBootstrapper
readXmlDeclaration, reportEof, reportNull, reportPseudoAttrProblem, reportUnexpectedChar, reportXmlProblem
-
Field Details
-
BYTE_NULL
private static final byte BYTE_NULL- See Also:
-
BYTE_CR
private static final byte BYTE_CR- See Also:
-
BYTE_LF
private static final byte BYTE_LF- See Also:
-
_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 Details
-
ByteSourceBootstrapper
-
ByteSourceBootstrapper
-
-
Method Details
-
construct
public static ByteSourceBootstrapper construct(ReaderConfig cfg, InputStream in) throws XMLStreamException - Throws:
XMLStreamException
-
construct
public static ByteSourceBootstrapper construct(ReaderConfig cfg, byte[] inputBuffer, int inputStart, int inputLen) throws XMLStreamException - Throws:
XMLStreamException
-
bootstrap
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 classInputBootstrapper
- Throws:
XMLStreamException
-
doBootstrap
- Throws:
IOException
XMLStreamException
-
determineStreamEncoding
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:
IOException
-
hasXmlDeclaration
- Throws:
IOException
XMLStreamException
-
verifyXmlEncoding
- Returns:
- Normalized encoding name
- Throws:
XMLStreamException
-
ensureLoaded
- Throws:
IOException
-
loadMore
- Throws:
IOException
XMLStreamException
-
pushback
protected void pushback()- Specified by:
pushback
in classInputBootstrapper
-
getNext
- Specified by:
getNext
in classInputBootstrapper
- Throws:
IOException
XMLStreamException
-
getNextAfterWs
- Specified by:
getNextAfterWs
in classInputBootstrapper
- Throws:
IOException
XMLStreamException
-
checkKeyword
- Specified by:
checkKeyword
in classInputBootstrapper
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOException
XMLStreamException
-
readQuotedValue
- Specified by:
readQuotedValue
in classInputBootstrapper
- Throws:
IOException
XMLStreamException
-
getLocation
- Specified by:
getLocation
in classInputBootstrapper
-
nextByte
- Throws:
IOException
XMLStreamException
-
skipSbWs
- Throws:
IOException
XMLStreamException
-
skipSbLF
- Throws:
IOException
XMLStreamException
-
checkSbKeyword
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOException
XMLStreamException
-
nextMultiByte
- Throws:
IOException
XMLStreamException
-
skipMbWs
- Throws:
IOException
XMLStreamException
-
skipMbLF
- Throws:
IOException
XMLStreamException
-
checkMbKeyword
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOException
XMLStreamException
-
verifyEncoding
- Throws:
XMLStreamException
-
verifyEncoding
- Throws:
XMLStreamException
-
reportWeirdUCS4
- Throws:
IOException
-
reportEBCDIC
- Throws:
IOException
-