Package com.ctc.wstx.io
Class InputBootstrapper
java.lang.Object
com.ctc.wstx.io.InputBootstrapper
- Direct Known Subclasses:
ReaderBootstrapper,StreamBootstrapper
Abstract base class that defines common API used with both stream and
reader-based input sources. Class is responsible for opening the physical
input source, figure out encoding (if necessary; only for streams), and
then handle (optional) XML declaration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final charstatic final charstatic final charprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected intXML declaration from the input (1.0, 1.1 or 'unknown')protected StringValue of encoding pseudo-attribute from xml declaration, if one was found; null otherwise.protected intCurrent number of characters that were processed in previous blocks, before contents of current input buffer.protected intCurrent row location of current point in input buffer, starting from 1protected intCurrent index of the first character of the current row in input buffer.protected final char[]Need a short buffer to read in values of pseudo-attributes (version, encoding, standalone).protected final Stringprotected Stringprotected final SystemIdprotected booleanFlag that indicates whether input read from this input source needs to be xml 1.1 compliant or not; if not, xml 1.0 is assumed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ReaderbootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion) protected abstract intcheckKeyword(String exp) booleanintabstract intabstract StringActual 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).intabstract intprotected abstract Locationprotected abstract intgetNext()protected abstract intgetNextAfterWs(boolean reqWs) private final intgetWsOrChar(int ok) Method that should get next character, which has to be either specified character (usually end marker), OR, any character as long as there' at least one space character before it.private final intprotected voidprotected abstract voidpushback()protected abstract intreadQuotedValue(char[] kw, int quoteChar) protected voidreadXmlDecl(boolean isMainDoc, int xmlVersion) private final Stringprivate final Stringprivate final intprotected voidprivate final voidreportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2) protected voidreportUnexpectedChar(int i, String msg) protected voidreportXmlProblem(String msg)
-
Field Details
-
ERR_XMLDECL_KW_VERSION
- See Also:
-
ERR_XMLDECL_KW_ENCODING
- See Also:
-
ERR_XMLDECL_KW_STANDALONE
- See Also:
-
ERR_XMLDECL_END_MARKER
- See Also:
-
ERR_XMLDECL_EXP_SPACE
- See Also:
-
ERR_XMLDECL_EXP_EQ
- See Also:
-
ERR_XMLDECL_EXP_ATTRVAL
- See Also:
-
CHAR_NULL
public static final char CHAR_NULL- See Also:
-
CHAR_SPACE
public static final char CHAR_SPACE- See Also:
-
CHAR_NEL
public static final char CHAR_NEL- See Also:
-
CHAR_CR
public static final byte CHAR_CR- See Also:
-
CHAR_LF
public static final byte CHAR_LF- See Also:
-
BYTE_NULL
public static final byte BYTE_NULL- See Also:
-
BYTE_CR
public static final byte BYTE_CR- See Also:
-
BYTE_LF
public static final byte BYTE_LF- See Also:
-
mPublicId
-
mSystemId
-
mInputProcessed
protected int mInputProcessedCurrent number of characters that were processed in previous blocks, before contents of current input buffer. -
mInputRow
protected int mInputRowCurrent row location of current point in input buffer, starting from 1 -
mInputRowStart
protected int mInputRowStartCurrent index of the first character of the current row in input buffer. Needed to calculate column position, if necessary; benefit of not having column itself is that this only has to be updated once per line. -
mDeclaredXmlVersion
protected int mDeclaredXmlVersionXML declaration from the input (1.0, 1.1 or 'unknown') -
mFoundEncoding
Value of encoding pseudo-attribute from xml declaration, if one was found; null otherwise. -
mStandalone
-
mXml11Handling
protected boolean mXml11HandlingFlag that indicates whether input read from this input source needs to be xml 1.1 compliant or not; if not, xml 1.0 is assumed. State of this flag depends on parent context (if one existed), or if not, on xml declaration of this input source. -
mKeywordBuffer
protected final char[] mKeywordBufferNeed a short buffer to read in values of pseudo-attributes (version, encoding, standalone). Don't really need tons of space; just enough for the longest anticipated encoding id... and maybe few chars just in case (for additional white space that we ignore)
-
-
Constructor Details
-
InputBootstrapper
-
-
Method Details
-
initFrom
-
bootstrapInput
public abstract Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion) throws IOException, XMLStreamException - Parameters:
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.- Throws:
IOExceptionXMLStreamException
-
getPublicId
-
getSystemId
-
getDeclaredVersion
public int getDeclaredVersion() -
declaredXml11
public boolean declaredXml11()- Returns:
- True, if the input bootstrapped declared that it conforms to xml 1.1 (independent of where it was included from)
-
getStandalone
-
getDeclaredEncoding
- Returns:
- Encoding declaration found from the xml declaration, if any; null if none.
-
getInputTotal
public abstract int getInputTotal()- Returns:
- Total number of characters read from bootstrapped input (stream, reader)
-
getInputRow
public int getInputRow() -
getInputColumn
public abstract int getInputColumn() -
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).- Returns:
- Input encoding in use, if it could be determined or was passed by the calling application
-
readXmlDecl
- Parameters:
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.- Throws:
IOExceptionWstxException
-
readXmlVersion
- Returns:
- Xml version declaration read
- Throws:
IOExceptionWstxException
-
readXmlEncoding
- Throws:
IOExceptionWstxException
-
readXmlStandalone
- Throws:
IOExceptionWstxException
-
handleEq
- Throws:
IOExceptionWstxException
-
getWsOrChar
Method that should get next character, which has to be either specified character (usually end marker), OR, any character as long as there' at least one space character before it.- Throws:
IOExceptionWstxException
-
pushback
protected abstract void pushback() -
getNext
- Throws:
IOExceptionWstxException
-
getNextAfterWs
- Throws:
IOExceptionWstxException
-
checkKeyword
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
IOExceptionWstxException
-
readQuotedValue
- Throws:
IOExceptionWstxException
-
getLocation
-
reportNull
- Throws:
WstxException
-
reportXmlProblem
- Throws:
WstxException
-
reportUnexpectedChar
- Throws:
WstxException
-
reportPseudoAttrProblem
private final void reportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2) throws WstxException - Throws:
WstxException
-