|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
javax.servlet.ServletOutputStream
org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorOutputStream
OutputStream
interface for the Enhydra connection method.
Implemention of ServletOutputStream
to be passed to
servlets to allow them to send response data to the client.
This class automatically wrappers a lower level output stream in
a BufferedOutputStream
if buffering is requested by
the servlet.
EnhydraResponse
,
ServletOutputStream
Constructor Summary | |
EnhydraDirectorOutputStream(EnhydraDirectorConnection conn)
Construct an output stream associate with a response object. |
Method Summary | |
void |
close()
|
void |
flush()
|
int |
getBufferSize()
Get the buffer size. |
void |
print(char c)
Writes a character to response data using simple Latin-1 encoding. |
void |
print(java.lang.String s)
Writes a string to response data using simple ASCII-8 encoding. |
void |
reset()
Resets the underlying output stream, discarding any buffers. |
void |
setBufferSize(int size)
Set the buffer size. |
void |
write(byte[] bytes)
Write an array of bytes to this output stream. |
void |
write(byte[] bytes,
int off,
int len)
Write an array of bytes to this output stream. |
void |
write(int b)
Write a single byte of response data. |
Methods inherited from class javax.servlet.ServletOutputStream |
print, print, print, print, print, println, println, println, println, println, println, println, println |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EnhydraDirectorOutputStream(EnhydraDirectorConnection conn) throws java.io.IOException
conn
- EnhydraDirector protocol driver instance.Method Detail |
public void setBufferSize(int size)
Sets the buffer size for this output stream. If less than or equal to zero, no buffering is done and output is sent directly to the protocol engine's output methods.
This method throws an IllegalStateException
if it
is called after the first write to response output.
size
- The size of the buffer, or 0
for no buffering.
java.lang.IllegalStateException
- If data has already been written.public int getBufferSize()
Gets the buffer size for this output stream. If less than or equal to zero, no buffering is done and output is sent directly to the protocol engine's output methods.
0
for no buffering.public void write(int b) throws java.io.IOException
This method is extremely inefficient, since it sends a separate
packet for each outgoing response byte. Servlets should pass this
output stream to the constructor of a new BufferedOutputStream
if the single byte write()
call is going
to be used frequently.
b
- Integer with a value between 0 and 255, inclusive.
java.io.IOException
- If an I/O error occurs.public void write(byte[] bytes, int off, int len) throws java.io.IOException
bytes
- Array of byte data to write to the stream.off
- Starting offset in the array.len
- Number of bytes to write.
java.io.IOException
- If an I/O error occurs.public void write(byte[] bytes) throws java.io.IOException
bytes
- Array of byte data to write to the stream.
java.io.IOException
- If an I/O error occurs.public void print(java.lang.String s) throws java.io.IOException
Sigh
This really does not belong at this level. The correct
solution would have been to have servlets pass a plain, simple
well defined binary OutputStream
to a
PrintStream
or PrintWriter
if they wanted
to have fully encoded string writing.
This implementation supports only simple 8 bit ASCII
encoding. If non-ASCII unicode characters are used, they WILL
be truncated. The correct solution in this case is to use
the appropriate PrintStream
or PrintWriter
classes to do the string-to-binary encoding at a higher level.
String-to-binary encoding is extremely slow.
s
- The string to write.
java.io.IOException
- if an I/O error has occurredServletOutputStream.print(java.lang.String)
public void print(char c) throws java.io.IOException
Sigh
This really does not belong at this level. The correct
solution would have been to have servlets pass a plain, simple
well defined binary OutputStream
to a
PrintStream
or PrintWriter
if they wanted
to have fully encoded string writing.
This implementation supports only simple 8 bit ASCII
encoding. If non-ASCII unicode characters are used, they WILL
be truncated. The correct solution in this case is to use
the appropriate PrintStream
or PrintWriter
classes to do the string-to-binary encoding at a higher level.
String-to-binary encoding is extremely slow.
c
- The character to write.
java.io.IOException
- if an I/O error has occurredServletOutputStream.print(java.lang.String)
public void close() throws java.io.IOException
java.io.IOException
public void flush() throws java.io.IOException
java.io.IOException
public void reset() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- If the stream is not buffered, or if buffer data has already
been flushed/written to the connection.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |