com.sun.faces.io
Class FastStringWriter

java.lang.Object
  extended by java.io.Writer
      extended by com.sun.faces.io.FastStringWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class FastStringWriter
extends java.io.Writer

This is based on StringWriter but backed by a StringBuilder instead.

This class is not thread safe.


Field Summary
protected  java.lang.StringBuilder builder
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
FastStringWriter()
          Constructs a new FastStringWriter instance using the default capacity of 16.
FastStringWriter(int initialCapacity)
          Constructs a new FastStringWriter instance using the specified initialCapacity.
 
Method Summary
 void close()
          This is a no-op.
 void flush()
          This is a no-op.
 java.lang.StringBuilder getBuffer()
          Return the StringBuilder itself.
 void reset()
           
 java.lang.String toString()
           
 void write(char[] cbuf, int off, int len)
          Write a portion of an array of characters.
 void write(java.lang.String str)
          Write a string.
 void write(java.lang.String str, int off, int len)
          Write a portion of a string.
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

builder

protected java.lang.StringBuilder builder
Constructor Detail

FastStringWriter

public FastStringWriter()

Constructs a new FastStringWriter instance using the default capacity of 16.


FastStringWriter

public FastStringWriter(int initialCapacity)

Constructs a new FastStringWriter instance using the specified initialCapacity.

Parameters:
initialCapacity - specifies the initial capacity of the buffer
Throws:
java.lang.IllegalArgumentException - if initialCapacity is less than zero
Method Detail

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException

Write a portion of an array of characters.

Specified by:
write in class java.io.Writer
Parameters:
cbuf - Array of characters
off - Offset from which to start writing characters
len - Number of characters to write
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException

This is a no-op.

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

close

public void close()
           throws java.io.IOException

This is a no-op.

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

write

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

Overrides:
write in class java.io.Writer
Parameters:
str - String to be written

write

public void write(java.lang.String str,
                  int off,
                  int len)
Write a portion of a string.

Overrides:
write in class java.io.Writer
Parameters:
str - A String
off - Offset from which to start writing characters
len - Number of characters to write

getBuffer

public java.lang.StringBuilder getBuffer()
Return the StringBuilder itself.

Returns:
StringBuilder holding the current buffer value.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the buffer's current value as a string.

reset

public void reset()


Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.