Package com.fasterxml.aalto.in
Class InputBootstrapper
- java.lang.Object
-
- com.fasterxml.aalto.in.InputBootstrapper
-
- All Implemented Interfaces:
XmlConsts
- Direct Known Subclasses:
ByteSourceBootstrapper
,CharSourceBootstrapper
public abstract class InputBootstrapper extends java.lang.Object implements XmlConsts
Abstract base class that defines shared functionality between different bootstrappers (byte stream, char Readers, block input)
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ReaderConfig
_config
protected int
_inputProcessed
Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.protected int
_inputRow
Current row location of current point in input buffer, using zero-based counting.protected int
_inputRowStart
Current index of the first character of the current row in input buffer.static java.lang.String
ERR_XMLDECL_END_MARKER
static java.lang.String
ERR_XMLDECL_EXP_ATTRVAL
static java.lang.String
ERR_XMLDECL_EXP_EQ
static java.lang.String
ERR_XMLDECL_EXP_SPACE
static java.lang.String
ERR_XMLDECL_KW_ENCODING
static java.lang.String
ERR_XMLDECL_KW_STANDALONE
static java.lang.String
ERR_XMLDECL_KW_VERSION
(package private) int
mDeclaredXmlVersion
XML declaration from the input (1.0, 1.1 or 'unknown')(package private) java.lang.String
mFoundEncoding
Value of encoding pseudo-attribute from xml declaration, if one was found; null otherwise.(package private) char[]
mKeyword
Need a short buffer to read in values of pseudo-attributes (version, encoding, standalone).(package private) java.lang.String
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
Constructors Modifier Constructor Description protected
InputBootstrapper(ReaderConfig cfg)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract XmlScanner
bootstrap()
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 abstract int
checkKeyword(java.lang.String exp)
protected abstract javax.xml.stream.Location
getLocation()
protected abstract int
getNext()
protected abstract int
getNextAfterWs(boolean reqWs)
private 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 int
handleEq(java.lang.String attr)
protected abstract void
pushback()
protected abstract int
readQuotedValue(char[] kw, int quoteChar)
protected void
readXmlDeclaration()
Method that will parse xml declaration, which at this point is known to exist.private java.lang.String
readXmlEncoding()
private java.lang.String
readXmlStandalone()
private int
readXmlVersion()
protected void
reportEof()
protected void
reportNull()
protected void
reportPseudoAttrProblem(java.lang.String attrName, java.lang.String got, java.lang.String expVal1, java.lang.String expVal2)
protected void
reportUnexpectedChar(int i, java.lang.String msg)
protected void
reportXmlProblem(java.lang.String msg)
-
-
-
Field Detail
-
ERR_XMLDECL_KW_VERSION
public static final java.lang.String ERR_XMLDECL_KW_VERSION
- See Also:
- Constant Field Values
-
ERR_XMLDECL_KW_ENCODING
public static final java.lang.String ERR_XMLDECL_KW_ENCODING
- See Also:
- Constant Field Values
-
ERR_XMLDECL_KW_STANDALONE
public static final java.lang.String ERR_XMLDECL_KW_STANDALONE
- See Also:
- Constant Field Values
-
ERR_XMLDECL_END_MARKER
public static final java.lang.String ERR_XMLDECL_END_MARKER
- See Also:
- Constant Field Values
-
ERR_XMLDECL_EXP_SPACE
public static final java.lang.String ERR_XMLDECL_EXP_SPACE
- See Also:
- Constant Field Values
-
ERR_XMLDECL_EXP_EQ
public static final java.lang.String ERR_XMLDECL_EXP_EQ
- See Also:
- Constant Field Values
-
ERR_XMLDECL_EXP_ATTRVAL
public static final java.lang.String ERR_XMLDECL_EXP_ATTRVAL
- See Also:
- Constant Field Values
-
_inputProcessed
protected int _inputProcessed
Current number of input units (bytes or chars) that were processed in previous blocks, before contents of current input buffer.Note: includes possible BOMs, if those were part of the input.
-
_inputRow
protected int _inputRow
Current row location of current point in input buffer, using zero-based counting.
-
_inputRowStart
protected int _inputRowStart
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.
-
_config
final ReaderConfig _config
-
mDeclaredXmlVersion
int mDeclaredXmlVersion
XML declaration from the input (1.0, 1.1 or 'unknown')
-
mFoundEncoding
java.lang.String mFoundEncoding
Value of encoding pseudo-attribute from xml declaration, if one was found; null otherwise.
-
mStandalone
java.lang.String mStandalone
-
mKeyword
final char[] mKeyword
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)
-
-
Constructor Detail
-
InputBootstrapper
protected InputBootstrapper(ReaderConfig cfg)
-
-
Method Detail
-
bootstrap
public abstract XmlScanner bootstrap() throws javax.xml.stream.XMLStreamException
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.- Throws:
javax.xml.stream.XMLStreamException
-
readXmlDeclaration
protected void readXmlDeclaration() throws java.io.IOException, javax.xml.stream.XMLStreamException
Method that will parse xml declaration, which at this point is known to exist.- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
readXmlVersion
private final int readXmlVersion() throws java.io.IOException, javax.xml.stream.XMLStreamException
- Returns:
- Xml version declaration read
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
readXmlEncoding
private final java.lang.String readXmlEncoding() throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
readXmlStandalone
private final java.lang.String readXmlStandalone() throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
handleEq
private final int handleEq(java.lang.String attr) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
getWsOrChar
private final int getWsOrChar(int ok) throws java.io.IOException, javax.xml.stream.XMLStreamException
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:
java.io.IOException
javax.xml.stream.XMLStreamException
-
pushback
protected abstract void pushback()
-
getNext
protected abstract int getNext() throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
getNextAfterWs
protected abstract int getNextAfterWs(boolean reqWs) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
checkKeyword
protected abstract int checkKeyword(java.lang.String exp) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Returns:
- First character that does not match expected, if any; CHAR_NULL if match succeeded
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
readQuotedValue
protected abstract int readQuotedValue(char[] kw, int quoteChar) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Throws:
java.io.IOException
javax.xml.stream.XMLStreamException
-
getLocation
protected abstract javax.xml.stream.Location getLocation()
-
reportXmlProblem
protected void reportXmlProblem(java.lang.String msg) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportNull
protected void reportNull() throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportEof
protected void reportEof() throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportUnexpectedChar
protected void reportUnexpectedChar(int i, java.lang.String msg) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
reportPseudoAttrProblem
protected final void reportPseudoAttrProblem(java.lang.String attrName, java.lang.String got, java.lang.String expVal1, java.lang.String expVal2) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
-