Package dap4.servlet
Class ChunkWriter
java.lang.Object
java.io.OutputStream
dap4.servlet.ChunkWriter
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ByteBufferprotected booleanstatic final byte[]static booleanstatic booleanprotected byte[]static booleanprotected ByteBufferprotected intprotected dap4.dap4lib.RequestModeprotected OutputStreamprotected OutputStreamprotected ChunkWriter.Stateprotected longprotected longprotected ByteOrder -
Constructor Summary
ConstructorsConstructorDescriptionChunkWriter(OutputStream output, dap4.dap4lib.RequestMode mode, ByteOrder writeorder) -
Method Summary
Modifier and TypeMethodDescriptionvoidcacheDMR(dap4.core.dmr.DapDataset dmr, dap4.core.util.DapContext cxt) Cache the DMR.voidstatic voidchunkheader(int length, int flags, ByteBuffer hdrbuf) voidclose()Closes this output stream and releases any system resources associated with this stream.voidflush()Overload flush to also write out the DMRbyte[]getDump()dap4.dap4lib.RequestModegetMode()voidsetBufferSize(int maxsize) voidsetMode(dap4.dap4lib.RequestMode mode) voidsetWriteLimit(long limit) voidsetWriteOrder(ByteOrder writeorder) voidwrite(byte[] b) Writes b.length bytes from the specified byte array to this output stream.voidwrite(byte[] b, int off, int len) Writes len bytes from the specified byte array starting at offset off to this output stream.voidwrite(int b) Writes the specified byte to the chunkvoidWrite the DSR; do not bother to cache.voidwriteError(int httpcode, String msg, String cxt, String other) Write an error chunk.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
DEBUG
public static boolean DEBUG -
DUMPDATA
public static boolean DUMPDATA -
DEBUGHEADER
public static boolean DEBUGHEADER -
CRLF8
public static final byte[] CRLF8 -
saveoutput
-
output
-
state
-
maxbuffersize
protected int maxbuffersize -
writelimit
protected long writelimit -
writecount
protected long writecount -
chunk
-
header
-
writeorder
-
mode
protected dap4.dap4lib.RequestMode mode -
dmr8
protected byte[] dmr8 -
closed
protected boolean closed
-
-
Constructor Details
-
ChunkWriter
public ChunkWriter(OutputStream output, dap4.dap4lib.RequestMode mode, ByteOrder writeorder) throws IOException - Throws:
IOException
-
-
Method Details
-
getMode
public dap4.dap4lib.RequestMode getMode() -
setMode
public void setMode(dap4.dap4lib.RequestMode mode) -
setBufferSize
public void setBufferSize(int maxsize) -
getWriteOrder
-
setWriteOrder
-
setWriteLimit
public void setWriteLimit(long limit) -
writeDSR
Write the DSR; do not bother to cache.- Parameters:
dsr- The DSR string- Throws:
IOException- on IO related errors
-
cacheDMR
public void cacheDMR(dap4.core.dmr.DapDataset dmr, dap4.core.util.DapContext cxt) throws IOException Cache the DMR. What it really does is cache the DMR and write it at the point where it is needed; either in close(), if writing the DMR only, or in writeChunk() if writing data as well.- Parameters:
dmr- The DMR string- Throws:
IOException- on IO related errors
-
cacheDMR
- Throws:
IOException
-
writeError
Write an error chunk. If mode == DMR then replaces the dmr else reset the current chunk thus losing any partial write.- Parameters:
httpcode- The httpcode, 0 => ignoremsg- The, null => ignore cxt- The, null => ignore other- The, null => ignore - Throws:
IOException- on IO related errors
-
chunkheader
public static void chunkheader(int length, int flags, ByteBuffer hdrbuf) throws dap4.core.util.DapException - Throws:
dap4.core.util.DapException
-
close
Closes this output stream and releases any system resources associated with this stream. Except, the underlying stream is not actually closed; that is left to the servlet level- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- on IO related errors
-
getDump
public byte[] getDump() -
flush
Overload flush to also write out the DMR- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
write
Writes b.length bytes from the specified byte array to this output stream.- Overrides:
writein classOutputStream- Parameters:
b- the data- Throws:
IOException- if an I/O error occurs
-
write
Writes the specified byte to the chunk- Specified by:
writein classOutputStream- Parameters:
b- the byte to write- Throws:
IOException- if an I/O error occurs
-
write
Writes len bytes from the specified byte array starting at offset off to this output stream.If this write fills up the chunk buffer, then write out the buffer and put the remaining bytes into the reset buffer.
- Overrides:
writein classOutputStream- Parameters:
b- the dataoff- start point in b from which to write datalen- number of bytes to write- Throws:
IOException- if an I/O error occurs
-