com.fasterxml.aalto.in
Class InputBootstrapper

java.lang.Object
  extended by com.fasterxml.aalto.in.InputBootstrapper
All Implemented Interfaces:
XmlConsts
Direct Known Subclasses:
ByteSourceBootstrapper, CharSourceBootstrapper

public abstract class InputBootstrapper
extends Object
implements XmlConsts

Abstract base class that defines shared functionality between different bootstrappers (byte stream, char Readers, block input)


Field Summary
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 String ERR_XMLDECL_END_MARKER
           
static String ERR_XMLDECL_EXP_ATTRVAL
           
static String ERR_XMLDECL_EXP_EQ
           
static String ERR_XMLDECL_EXP_SPACE
           
static String ERR_XMLDECL_KW_ENCODING
           
static String ERR_XMLDECL_KW_STANDALONE
           
static String ERR_XMLDECL_KW_VERSION
           
 
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
protected InputBootstrapper(ReaderConfig cfg)
           
 
Method Summary
 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(String exp)
           
abstract  XmlScanner doBootstrap()
           
protected abstract  Location getLocation()
           
protected abstract  int getNext()
           
protected abstract  int getNextAfterWs(boolean reqWs)
           
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.
protected  void reportEof()
           
protected  void reportNull()
           
protected  void reportPseudoAttrProblem(String attrName, String got, String expVal1, String expVal2)
           
protected  void reportUnexpectedChar(int i, String msg)
           
protected  void reportXmlProblem(String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_XMLDECL_KW_VERSION

public static final String ERR_XMLDECL_KW_VERSION
See Also:
Constant Field Values

ERR_XMLDECL_KW_ENCODING

public static final String ERR_XMLDECL_KW_ENCODING
See Also:
Constant Field Values

ERR_XMLDECL_KW_STANDALONE

public static final String ERR_XMLDECL_KW_STANDALONE
See Also:
Constant Field Values

ERR_XMLDECL_END_MARKER

public static final String ERR_XMLDECL_END_MARKER
See Also:
Constant Field Values

ERR_XMLDECL_EXP_SPACE

public static final String ERR_XMLDECL_EXP_SPACE
See Also:
Constant Field Values

ERR_XMLDECL_EXP_EQ

public static final String ERR_XMLDECL_EXP_EQ
See Also:
Constant Field Values

ERR_XMLDECL_EXP_ATTRVAL

public static final 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.

Constructor Detail

InputBootstrapper

protected InputBootstrapper(ReaderConfig cfg)
Method Detail

bootstrap

public final XmlScanner bootstrap()
                           throws 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:
XMLStreamException

doBootstrap

public abstract XmlScanner doBootstrap()
                                throws IOException,
                                       XMLStreamException
Throws:
IOException
XMLStreamException

readXmlDeclaration

protected void readXmlDeclaration()
                           throws IOException,
                                  XMLStreamException
Method that will parse xml declaration, which at this point is known to exist.

Throws:
IOException
XMLStreamException

pushback

protected abstract void pushback()

getNext

protected abstract int getNext()
                        throws IOException,
                               XMLStreamException
Throws:
IOException
XMLStreamException

getNextAfterWs

protected abstract int getNextAfterWs(boolean reqWs)
                               throws IOException,
                                      XMLStreamException
Throws:
IOException
XMLStreamException

checkKeyword

protected abstract int checkKeyword(String exp)
                             throws IOException,
                                    XMLStreamException
Returns:
First character that does not match expected, if any; CHAR_NULL if match succeeded
Throws:
IOException
XMLStreamException

readQuotedValue

protected abstract int readQuotedValue(char[] kw,
                                       int quoteChar)
                                throws IOException,
                                       XMLStreamException
Throws:
IOException
XMLStreamException

getLocation

protected abstract Location getLocation()

reportXmlProblem

protected void reportXmlProblem(String msg)
                         throws XMLStreamException
Throws:
XMLStreamException

reportNull

protected void reportNull()
                   throws XMLStreamException
Throws:
XMLStreamException

reportEof

protected void reportEof()
                  throws XMLStreamException
Throws:
XMLStreamException

reportUnexpectedChar

protected void reportUnexpectedChar(int i,
                                    String msg)
                             throws XMLStreamException
Throws:
XMLStreamException

reportPseudoAttrProblem

protected final void reportPseudoAttrProblem(String attrName,
                                             String got,
                                             String expVal1,
                                             String expVal2)
                                      throws XMLStreamException
Throws:
XMLStreamException


Copyright © 2012 Fasterxml.com. All Rights Reserved.