Class InputBootstrapper

  • Direct Known Subclasses:
    ReaderBootstrapper, StreamBootstrapper

    public abstract class InputBootstrapper
    extends Object
    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 Detail

      • mPublicId

        protected final String mPublicId
      • mSystemId

        protected final SystemId mSystemId
      • mInputProcessed

        protected int mInputProcessed
        Current number of characters that were processed in previous blocks, before contents of current input buffer.
      • mInputRow

        protected int mInputRow
        Current row location of current point in input buffer, starting from 1
      • mInputRowStart

        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.
    • Constructor Detail

      • InputBootstrapper

        protected InputBootstrapper​(String pubId,
                                    SystemId sysId)
    • Method Detail

      • 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:
        IOException
        XMLStreamException
      • getPublicId

        public String getPublicId()
      • getSystemId

        public SystemId 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

        public String getStandalone()
      • getDeclaredEncoding

        public String 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

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

        protected void readXmlDecl​(boolean isMainDoc,
                                   int xmlVersion)
                            throws IOException,
                                   WstxException
        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:
        IOException
        WstxException
      • pushback

        protected abstract void pushback()
      • getLocation

        protected abstract Location getLocation()