net.sourceforge.java.util.io
Class XmlProgressReader

java.lang.Object
  extended byjava.io.Reader
      extended bycom.sun.syndication.io.XmlReader
          extended bynet.sourceforge.java.util.io.XmlProgressReader

public class XmlProgressReader
extends XmlReader

XMLReader extension that is bindable to a IProgressMonitor to report the progress of a xml read operation.

Author:
Sebastian Machhausen

Field Summary
private  int charactersRead
           The number of characters read
private  IProgressMonitor monitor
           The IProgressMonitor to report the reading status to
private  int overallCharacters
           The overall number of characters to be read
 
Fields inherited from class com.sun.syndication.io.XmlReader
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
XmlProgressReader(InputStream is, boolean lenient, IProgressMonitor monitor)
           Creates a new XmlProgressReader which reads from the specified InputStream and reports its reading progress to the specified IProgressMonitor.
XmlProgressReader(InputStream is, String httpContentType, boolean lenient, IProgressMonitor monitor)
           Creates a new XmlProgressReader which reads from the specified InputStream and reports its reading progress to the specified IProgressMonitor.
XmlProgressReader(URLConnection conn, IProgressMonitor monitor)
           Creates a new XmlProgressReader which reads using the specified URLConnection and reports its reading progress to the specified IProgressMonitor.
XmlProgressReader(URL url, IProgressMonitor monitor)
           Creates a new XmlProgressReader which reads from the specified URL and reports its reading progress to the specified IProgressMonitor.
 
Method Summary
 void close()
           Overrides XmlReader.close() to close the progress monitor as well as the stream.
 int read()
           Overrides XmlReader.read() to update the IProgressMonitor after the read.
 int read(char[] buffer)
           Overrides XmlReader.read(char[]) to update the IProgressMonitor after the read.
 int read(char[] buffer, int off, int len)
           Overrides XmlReader.read(char[], int, int) to update the IProgressMonitor after the read.
 long skip(long n)
           Overrides XmlReader.skip to update the progress monitor after the skip.
 
Methods inherited from class com.sun.syndication.io.XmlReader
getEncoding
 
Methods inherited from class java.io.Reader
mark, markSupported, ready, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

monitor

private IProgressMonitor monitor

The IProgressMonitor to report the reading status to


charactersRead

private int charactersRead

The number of characters read


overallCharacters

private int overallCharacters

The overall number of characters to be read

Constructor Detail

XmlProgressReader

public XmlProgressReader(InputStream is,
                         boolean lenient,
                         IProgressMonitor monitor)
                  throws IOException,
                         XmlReaderException

Creates a new XmlProgressReader which reads from the specified InputStream and reports its reading progress to the specified IProgressMonitor.

Parameters:
is - InputStream to create a Reader from
lenient - indicates if the charset encoding detection should be relaxed
monitor - the IProgressMonitor to report the reading progress to
Throws:
IOException - if an io error occured while setting up this XmlProgressReader
XmlReaderException - thrown if the charset encoding could not be determined according to the specs.

XmlProgressReader

public XmlProgressReader(InputStream is,
                         String httpContentType,
                         boolean lenient,
                         IProgressMonitor monitor)
                  throws IOException,
                         XmlReaderException

Creates a new XmlProgressReader which reads from the specified InputStream and reports its reading progress to the specified IProgressMonitor.

Parameters:
is - InputStream to create the Reader from
httpContentType - content-type header to use for the resolution of the charset encoding
lenient - indicates if the charset encoding detection should be relaxed
monitor - the IProgressMonitor to report the reading progress to
Throws:
IOException - thrown if there is a problem reading the file.
XmlReaderException - thrown if the charset encoding could not be determined according to the specs.

XmlProgressReader

public XmlProgressReader(URL url,
                         IProgressMonitor monitor)
                  throws IOException

Creates a new XmlProgressReader which reads from the specified URL and reports its reading progress to the specified IProgressMonitor.

Parameters:
url - the URL to read from
monitor - the IProgressMonitor to report the reading progress to
Throws:
IOException - if an io error occured while setting up this XmlProgressReader

XmlProgressReader

public XmlProgressReader(URLConnection conn,
                         IProgressMonitor monitor)
                  throws IOException

Creates a new XmlProgressReader which reads using the specified URLConnection and reports its reading progress to the specified IProgressMonitor.

Parameters:
conn - the URLConnection to use for reading
monitor - the IProgressMonitor to report the reading progress to
Throws:
IOException - if an io error occured while setting up this XmlProgressReader
Method Detail

read

public int read()
         throws IOException

Overrides XmlReader.read() to update the IProgressMonitor after the read.

Returns:
the character read or -1 if the end of the stream has been reached
Throws:
IOException - if an io error occured during the read operation

read

public int read(char[] buffer)
         throws IOException

Overrides XmlReader.read(char[]) to update the IProgressMonitor after the read.

Parameters:
buffer - the buffer to read into
Returns:
the number of characters read or -1 if the end of the stream has been reached
Throws:
IOException - if an io error occured during the read operation

read

public int read(char[] buffer,
                int off,
                int len)
         throws IOException

Overrides XmlReader.read(char[], int, int) to update the IProgressMonitor after the read.

Parameters:
buffer - the buffer to read into
off - the offset at which to start storing characters
len - the maximum number of characters to read
Returns:
the number of characters read or -1 if the end of the stream has been reached
Throws:
IOException - if an io error occured during the read operation

skip

public long skip(long n)
          throws IOException

Overrides XmlReader.skip to update the progress monitor after the skip.

Parameters:
n - the number of characters to skip
Returns:
the number of characters actually skipped
Throws:
IllegalArgumentException - If n is negative.
IOException - if an io error occured during the skip operation

close

public void close()
           throws IOException

Overrides XmlReader.close() to close the progress monitor as well as the stream.

Throws:
IOException - if an io error occured during the close operation