com.Ostermiller.util
Class CircularCharBuffer.CircularCharBufferWriter

java.lang.Object
  extended by java.io.Writer
      extended by com.Ostermiller.util.CircularCharBuffer.CircularCharBufferWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Enclosing class:
CircularCharBuffer

protected class CircularCharBuffer.CircularCharBufferWriter
extends java.io.Writer

Class for writing to a circular character buffer. If the buffer is full, the writes will either block until there is some space available or throw an IOException based on the CircularCharBuffer's preference.

Since:
ostermillerutils 1.00.00

Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
protected CircularCharBuffer.CircularCharBufferWriter()
           
 
Method Summary
 void close()
          Close the stream, flushing it first.
 void flush()
          Flush the stream.
 void write(char[] cbuf)
          Write an array of characters.
 void write(char[] cbuf, int off, int len)
          Write a portion of an array of characters.
 void write(int c)
          Write a single character.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CircularCharBuffer.CircularCharBufferWriter

protected CircularCharBuffer.CircularCharBufferWriter()
Method Detail

close

public void close()
           throws java.io.IOException
Close the stream, flushing it first. This will cause the reader associated with this circular buffer to read its last characters once it empties the buffer. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer
Throws:
java.io.IOException - never.
Since:
ostermillerutils 1.00.00

flush

public void flush()
           throws java.io.IOException
Flush the stream.

Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer
Throws:
java.io.IOException - if the stream is closed.
Since:
ostermillerutils 1.00.00

write

public void write(char[] cbuf)
           throws java.io.IOException
Write an array of characters. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.

Overrides:
write in class java.io.Writer
Parameters:
cbuf - Array of characters to be written
Throws:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
java.io.IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of an array of characters. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.

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:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
java.io.IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00

write

public void write(int c)
           throws java.io.IOException
Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.

Overrides:
write in class java.io.Writer
Parameters:
c - number of characters to be written
Throws:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full.
java.io.IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00

write

public void write(java.lang.String str)
           throws java.io.IOException
Write a string. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.

Overrides:
write in class java.io.Writer
Parameters:
str - String to be written
Throws:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
java.io.IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00

write

public void write(java.lang.String str,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of a string. If the buffer allows blocking writes, this method will block until all the data has been written rather than throw an IOException.

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
Throws:
BufferOverflowException - if buffer does not allow blocking writes and the buffer is full. If the exception is thrown, no data will have been written since the buffer was set to be non-blocking.
java.io.IOException - if the stream is closed, or the write is interrupted.
Since:
ostermillerutils 1.00.00