Package com.sun.faces.io
Class FastStringWriter
- java.lang.Object
-
- java.io.Writer
-
- com.sun.faces.io.FastStringWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public class FastStringWriter extends Writer
This is based on
StringWriterbut backed by aStringBuilderinstead.This class is not thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilderbuilder
-
Constructor Summary
Constructors Constructor Description FastStringWriter()Constructs a newFastStringWriterinstance using the default capacity of16.FastStringWriter(int initialCapacity)Constructs a newFastStringWriterinstance using the specifiedinitialCapacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()This is a no-op.voidflush()This is a no-op.StringBuildergetBuffer()Return theStringBuilderitself.voidreset()StringtoString()voidwrite(char[] cbuf, int off, int len)Write a portion of an array of characters.voidwrite(String str)Write a string.voidwrite(String str, int off, int len)Write a portion of a string.
-
-
-
Field Detail
-
builder
protected StringBuilder builder
-
-
Constructor Detail
-
FastStringWriter
public FastStringWriter()
Constructs a new
FastStringWriterinstance using the default capacity of16.
-
FastStringWriter
public FastStringWriter(int initialCapacity)
Constructs a new
FastStringWriterinstance using the specifiedinitialCapacity.- Parameters:
initialCapacity- specifies the initial capacity of the buffer- Throws:
IllegalArgumentException- if initialCapacity is less than zero
-
-
Method Detail
-
write
public void write(char[] cbuf, int off, int len) throws IOExceptionWrite a portion of an array of characters.
- Specified by:
writein classWriter- Parameters:
cbuf- Array of charactersoff- Offset from which to start writing characterslen- Number of characters to write- Throws:
IOException
-
flush
public void flush() throws IOExceptionThis is a no-op.
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
public void close() throws IOExceptionThis is a no-op.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
write
public void write(String str)
Write a string.
-
write
public void write(String str, int off, int len)
Write a portion of a string.
-
getBuffer
public StringBuilder getBuffer()
Return theStringBuilderitself.- Returns:
- StringBuilder holding the current buffer value.
-
toString
public String toString()
-
reset
public void reset()
-
-