FileDocCategorySizeDatePackage
SerializableReader.javaAPI DocJBoss 4.2.13583Fri Jul 13 21:01:14 BST 2007org.jboss.resource.adapter.jdbc.remote

SerializableReader

public class SerializableReader extends Reader implements Serializable
author
Tom Elrod
version
$Revision: 57189 $

Fields Summary
static final long
serialVersionUID
private char[]
data
protected char[]
buf
protected int
pos
protected int
mark
protected int
count
Constructors Summary
public SerializableReader(Reader reader)


       
   
      BufferedReader in = new BufferedReader(reader);
      String line = in.readLine();
      while (line != null)
      {
         String current = (data == null) ? "" : new String(data);
         String newData = current + line;
         data = newData.toCharArray();
         line = in.readLine();
      }

      reader.close();

      this.buf = this.data;
      this.pos = 0;
      this.count = this.buf.length;

   
Methods Summary
public voidclose()
Close the stream. Once a stream has been closed, further read(), ready(), mark(), or reset() invocations will throw an IOException. Closing a previously-closed stream, however, has no effect.

throws
java.io.IOException If an I/O error occurs

      // Do nothing
   
public intread(char[] cbuf, int off, int len)
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

param
cbuf Destination buffer
param
off Offset at which to start storing characters
param
len Maximum number of characters to read
return
The number of characters read, or -1 if the end of the stream has been reached
throws
java.io.IOException If an I/O error occurs

      if (cbuf == null)
      {
         throw new NullPointerException();
      }
      else if ((off < 0) || (off > cbuf.length) || (len < 0) ||
            ((off + len) > cbuf.length) || ((off + len) < 0))
      {
         throw new IndexOutOfBoundsException();
      }

      if (pos >= count)
      {
         return -1;
      }
      if (pos + len > count)
      {
         len = count - pos;
      }
      if (len <= 0)
      {
         return 0;
      }
      System.arraycopy(buf, pos, cbuf, off, len);
      pos += len;
      return len;