edu.sdsc.inca.protocol
Class ProtocolWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.BufferedWriter
          extended by edu.sdsc.inca.protocol.ProtocolWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class ProtocolWriter
extends java.io.BufferedWriter

Author:
Cathie Olschanowsky A buffered protocol writer. The same as a buffered Writer with the addition of a write method that will accept a Statement.

Field Summary
protected  boolean closed
           
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
ProtocolWriter(java.io.OutputStream output)
          Create a buffered character-output stream that uses a default-sized output buffer.
ProtocolWriter(java.io.OutputStream output, int i)
          Create a new buffered character-output stream that uses an output buffer of the given size.
ProtocolWriter(java.io.Writer writer)
          Create a buffered character-output stream that uses a default-sized output buffer.
ProtocolWriter(java.io.Writer writer, int i)
          Create a new buffered character-output stream that uses an output buffer of the given size.
 
Method Summary
 void close()
          Closes the writer.
 boolean isClosed()
          Indicates whether or not the writer has been closed.
 void write(Statement statement)
          Write a statement to the protocolWriter.
 void write(java.lang.String command, java.io.Reader inStream)
          Write a statement to the protocolWriter.
 
Methods inherited from class java.io.BufferedWriter
flush, newLine, write, write, write
 
Methods inherited from class java.io.Writer
append, append, append, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

closed

protected boolean closed
Constructor Detail

ProtocolWriter

public ProtocolWriter(java.io.Writer writer)
Create a buffered character-output stream that uses a default-sized output buffer.

Parameters:
writer - the writer to send the data to

ProtocolWriter

public ProtocolWriter(java.io.Writer writer,
                      int i)
Create a new buffered character-output stream that uses an output buffer of the given size.

Parameters:
writer - to direct the output to
i - buffer size

ProtocolWriter

public ProtocolWriter(java.io.OutputStream output)
Create a buffered character-output stream that uses a default-sized output buffer.

Parameters:
output - the stream to send the data to

ProtocolWriter

public ProtocolWriter(java.io.OutputStream output,
                      int i)
Create a new buffered character-output stream that uses an output buffer of the given size.

Parameters:
output - the stream to direct the output to
i - buffer size
Method Detail

close

public void close()
           throws java.io.IOException
Closes the writer.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.BufferedWriter
Throws:
java.io.IOException - on a close error

isClosed

public boolean isClosed()
Indicates whether or not the writer has been closed.

Returns:
true if the writer is closed, else false

write

public void write(Statement statement)
           throws java.io.IOException
Write a statement to the protocolWriter.

Parameters:
statement - data to write
Throws:
java.io.IOException - if the write fails

write

public void write(java.lang.String command,
                  java.io.Reader inStream)
           throws java.io.IOException
Write a statement to the protocolWriter.

Parameters:
command - command for the statement to write
inStream - data for the statement to write
Throws:
java.io.IOException - if the write fails