Package dap4.servlet

Class ChunkWriter

    • Field Detail

      • DEBUG

        public static boolean DEBUG
      • DUMPDATA

        public static boolean DUMPDATA
      • DEBUGHEADER

        public static boolean DEBUGHEADER
      • CRLF8

        public static final byte[] CRLF8
      • maxbuffersize

        protected int maxbuffersize
      • writelimit

        protected long writelimit
      • writecount

        protected long writecount
      • mode

        protected dap4.dap4lib.RequestMode mode
      • dmr8

        protected byte[] dmr8
      • closed

        protected boolean closed
    • Method Detail

      • getMode

        public dap4.dap4lib.RequestMode getMode()
      • setMode

        public void setMode​(dap4.dap4lib.RequestMode mode)
      • setBufferSize

        public void setBufferSize​(int maxsize)
      • getWriteOrder

        public ByteOrder getWriteOrder()
      • setWriteOrder

        public void setWriteOrder​(ByteOrder writeorder)
      • setWriteLimit

        public void setWriteLimit​(long limit)
      • writeDSR

        public void writeDSR​(String dsr)
                      throws IOException
        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
      • writeError

        public void writeError​(int httpcode,
                               String msg,
                               String cxt,
                               String other)
                        throws IOException
        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 => ignore
        msg - 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

        public void close()
                   throws IOException
        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:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Overrides:
        close in class OutputStream
        Throws:
        IOException - on IO related errors
      • getDump

        public byte[] getDump()
      • write

        public void write​(byte[] b)
                   throws IOException
        Writes b.length bytes from the specified byte array to this output stream.
        Overrides:
        write in class OutputStream
        Parameters:
        b - the data
        Throws:
        IOException - if an I/O error occurs
      • write

        public void write​(int b)
                   throws IOException
        Writes the specified byte to the chunk
        Specified by:
        write in class OutputStream
        Parameters:
        b - the byte to write
        Throws:
        IOException - if an I/O error occurs
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws IOException
        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:
        write in class OutputStream
        Parameters:
        b - the data
        off - start point in b from which to write data
        len - number of bytes to write
        Throws:
        IOException - if an I/O error occurs