com.ctc.wstx.io
Class ReaderBootstrapper

java.lang.Object
  extended by com.ctc.wstx.io.InputBootstrapper
      extended by com.ctc.wstx.io.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 Summary
 
Fields inherited from class com.ctc.wstx.io.InputBootstrapper
BYTE_CR, BYTE_LF, BYTE_NULL, CHAR_CR, CHAR_LF, 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
 java.io.Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion)
          Method called to do actual bootstrapping.
protected  int checkKeyword(java.lang.String exp)
           
 int getInputColumn()
           
 java.lang.String getInputEncoding()
          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).
 int getInputTotal()
           
static ReaderBootstrapper getInstance(java.io.Reader r, java.lang.String pubId, java.lang.String sysId, java.lang.String appEncoding)
           
protected  javax.xml.stream.Location getLocation()
           
protected  int getNext()
           
protected  int getNextAfterWs(boolean reqWs)
           
protected  boolean initialLoad(int minimum)
           
protected  void loadMore()
           
protected  char nextChar()
           
protected  void pushback()
           
protected  int readQuotedValue(char[] kw, int quoteChar)
           
protected  void skipCRLF(char lf)
           
protected  void verifyXmlEncoding(ReaderConfig cfg)
           
 
Methods inherited from class com.ctc.wstx.io.InputBootstrapper
declaredXml11, getDeclaredEncoding, getDeclaredVersion, getInputRow, getPublicId, getStandalone, getSystemId, readXmlDecl, reportNull, reportUnexpectedChar, reportXmlProblem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ReaderBootstrapper getInstance(java.io.Reader r,
                                             java.lang.String pubId,
                                             java.lang.String sysId,
                                             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)

getInputColumn

public int getInputColumn()
Specified by:
getInputColumn in class InputBootstrapper

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

loadMore

protected void loadMore()
                 throws java.io.IOException,
                        WstxException
Throws:
java.io.IOException
WstxException

pushback

protected void pushback()
Specified by:
pushback in class InputBootstrapper

getNext

protected int getNext()
               throws java.io.IOException,
                      WstxException
Specified by:
getNext in class InputBootstrapper
Throws:
java.io.IOException
WstxException

getNextAfterWs

protected int getNextAfterWs(boolean reqWs)
                      throws java.io.IOException,
                             WstxException
Specified by:
getNextAfterWs in class InputBootstrapper
Throws:
java.io.IOException
WstxException

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

readQuotedValue

protected int readQuotedValue(char[] kw,
                              int quoteChar)
                       throws java.io.IOException,
                              WstxException
Specified by:
readQuotedValue in class InputBootstrapper
Throws:
java.io.IOException
WstxException

getLocation

protected javax.xml.stream.Location getLocation()
Specified by:
getLocation in class InputBootstrapper

nextChar

protected char nextChar()
                 throws java.io.IOException,
                        WstxException
Throws:
java.io.IOException
WstxException

skipCRLF

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