net.sf.kernow.ui
Class TextAreaWriter

java.lang.Object
  extended by java.io.Writer
      extended by net.sf.kernow.ui.TextAreaWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class TextAreaWriter
extends java.io.Writer

A implementation of the java.io.Writer class which facilitates writing to a JTextArea via a stream.

Note: There appears to be bug in the Macintosh implementation of the JDK 1.1 where a PrintWriter writing to this class will not include the correct line feeds for display in a JTextArea. There is a simple test of the "java.version" system property which, if it starts with the String "1.1" will cause newlines to be written each time the buffer is flushed.


Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
TextAreaWriter(javax.swing.JTextArea textArea)
          Constructor.
 
Method Summary
 void close()
          Close the stream.
 void flush()
          Flush the data that is currently in the buffer.
protected  java.lang.StringBuffer getBuffer()
          Get the StringBuffer which holds the data prior to writing via a call to the flush() method.
 void setTextArea(javax.swing.JTextArea textArea)
          Set the JTextArea to write to.
 void write(char[] charArray)
          Write the given character array to the output stream.
 void write(char[] charArray, int offset, int length)
          Write the given character array to the output stream beginning from the given offset and proceeding to until the given length is reached.
 void write(int c)
          Write the given character to the output stream.
 void write(java.lang.String string)
          Write the given String to the output stream.
 void write(java.lang.String string, int offset, int length)
          Write the given String to the output stream beginning from the given offset and proceeding to until the given length is reached.
 
Methods inherited from class java.io.Writer
append, append, append
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextAreaWriter

public TextAreaWriter(javax.swing.JTextArea textArea)
Constructor.

Parameters:
textArea - The JTextArea to write to.
Method Detail

setTextArea

public void setTextArea(javax.swing.JTextArea textArea)
Set the JTextArea to write to.

Parameters:
textArea - The JTextArea

close

public void close()
Close the stream.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer

flush

public void flush()
           throws java.io.IOException
Flush the data that is currently in the buffer.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException

write

public void write(char[] charArray)
           throws java.io.IOException
Write the given character array to the output stream.

Overrides:
write in class java.io.Writer
Parameters:
charArray - The character array
Throws:
java.io.IOException

write

public void write(char[] charArray,
                  int offset,
                  int length)
           throws java.io.IOException
Write the given character array to the output stream beginning from the given offset and proceeding to until the given length is reached.

Specified by:
write in class java.io.Writer
Parameters:
charArray - The character array
offset - The start offset
length - The length to write
Throws:
java.io.IOException

write

public void write(int c)
           throws java.io.IOException
Write the given character to the output stream.

Overrides:
write in class java.io.Writer
Parameters:
c - The character
Throws:
java.io.IOException

write

public void write(java.lang.String string)
           throws java.io.IOException
Write the given String to the output stream.

Overrides:
write in class java.io.Writer
Parameters:
string - The String
Throws:
java.io.IOException

write

public void write(java.lang.String string,
                  int offset,
                  int length)
           throws java.io.IOException
Write the given String to the output stream beginning from the given offset and proceeding to until the given length is reached.

Overrides:
write in class java.io.Writer
Parameters:
string - The String
offset - The start offset
length - The length to write
Throws:
java.io.IOException

getBuffer

protected java.lang.StringBuffer getBuffer()
Get the StringBuffer which holds the data prior to writing via a call to the flush() method. This method should never return null.

Returns:
A StringBuffer