Class DoctypeReader

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

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

      Constructors 
      Constructor Description
      DoctypeReader​(java.io.Reader originalSource, java.lang.String doctypeName, java.lang.String systemID)
      Create a Reader 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()  
      private java.lang.StringBuilder getContent​(java.io.BufferedReader originalSource)  
      int read()
      Read DOCTYPE-replaced content from the wrapped Reader
      int read​(char[] cbuf, int off, int len)
      Read DOCTYPE-replaced content from the wrapped Reader
      • Methods inherited from class java.io.Reader

        mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • originalReader

        private final java.io.BufferedReader originalReader
      • sourceBuilder

        private final java.lang.StringBuilder sourceBuilder
    • Constructor Detail

      • DoctypeReader

        public DoctypeReader​(java.io.Reader originalSource,
                             java.lang.String doctypeName,
                             java.lang.String systemID)
        Create a Reader 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()
                                       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
      • getContent

        private java.lang.StringBuilder getContent​(java.io.BufferedReader originalSource)
                                            throws java.io.IOException
        Parameters:
        originalSource -
        Returns:
        the contents of the originalSource within a StringBuffer
        Throws:
        java.io.IOException - if thrown while reading from the original source
      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Read DOCTYPE-replaced content from the wrapped Reader
        Specified by:
        read in class java.io.Reader
        Parameters:
        cbuf -
        off -
        len -
        Returns:
        The number of characters read, or -1 if the end of the stream has been reached
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Read DOCTYPE-replaced content from the wrapped Reader
        Overrides:
        read in class java.io.Reader
        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
        Specified by:
        close in class java.io.Reader
        Throws:
        java.io.IOException