Class XmlHeaderAwareReader

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

    public final class XmlHeaderAwareReader
    extends java.io.Reader
    A Reader that evaluates the XML header. It selects its encoding based on the encoding read with the XML header of the provided InputStream. The default encoding is UTF-8 and the version is 1.0 if the stream does not contain an XML header or the attributes are not set within the header.
    Since:
    1.3
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlHeaderAwareReader​(java.io.InputStream in)
      Constructs an XmlHeaderAwareReader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      boolean equals​(java.lang.Object obj)  
      java.lang.String getEncoding()  
      private java.util.Map getHeader​(java.io.PushbackInputStream[] in)  
      double getVersion()  
      int hashCode()  
      void mark​(int readAheadLimit)  
      boolean markSupported()  
      int read()  
      int read​(char[] cbuf)  
      int read​(char[] cbuf, int offset, int length)  
      boolean ready()  
      void reset()  
      long skip​(long n)  
      java.lang.String toString()  
      • Methods inherited from class java.io.Reader

        nullReader, read, transferTo
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • XmlHeaderAwareReader

        public XmlHeaderAwareReader​(java.io.InputStream in)
                             throws java.io.UnsupportedEncodingException,
                                    java.io.IOException
        Constructs an XmlHeaderAwareReader.
        Parameters:
        in - the InputStream
        Throws:
        java.io.UnsupportedEncodingException - if the encoding is not supported
        java.io.IOException - occurred while reading the XML header
        Since:
        1.3
    • Method Detail

      • getHeader

        private java.util.Map getHeader​(java.io.PushbackInputStream[] in)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getEncoding

        public java.lang.String getEncoding()
        Since:
        1.3
        See Also:
        InputStreamReader.getEncoding()
      • getVersion

        public double getVersion()
        Since:
        1.3
        See Also:
        InputStreamReader.getEncoding()
      • mark

        public void mark​(int readAheadLimit)
                  throws java.io.IOException
        Overrides:
        mark in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.mark(int)
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.Reader
        See Also:
        Reader.markSupported()
      • read

        public int read()
                 throws java.io.IOException
        Overrides:
        read in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.read()
      • read

        public int read​(char[] cbuf,
                        int offset,
                        int length)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.read(char[], int, int)
      • read

        public int read​(char[] cbuf)
                 throws java.io.IOException
        Overrides:
        read in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.read(char[])
      • ready

        public boolean ready()
                      throws java.io.IOException
        Overrides:
        ready in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.ready()
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.reset()
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.Reader
        Throws:
        java.io.IOException
        See Also:
        Reader.skip(long)
      • 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
        See Also:
        Reader.close()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()