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 Threads 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

    Fields inherited from class java.io.Writer

    lock
  • Constructor Summary

    Constructors 
    Constructor Description
    StringBuilderWriter()
    Construct a new StringBuilder instance with default capacity.
    StringBuilderWriter​(int capacity)
    Construct a new StringBuilder instance with the specified capacity.
    StringBuilderWriter​(java.lang.StringBuilder builder)
    Construct a new instance with the specified StringBuilder.
  • 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 the StringBuilder.
    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()
    Returns StringBuilder.toString().
    void write​(char[] value, int offset, int length)
    Write a portion of a character array to the StringBuilder.
    void write​(java.lang.String value)
    Write a String to the StringBuilder.

    Methods inherited from class java.io.Writer

    nullWriter, write, write, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • StringBuilderWriter

      public StringBuilderWriter()
      Construct a new StringBuilder instance with default capacity.
    • StringBuilderWriter

      public StringBuilderWriter​(int capacity)
      Construct a new StringBuilder instance with the specified capacity.
      Parameters:
      capacity - The initial capacity of the underlying StringBuilder
    • StringBuilderWriter

      public StringBuilderWriter​(java.lang.StringBuilder builder)
      Construct a new instance with the specified StringBuilder.
      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 interface java.lang.Appendable
      Overrides:
      append in class java.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 interface java.lang.Appendable
      Overrides:
      append in class java.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 the StringBuilder.
      Specified by:
      append in interface java.lang.Appendable
      Overrides:
      append in class java.io.Writer
      Parameters:
      value - The character to append
      start - The index of the first character
      end - 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 interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Specified by:
      close in class java.io.Writer
    • flush

      public void flush()
      Flushing this writer has no effect.
      Specified by:
      flush in interface java.io.Flushable
      Specified by:
      flush in class java.io.Writer
    • write

      public void write​(java.lang.String value)
      Write a String to the StringBuilder.
      Overrides:
      write in class java.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 the StringBuilder.
      Specified by:
      write in class java.io.Writer
      Parameters:
      value - The value to write
      offset - The index of the first character
      length - 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()
      Returns StringBuilder.toString().
      Overrides:
      toString in class java.lang.Object
      Returns:
      The contents of the String builder.