Package com.ctc.wstx.io
Class StreamBootstrapper
- java.lang.Object
-
- com.ctc.wstx.io.InputBootstrapper
-
- com.ctc.wstx.io.StreamBootstrapper
-
public final class StreamBootstrapper extends InputBootstrapper
Input bootstrap class used with streams, when encoding is not known (when encoding is specified by application, a reader is constructed, and then reader-based bootstrapper is used).-
-
Field Summary
-
Fields inherited from class com.ctc.wstx.io.InputBootstrapper
BYTE_CR, BYTE_LF, BYTE_NULL, CHAR_CR, CHAR_LF, CHAR_NEL, CHAR_NULL, CHAR_SPACE, 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, mInputProcessed, mInputRow, mInputRowStart, mPublicId, mSystemId
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ReaderbootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion)protected intcheckKeyword(String exp)protected intcheckMbKeyword(String expected)protected intcheckSbKeyword(String expected)protected intcheckTranslatedKeyword(String expected)protected booleanensureLoaded(int minimum)intgetInputColumn()StringgetInputEncoding()Since this class only gets used when encoding is not explicitly passed, need use the encoding that was auto-detected...intgetInputTotal()static StreamBootstrappergetInstance(String pubId, SystemId sysId, byte[] data, int start, int end)Factory method used when the underlying data provider is a pre-allocated block source, and no stream is used.static StreamBootstrappergetInstance(String pubId, SystemId sysId, InputStream in)Factory method used when the underlying data provider is an actual stream.protected LocationgetLocation()protected intgetNext()protected intgetNextAfterWs(boolean reqWs)protected booleanhasXmlDecl()protected voidloadMore()protected bytenextByte()protected intnextMultiByte()protected intnextTranslated()protected voidpushback()protected intreadQuotedValue(char[] kw, int quoteChar)protected voidresolveStreamEncoding()Method called to try to figure out physical encoding the underlying input stream uses.protected voidskipMbLF(int lf)protected intskipMbWs()protected voidskipSbLF(byte lfByte)protected intskipSbWs()protected voidskipTranslatedLF(int lf)protected intskipTranslatedWs()protected StringverifyXmlEncoding(String enc)-
Methods inherited from class com.ctc.wstx.io.InputBootstrapper
declaredXml11, getDeclaredEncoding, getDeclaredVersion, getInputRow, getPublicId, getStandalone, getSystemId, initFrom, readXmlDecl, reportNull, reportUnexpectedChar, reportXmlProblem
-
-
-
-
Method Detail
-
getInstance
public static StreamBootstrapper getInstance(String pubId, SystemId sysId, InputStream in)
Factory method used when the underlying data provider is an actual stream.
-
getInstance
public static StreamBootstrapper getInstance(String pubId, SystemId sysId, byte[] data, int start, int end)
Factory method used when the underlying data provider is a pre-allocated block source, and no stream is used. Additionally the buffer passed is not owned by the bootstrapper or Reader that is created, so it is not to be recycled.
-
bootstrapInput
public Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion) throws IOException, XMLStreamException
- Specified by:
bootstrapInputin classInputBootstrapperxmlVersion- 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.- Throws:
IOExceptionXMLStreamException
-
getInputEncoding
public String getInputEncoding()
Since this class only gets used when encoding is not explicitly passed, need use the encoding that was auto-detected...- Specified by:
getInputEncodingin classInputBootstrapper- Returns:
- Input encoding in use, if it could be determined or was passed by the calling application
-
getInputTotal
public int getInputTotal()
- Specified by:
getInputTotalin classInputBootstrapper- Returns:
- Total number of characters read from bootstrapped input (stream, reader)
-
getInputColumn
public int getInputColumn()
- Specified by:
getInputColumnin classInputBootstrapper
-
resolveStreamEncoding
protected void resolveStreamEncoding() throws IOException, WstxExceptionMethod called to try to figure out physical encoding the underlying input stream uses.- Throws:
IOExceptionWstxException
-
verifyXmlEncoding
protected String verifyXmlEncoding(String enc) throws WstxException
- Returns:
- Normalized encoding name
- Throws:
WstxException
-
ensureLoaded
protected boolean ensureLoaded(int minimum) throws IOException- Throws:
IOException
-
loadMore
protected void loadMore() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
pushback
protected void pushback()
- Specified by:
pushbackin classInputBootstrapper
-
getNext
protected int getNext() throws IOException, WstxException- Specified by:
getNextin classInputBootstrapper- Throws:
IOExceptionWstxException
-
getNextAfterWs
protected int getNextAfterWs(boolean reqWs) throws IOException, WstxException- Specified by:
getNextAfterWsin classInputBootstrapper- Throws:
IOExceptionWstxException
-
checkKeyword
protected int checkKeyword(String exp) throws IOException, WstxException
- Specified by:
checkKeywordin classInputBootstrapper- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOExceptionWstxException
-
readQuotedValue
protected int readQuotedValue(char[] kw, int quoteChar) throws IOException, WstxException- Specified by:
readQuotedValuein classInputBootstrapper- Throws:
IOExceptionWstxException
-
hasXmlDecl
protected boolean hasXmlDecl() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
getLocation
protected Location getLocation()
- Specified by:
getLocationin classInputBootstrapper
-
nextByte
protected byte nextByte() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipSbWs
protected int skipSbWs() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipSbLF
protected void skipSbLF(byte lfByte) throws IOException, WstxException- Throws:
IOExceptionWstxException
-
checkSbKeyword
protected int checkSbKeyword(String expected) throws IOException, WstxException
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOExceptionWstxException
-
nextMultiByte
protected int nextMultiByte() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
nextTranslated
protected int nextTranslated() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipMbWs
protected int skipMbWs() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipTranslatedWs
protected int skipTranslatedWs() throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipMbLF
protected void skipMbLF(int lf) throws IOException, WstxException- Throws:
IOExceptionWstxException
-
skipTranslatedLF
protected void skipTranslatedLF(int lf) throws IOException, WstxException- Throws:
IOExceptionWstxException
-
checkMbKeyword
protected int checkMbKeyword(String expected) throws IOException, WstxException
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOExceptionWstxException
-
checkTranslatedKeyword
protected int checkTranslatedKeyword(String expected) throws IOException, WstxException
- Throws:
IOExceptionWstxException
-
-
-