public class ChunkWriter
extends java.io.OutputStream
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ChunkWriter.State |
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
chunk |
protected boolean |
closed |
static byte[] |
CRLF8 |
static boolean |
DEBUG |
static boolean |
DEBUGHEADER |
protected byte[] |
dmr8 |
static boolean |
DUMPDATA |
protected java.nio.ByteBuffer |
header |
protected int |
maxbuffersize |
protected dap4.dap4lib.RequestMode |
mode |
protected java.io.OutputStream |
output |
protected java.io.OutputStream |
saveoutput |
protected ChunkWriter.State |
state |
protected long |
writecount |
protected long |
writelimit |
protected java.nio.ByteOrder |
writeorder |
static java.lang.String |
XMLDOCUMENTHEADER |
| Constructor and Description |
|---|
ChunkWriter(java.io.OutputStream output,
dap4.dap4lib.RequestMode mode,
java.nio.ByteOrder writeorder) |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheDMR(java.lang.String dmr)
Cache the DMR.
|
static void |
chunkheader(int length,
int flags,
java.nio.ByteBuffer hdrbuf) |
void |
close()
Closes this output stream and releases any system resources
associated with this stream.
|
void |
flush()
Overload flush to also write out the DMR
|
byte[] |
getDump() |
dap4.dap4lib.RequestMode |
getMode() |
java.nio.ByteOrder |
getWriteOrder() |
void |
setBufferSize(int maxsize) |
void |
setMode(dap4.dap4lib.RequestMode mode) |
void |
setWriteLimit(long limit) |
void |
setWriteOrder(java.nio.ByteOrder writeorder) |
void |
write(byte[] b)
Writes b.length bytes from the specified byte array
to this output stream.
|
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array starting at
offset off to this output stream.
|
void |
write(int b)
Writes the specified byte to the chunk
|
void |
writeDSR(java.lang.String dsr)
Write the DSR; do not bother to cache.
|
void |
writeError(int httpcode,
java.lang.String msg,
java.lang.String cxt,
java.lang.String other)
Write an error chunk.
|
public static boolean DEBUG
public static boolean DUMPDATA
public static boolean DEBUGHEADER
public static final byte[] CRLF8
public static final java.lang.String XMLDOCUMENTHEADER
protected java.io.OutputStream saveoutput
protected java.io.OutputStream output
protected ChunkWriter.State state
protected int maxbuffersize
protected long writelimit
protected long writecount
protected java.nio.ByteBuffer chunk
protected java.nio.ByteBuffer header
protected java.nio.ByteOrder writeorder
protected dap4.dap4lib.RequestMode mode
protected byte[] dmr8
protected boolean closed
public ChunkWriter(java.io.OutputStream output,
dap4.dap4lib.RequestMode mode,
java.nio.ByteOrder writeorder)
throws java.io.IOException
java.io.IOExceptionpublic dap4.dap4lib.RequestMode getMode()
public void setMode(dap4.dap4lib.RequestMode mode)
public void setBufferSize(int maxsize)
public java.nio.ByteOrder getWriteOrder()
public void setWriteOrder(java.nio.ByteOrder writeorder)
public void setWriteLimit(long limit)
public void writeDSR(java.lang.String dsr)
throws java.io.IOException
dsr - The DSR stringjava.io.IOException - on IO related errorspublic void cacheDMR(java.lang.String dmr)
throws java.io.IOException
dmr - The DMR stringjava.io.IOException - on IO related errorspublic void writeError(int httpcode,
java.lang.String msg,
java.lang.String cxt,
java.lang.String other)
throws java.io.IOException
httpcode - The httpcode, 0 => ignoremsg - The cxt - The other - The java.io.IOException - on IO related errorspublic static void chunkheader(int length,
int flags,
java.nio.ByteBuffer hdrbuf)
throws dap4.core.util.DapException
dap4.core.util.DapExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException - on IO related errorspublic byte[] getDump()
public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b)
throws java.io.IOException
write in class java.io.OutputStreamb - the datajava.io.IOException - if an I/O error occurspublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamb - the byte to writejava.io.IOException - if an I/O error occurspublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
If this write fills up the chunk buffer, then write out the buffer and put the remaining bytes into the reset buffer.
write in class java.io.OutputStreamb - the dataoff - start point in b from which to write datalen - number of bytes to writejava.io.IOException - if an I/O error occurs