Top Description Fields Constructors Methods
com.ctc.wstx.io

public abstract Class InputBootstrapper

extends Object
Class Inheritance
Known Direct Subclasses
com.ctc.wstx.io.ReaderBootstrapper, com.ctc.wstx.io.StreamBootstrapper
Imports
java.io.*, javax.xml.stream.Location, .XMLStreamException, com.ctc.wstx.api.ReaderConfig, com.ctc.wstx.cfg.ErrorConsts, .XmlConsts, com.ctc.wstx.exc.*

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

Modifier and TypeField and Description
public static final byte
public static final byte
public static final byte
public static final byte
public static final byte
public static final char
public static final char
public static final char
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected int
mDeclaredXmlVersion

XML declaration from the input (1.0, 1.1 or 'unknown')

protected String
mFoundEncoding

Value of encoding pseudo-attribute from xml declaration, if one was found; null otherwise.

protected int
mInputProcessed

Current number of characters that were processed in previous blocks, before contents of current input buffer.

protected int
mInputRow

Current row location of current point in input buffer, starting from 1

protected int
mInputRowStart

Current index of the first character of the current row in input buffer.

protected final char[]
mKeywordBuffer

Need a short buffer to read in values of pseudo-attributes (version, encoding, standalone).

protected final String
protected String
protected final SystemId
protected boolean
mXml11Handling

Flag 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

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract Reader
bootstrapInput(ReaderConfig cfg, boolean mainDoc, int
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.
xmlVersion
)

protected abstract int

Returns:

First character that does not match expected, if any; CHAR_NULL if match succeeded
checkKeyword
(String exp)

public boolean

Returns:

True, if the input bootstrapped declared that it conforms to xml 1.1 (independent of where it was included from)
declaredXml11
()

public String

Returns:

Encoding declaration found from the xml declaration, if any; null if none.
getDeclaredEncoding
()

public int
public abstract int
public abstract String

Returns:

Input encoding in use, if it could be determined or was passed by the calling application
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).

public int
public abstract int

Returns:

Total number of characters read from bootstrapped input (stream, reader)
getInputTotal
()

protected abstract Location
protected abstract int
protected abstract int
getNextAfterWs(boolean reqWs)

public String
public String
public SystemId
private final int
getWsOrChar(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 int
protected void
protected abstract void
protected abstract int
readQuotedValue(char[] kw, int quoteChar)

protected void
readXmlDecl(boolean isMainDoc, int
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.
xmlVersion
)

private final String
private final String
private final int

Returns:

Xml version declaration read
readXmlVersion
()

protected void
private final void
reportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2)

protected void
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BYTE_CRback to summary
public static final byte BYTE_CR
BYTE_LFback to summary
public static final byte BYTE_LF
BYTE_NULLback to summary
public static final byte BYTE_NULL
CHAR_CRback to summary
public static final byte CHAR_CR
CHAR_LFback to summary
public static final byte CHAR_LF
CHAR_NELback to summary
public static final char CHAR_NEL
CHAR_NULLback to summary
public static final char CHAR_NULL
CHAR_SPACEback to summary
public static final char CHAR_SPACE
ERR_XMLDECL_END_MARKERback to summary
protected static final String ERR_XMLDECL_END_MARKER
ERR_XMLDECL_EXP_ATTRVALback to summary
protected static final String ERR_XMLDECL_EXP_ATTRVAL
ERR_XMLDECL_EXP_EQback to summary
protected static final String ERR_XMLDECL_EXP_EQ
ERR_XMLDECL_EXP_SPACEback to summary
protected static final String ERR_XMLDECL_EXP_SPACE
ERR_XMLDECL_KW_ENCODINGback to summary
protected static final String ERR_XMLDECL_KW_ENCODING
ERR_XMLDECL_KW_STANDALONEback to summary
protected static final String ERR_XMLDECL_KW_STANDALONE
ERR_XMLDECL_KW_VERSIONback to summary
protected static final String ERR_XMLDECL_KW_VERSION
mDeclaredXmlVersionback to summary
protected int mDeclaredXmlVersion

XML declaration from the input (1.0, 1.1 or 'unknown')

mFoundEncodingback to summary
protected String mFoundEncoding

Value of encoding pseudo-attribute from xml declaration, if one was found; null otherwise.

mInputProcessedback to summary
protected int mInputProcessed

Current number of characters that were processed in previous blocks, before contents of current input buffer.

mInputRowback to summary
protected int mInputRow

Current row location of current point in input buffer, starting from 1

mInputRowStartback to summary
protected int mInputRowStart

Current 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.

mKeywordBufferback to summary
protected final char[] mKeywordBuffer

Need 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)

mPublicIdback to summary
protected final String mPublicId
mStandaloneback to summary
protected String mStandalone
mSystemIdback to summary
protected final SystemId mSystemId
mXml11Handlingback to summary
protected boolean mXml11Handling

Flag 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.

Constructor Detail

InputBootstrapperback to summary
protected InputBootstrapper(String pubId, SystemId sysId)

Method Detail

bootstrapInputback to summary
public abstract Reader bootstrapInput(ReaderConfig cfg, boolean mainDoc, int xmlVersion) throws IOException, XMLStreamException
Parameters
xmlVersion:int

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.

checkKeywordback to summary
protected abstract int checkKeyword(String exp) throws IOException, WstxException
Returns:int

First character that does not match expected, if any; CHAR_NULL if match succeeded

declaredXml11back to summary
public boolean declaredXml11()
Returns:boolean

True, if the input bootstrapped declared that it conforms to xml 1.1 (independent of where it was included from)

getDeclaredEncodingback to summary
public String getDeclaredEncoding()
Returns:String

Encoding declaration found from the xml declaration, if any; null if none.

getDeclaredVersionback to summary
public int getDeclaredVersion()
getInputColumnback to summary
public abstract int getInputColumn()
getInputEncodingback to summary
public abstract 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).

Returns:String

Input encoding in use, if it could be determined or was passed by the calling application

getInputRowback to summary
public int getInputRow()
getInputTotalback to summary
public abstract int getInputTotal()
Returns:int

Total number of characters read from bootstrapped input (stream, reader)

getLocationback to summary
protected abstract Location getLocation()
getNextback to summary
protected abstract int getNext() throws IOException, WstxException
getNextAfterWsback to summary
protected abstract int getNextAfterWs(boolean reqWs) throws IOException, WstxException
getPublicIdback to summary
public String getPublicId()
getStandaloneback to summary
public String getStandalone()
getSystemIdback to summary
public SystemId getSystemId()
getWsOrCharback to summary
private final int getWsOrChar(int ok) throws IOException, WstxException

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.

handleEqback to summary
private final int handleEq(String attr) throws IOException, WstxException
initFromback to summary
protected void initFrom(InputBootstrapper src)
pushbackback to summary
protected abstract void pushback()
readQuotedValueback to summary
protected abstract int readQuotedValue(char[] kw, int quoteChar) throws IOException, WstxException
readXmlDeclback to summary
protected void readXmlDecl(boolean isMainDoc, int xmlVersion) throws IOException, WstxException
Parameters
xmlVersion:int

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.

readXmlEncodingback to summary
private final String readXmlEncoding() throws IOException, WstxException
readXmlStandaloneback to summary
private final String readXmlStandalone() throws IOException, WstxException
readXmlVersionback to summary
private final int readXmlVersion() throws IOException, WstxException
Returns:int

Xml version declaration read

reportNullback to summary
protected void reportNull() throws WstxException
reportPseudoAttrProblemback to summary
private final void reportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2) throws WstxException
reportUnexpectedCharback to summary
protected void reportUnexpectedChar(int i, String msg) throws WstxException
reportXmlProblemback to summary
protected void reportXmlProblem(String msg) throws WstxException