Class StringBuilderWriter
java.lang.Object
java.io.Writer
org.eclipse.nebula.widgets.picture.internal.output.StringBuilderWriter
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.io.Serializable
,java.lang.Appendable
,java.lang.AutoCloseable
public class StringBuilderWriter
extends java.io.Writer
implements java.io.Serializable
Writer
implementation that outputs to a StringBuilder
.
NOTE: This implementation, as an alternative to
java.io.StringWriter
, provides an un-synchronized
(i.e. for use in a single thread) implementation for better performance.
For safe usage with multiple Thread
s then
java.io.StringWriter
should be used.
- Since:
- Commons IO 2.0
- Version:
- $Revision: 1003647 $ $Date: 2010-10-01 21:53:59 +0100 (Fri, 01 Oct 2010) $
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description StringBuilderWriter()
Construct a newStringBuilder
instance with default capacity.StringBuilderWriter(int capacity)
Construct a newStringBuilder
instance with the specified capacity.StringBuilderWriter(java.lang.StringBuilder builder)
Construct a new instance with the specifiedStringBuilder
. -
Method Summary
Modifier and Type Method Description java.io.Writer
append(char value)
Append a single character to this Writer.java.io.Writer
append(java.lang.CharSequence value)
Append a character sequence to this Writer.java.io.Writer
append(java.lang.CharSequence value, int start, int end)
Append a portion of a character sequence to theStringBuilder
.void
close()
Closing this writer has no effect.void
flush()
Flushing this writer has no effect.java.lang.StringBuilder
getBuilder()
Return the underlying builder.java.lang.String
toString()
ReturnsStringBuilder.toString()
.void
write(char[] value, int offset, int length)
Write a portion of a character array to theStringBuilder
.void
write(java.lang.String value)
Write a String to theStringBuilder
.
-
Constructor Details
-
StringBuilderWriter
public StringBuilderWriter()Construct a newStringBuilder
instance with default capacity. -
StringBuilderWriter
public StringBuilderWriter(int capacity)Construct a newStringBuilder
instance with the specified capacity.- Parameters:
capacity
- The initial capacity of the underlyingStringBuilder
-
StringBuilderWriter
public StringBuilderWriter(java.lang.StringBuilder builder)Construct a new instance with the specifiedStringBuilder
.- Parameters:
builder
- The String builder
-
-
Method Details
-
append
public java.io.Writer append(char value)Append a single character to this Writer.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Parameters:
value
- The character to append- Returns:
- This writer instance
-
append
public java.io.Writer append(java.lang.CharSequence value)Append a character sequence to this Writer.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Parameters:
value
- The character to append- Returns:
- This writer instance
-
append
public java.io.Writer append(java.lang.CharSequence value, int start, int end)Append a portion of a character sequence to theStringBuilder
.- Specified by:
append
in interfacejava.lang.Appendable
- Overrides:
append
in classjava.io.Writer
- Parameters:
value
- The character to appendstart
- The index of the first characterend
- The index of the last character + 1- Returns:
- This writer instance
-
close
public void close()Closing this writer has no effect.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classjava.io.Writer
-
flush
public void flush()Flushing this writer has no effect.- Specified by:
flush
in interfacejava.io.Flushable
- Specified by:
flush
in classjava.io.Writer
-
write
public void write(java.lang.String value)Write a String to theStringBuilder
.- Overrides:
write
in classjava.io.Writer
- Parameters:
value
- The value to write
-
write
public void write(char[] value, int offset, int length)Write a portion of a character array to theStringBuilder
.- Specified by:
write
in classjava.io.Writer
- Parameters:
value
- The value to writeoffset
- The index of the first characterlength
- The number of characters to write
-
getBuilder
public java.lang.StringBuilder getBuilder()Return the underlying builder.- Returns:
- The underlying builder
-
toString
public java.lang.String toString()ReturnsStringBuilder.toString()
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The contents of the String builder.
-