public class ChunkWriter extends OutputStream
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ChunkWriter.State |
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
chunk |
protected boolean |
closed |
static byte[] |
CRLF8 |
static boolean |
DEBUG |
static boolean |
DEBUGHEADER |
protected byte[] |
dmr8 |
static boolean |
DUMPDATA |
protected ByteBuffer |
header |
protected int |
maxbuffersize |
protected dap4.dap4lib.RequestMode |
mode |
protected OutputStream |
output |
protected OutputStream |
saveoutput |
protected ChunkWriter.State |
state |
protected long |
writecount |
protected long |
writelimit |
protected ByteOrder |
writeorder |
static String |
XMLDOCUMENTHEADER |
| Constructor and Description |
|---|
ChunkWriter(OutputStream output,
dap4.dap4lib.RequestMode mode,
ByteOrder writeorder) |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheDMR(String dmr)
Cache the DMR.
|
static void |
chunkheader(int length,
int flags,
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() |
ByteOrder |
getWriteOrder() |
void |
setBufferSize(int maxsize) |
void |
setMode(dap4.dap4lib.RequestMode mode) |
void |
setWriteLimit(long limit) |
void |
setWriteOrder(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(String dsr)
Write the DSR; do not bother to cache.
|
void |
writeError(int httpcode,
String msg,
String cxt,
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 String XMLDOCUMENTHEADER
protected OutputStream saveoutput
protected OutputStream output
protected ChunkWriter.State state
protected int maxbuffersize
protected long writelimit
protected long writecount
protected ByteBuffer chunk
protected ByteBuffer header
protected ByteOrder writeorder
protected dap4.dap4lib.RequestMode mode
protected byte[] dmr8
protected boolean closed
public ChunkWriter(OutputStream output, dap4.dap4lib.RequestMode mode, ByteOrder writeorder) throws IOException
IOExceptionpublic dap4.dap4lib.RequestMode getMode()
public void setMode(dap4.dap4lib.RequestMode mode)
public void setBufferSize(int maxsize)
public ByteOrder getWriteOrder()
public void setWriteOrder(ByteOrder writeorder)
public void setWriteLimit(long limit)
public void writeDSR(String dsr) throws IOException
dsr - The DSR stringIOException - on IO related errorspublic void cacheDMR(String dmr) throws IOException
dmr - The DMR stringIOException - on IO related errorspublic void writeError(int httpcode,
String msg,
String cxt,
String other)
throws IOException
httpcode - The httpcode, 0 => ignoremsg - The cxt - The other - The IOException - on IO related errorspublic static void chunkheader(int length,
int flags,
ByteBuffer hdrbuf)
throws dap4.core.util.DapException
dap4.core.util.DapExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOException - on IO related errorspublic byte[] getDump()
public void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void write(byte[] b)
throws IOException
write in class OutputStreamb - the dataIOException - if an I/O error occurspublic void write(int b)
throws IOException
write in class OutputStreamb - the byte to writeIOException - if an I/O error occurspublic void write(byte[] b,
int off,
int len)
throws 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 OutputStreamb - the dataoff - start point in b from which to write datalen - number of bytes to writeIOException - if an I/O error occurs