org.codehaus.groovy.runtime
Class StringBufferWriter

java.lang.Object
  extended byjava.io.Writer
      extended byorg.codehaus.groovy.runtime.StringBufferWriter

public class StringBufferWriter
extends java.io.Writer

This class codes around a silly limiation of StringWriter which doesn't allow a StringBuffer to be passed in as a constructor for some bizzare reason. So we replicate the behaviour of StringWriter here but allow a StringBuffer to be passed in.

Version:
$Revision: 1.1 $
Author:
James Strachan

Field Summary
private  java.lang.StringBuffer buffer
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
StringBufferWriter(java.lang.StringBuffer buffer)
          Create a new string writer which will append the text to the given StringBuffer
 
Method Summary
 void close()
          Closing a StringWriter has no effect.
 void flush()
          Flush the stream.
 java.lang.String toString()
          Return the buffer's current value as a string.
 void write(char[] text, int offset, int length)
          Write a portion of an array of characters.
 void write(int c)
          Write a single character.
 void write(java.lang.String text)
          Write a string.
 void write(java.lang.String text, int offset, int length)
          Write a portion of a string.
 
Methods inherited from class java.io.Writer
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

private java.lang.StringBuffer buffer
Constructor Detail

StringBufferWriter

public StringBufferWriter(java.lang.StringBuffer buffer)
Create a new string writer which will append the text to the given StringBuffer

Method Detail

write

public void write(int c)
Write a single character.


write

public void write(char[] text,
                  int offset,
                  int length)
Write a portion of an array of characters.

Parameters:
text - Array of characters
offset - Offset from which to start writing characters
length - Number of characters to write

write

public void write(java.lang.String text)
Write a string.


write

public void write(java.lang.String text,
                  int offset,
                  int length)
Write a portion of a string.

Parameters:
text - the text to be written
offset - offset from which to start writing characters
length - Number of characters to write

toString

public java.lang.String toString()
Return the buffer's current value as a string.


flush

public void flush()
Flush the stream.


close

public void close()
           throws java.io.IOException
Closing a StringWriter has no effect. The methods in this class can be called after the stream has been closed without generating an IOException.

Throws:
java.io.IOException


Copyright © 2003-2005 The Codehaus. All Rights Reserved.