soapical.util
Class MultiReader

java.lang.Object
  extended byjava.io.Reader
      extended bysoapical.util.MultiReader

public class MultiReader
extends java.io.Reader

A decorator which allows you to reuse a Reader. This copies the contents of the Reader to an internal buffer. Before you re-use the reader, you will have to call the reopen function.

Version:
$Revision: 1.1 $
$Date: 2003/05/16 11:10:52 $
Author:
Eric Kow (kow at loria point fr)

Constructor Summary
MultiReader(java.io.Reader reader)
           
 
Method Summary
 void close()
           
 java.io.Reader getCopy()
          Return a copy of the Reader.
 java.lang.String getCopyAsString()
          Return a copy of the Reader's contents as a String.
 boolean isClosed()
           
 int read(char[] cbuf, int off, int len)
           
 void reopen()
          Allows this MultiReader to be reused.
static java.lang.String toString(java.io.Reader reader)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiReader

public MultiReader(java.io.Reader reader)
Method Detail

toString

public static java.lang.String toString(java.io.Reader reader)
                                 throws java.io.IOException
Throws:
java.io.IOException

isClosed

public boolean isClosed()

reopen

public void reopen()
            throws java.io.IOException
Allows this MultiReader to be reused. You have to call this every first time after closing the reader.

Forcing people to use this function makes MultiReader less convenient but more predictable to use. Otherwise, it would silently loop back to the beginning, and instead of getting a proper IOException, people would get the beginning of the stream again.

Throws:
java.io.IOException - if you call this before closing the reader

getCopy

public java.io.Reader getCopy()
                       throws java.io.IOException
Return a copy of the Reader. This is if you want to read in multiple threads.

Throws:
java.io.IOException
See Also:
getCopyAsString()

getCopyAsString

public java.lang.String getCopyAsString()
                                 throws java.io.IOException
Return a copy of the Reader's contents as a String.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Throws:
java.io.IOException