Class DoctypeInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class DoctypeInputStream
    extends java.io.InputStream
    Adapts the marked-up content in a source InputStream to specify that it conforms to a different DTD. Combines InputStream semantics with the ability to specify a target doctype for a byte stream containing XML markup. Used by Validator class to wrap an InputStream, when performing validation of a document against a DTD.
    • Constructor Summary

      Constructors 
      Constructor Description
      DoctypeInputStream​(java.io.InputStream originalSource, java.lang.String encoding, java.lang.String doctypeName, java.lang.String systemID)
      Create an InputStream whose XML content is provided by the originalSource with the exception of the DOCTYPE which is provided by the doctypeName and systemID.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      protected java.lang.String getContent​(java.lang.String encoding)  
      int read()
      Read DOCTYPE-replaced content from the wrapped InputStream
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • baos

        private final java.io.ByteArrayOutputStream baos
      • wrappedStream

        private final java.io.InputStream wrappedStream
    • Constructor Detail

      • DoctypeInputStream

        public DoctypeInputStream​(java.io.InputStream originalSource,
                                  java.lang.String encoding,
                                  java.lang.String doctypeName,
                                  java.lang.String systemID)
        Create an InputStream whose XML content is provided by the originalSource with the exception of the DOCTYPE which is provided by the doctypeName and systemID.
        Parameters:
        originalSource -
        doctypeName -
        systemID -
    • Method Detail

      • getContent

        protected java.lang.String getContent​(java.lang.String encoding)
                                       throws java.io.IOException
        Returns:
        the content of the original source, without amendments or substitutions. Safe to call multiple times.
        Throws:
        java.io.IOException - if thrown while reading from the original source
      • read

        public int read()
                 throws java.io.IOException
        Read DOCTYPE-replaced content from the wrapped InputStream
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException