Class DelegatingWriter

java.lang.Object
java.io.Writer
nl.talsmasoftware.umldoclet.rendering.writers.DelegatingWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Direct Known Subclasses:
StringBufferingWriter

public class DelegatingWriter extends Writer
Base implementation that delegates writing to one or more delegate writers.
Author:
Sjoerd Talsma
  • Field Details

  • Constructor Details

    • DelegatingWriter

      public DelegatingWriter(Writer... delegates)
      Constructor. Creates a new writer that writes to all provided delegates when written to.
      Parameters:
      delegates - The delegates to write to.
  • Method Details

    • write

      public void write(char[] cbuf, int off, int len) throws IOException
      Delegates the write operation to all delegates and merges any occurred exceptions into a single IOException.
      Specified by:
      write in class Writer
      Parameters:
      cbuf - The buffer containing the characters to be written.
      off - The offset index to write from.
      len - The number of characters to write.
      Throws:
      IOException - in case at least one of the delegate writers threw an exception while writing. Please note: It is very well possible that other delegates were succesfully written.
    • flush

      public void flush() throws IOException
      Delegates the flush operation to all delegates and merges any occurred exceptions into a single IOException.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
      Throws:
      IOException - in case at least one of the delegate writers threw an exception while flushing.
    • close

      public void close() throws IOException
      Delegates the close operation to all delegates and merges any occurred exceptions into a single IOException.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
      Throws:
      IOException - in case at least one of the delegate writers threw an exception while closing. Please note: Attempts are made to close all delegates.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      The classname plus the delegate writers.