edu.upc.dama.dex.core
Class TextStream.TextReader

java.lang.Object
  extended by java.io.Reader
      extended by edu.upc.dama.dex.core.TextStream.TextReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable
Enclosing class:
TextStream

public static class TextStream.TextReader
extends java.io.Reader

Reader implementation for TextStream.

This way we can use TextStream as a common Java Writer:

 long oid = ... // object OID
 long text = ... // TEXT attribute id
 dbg.getAttribute(oid, text, v);
 TextStream tstrm = v.getTextStream();
 StringBuffer sb = new StringBuffer();
 char[] buff = new char[200];
 int len = 0;
 BufferedReader br = new BufferedReader(new TextReader(tstrm));
 while ((len = br.read(buff, 0, 200)) != -1) {
     sb.append(buff, 0, len);
 }
 br.close(); // it already closes underlaying Reader and TextStream
 


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
TextStream.TextReader(TextStream strm)
          Creates a new instance.
 
Method Summary
 void close()
           
 boolean markSupported()
           
 int read(char[] chars, int i, int i1)
           
 
Methods inherited from class java.io.Reader
mark, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextStream.TextReader

public TextStream.TextReader(TextStream strm)
Creates a new instance.

Parameters:
strm - Underlaying reader TextStream.
Throws:
java.lang.IllegalArgumentException - If the given TextStream is not a reader stream.
Method Detail

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.Reader

read

public int read(char[] chars,
                int i,
                int i1)
         throws java.io.IOException
Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException