src/org/objectweb/cjdbc/console/gui/jtools/JTextAreaWriter.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.console.gui.jtools; 00026 00027 import java.io.IOException; 00028 import java.io.Writer; 00029 00030 import javax.swing.JTextArea; 00031 00040 public class JTextAreaWriter extends Writer 00041 { 00042 00043 private boolean closed = false; 00044 private JTextArea textArea; 00045 private StringBuffer buffer; 00046 00053 public JTextAreaWriter(JTextArea textArea) 00054 { 00055 setTextArea(textArea); 00056 } 00057 00064 public void setTextArea(JTextArea textArea) 00065 { 00066 if (textArea == null) 00067 { 00068 throw new IllegalArgumentException("The text area must not be null."); 00069 } 00070 this.textArea = textArea; 00071 } 00072 00075 public void close() 00076 { 00077 closed = true; 00078 } 00079 00086 public void flush() throws IOException 00087 { 00088 if (closed) 00089 { 00090 throw new IOException("The stream is closed."); 00091 } 00092 textArea.append(getBuffer().toString()); 00093 textArea.setCaretPosition(textArea.getDocument().getLength()); 00094 buffer = null; 00095 } 00096 00104 public void write(char[] charArray) throws IOException 00105 { 00106 write(charArray, 0, charArray.length); 00107 } 00108 00119 public void write(char[] charArray, int offset, int length) 00120 throws IOException 00121 { 00122 if (closed) 00123 { 00124 throw new IOException("The stream is not open."); 00125 } 00126 getBuffer().append(charArray, offset, length); 00127 } 00128 00136 public void write(int c) throws IOException 00137 { 00138 if (closed) 00139 { 00140 throw new IOException("The stream is not open."); 00141 } 00142 getBuffer().append((char) c); 00143 } 00144 00152 public void write(String string) throws IOException 00153 { 00154 if (closed) 00155 { 00156 throw new IOException("The stream is not open."); 00157 } 00158 getBuffer().append(string); 00159 } 00160 00171 public void write(String string, int offset, int length) throws IOException 00172 { 00173 if (closed) 00174 { 00175 throw new IOException("The stream is not open."); 00176 } 00177 getBuffer().append(string.substring(offset, length)); 00178 } 00179 00187 private StringBuffer getBuffer() 00188 { 00189 if (buffer == null) 00190 { 00191 buffer = new StringBuffer(); 00192 } 00193 return buffer; 00194 } 00195 00196 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:58 2004に生成されました。 doxygen 1.3.8