Package dap4.dap4lib
Class DeChunkedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- dap4.dap4lib.DeChunkedInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DeChunkedInputStream extends InputStream
This class transforms a chunked input stream to a de-chunked input stream. Given the input stream, produce a ByteBuffer with all chunking information removed. There are two special cases. 1. Error chunk -- cache the error chunk as text and provide accessors to obtain it. 2. DMR -- cache the DMR, whatever the mode, and provide accessors.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDeChunkedInputStream.Chunkstatic classDeChunkedInputStream.State
-
Field Summary
Fields Modifier and Type Field Description protected booleanchecksummingprotected DeChunkedInputStream.Chunkchunkprotected longcrc32protected Checksumcrc32algprotected Stringdmrtextprotected Stringerrortextprotected RequestModemodeprotected ByteOrderremoteorderprotected DeChunkedInputStream.Statestate
-
Constructor Summary
Constructors Constructor Description DeChunkedInputStream(InputStream src, RequestMode mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidcomputeChecksum(byte[] b, int offset, int extent)voidcomputeChecksum(int b)longendChecksum()byte[]getCurrentChunk()StringgetDMRText()StringgetErrorText()ByteOrdergetRemoteOrder()DeChunkedInputStream.StategetState()voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)protected intreadChunk(DeChunkedInputStream.Chunk chunk)protected intreadDMR(DeChunkedInputStream.Chunk chunk)protected booleanreadHeader(DeChunkedInputStream.Chunk chunk)Read the size+flags header from the input source and use it to initialize the chunk statevoidreset()longskip(long n)voidstartChecksum()-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
mode
protected RequestMode mode
-
remoteorder
protected ByteOrder remoteorder
-
state
protected DeChunkedInputStream.State state
-
chunk
protected DeChunkedInputStream.Chunk chunk
-
crc32alg
protected Checksum crc32alg
-
crc32
protected long crc32
-
checksumming
protected boolean checksumming
-
errortext
protected String errortext
-
dmrtext
protected String dmrtext
-
-
Constructor Detail
-
DeChunkedInputStream
public DeChunkedInputStream(InputStream src, RequestMode mode) throws IOException
- Throws:
IOException
-
-
Method Detail
-
available
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classInputStream
-
reset
public void reset() throws IOException- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classInputStream
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
getState
public DeChunkedInputStream.State getState()
-
getErrorText
public String getErrorText()
-
getDMRText
public String getDMRText()
-
getCurrentChunk
public byte[] getCurrentChunk() throws IOException- Throws:
IOException
-
getRemoteOrder
public ByteOrder getRemoteOrder()
-
readChunk
protected int readChunk(DeChunkedInputStream.Chunk chunk) throws IOException
- Throws:
IOException
-
readDMR
protected int readDMR(DeChunkedInputStream.Chunk chunk) throws IOException
- Throws:
IOException
-
readHeader
protected boolean readHeader(DeChunkedInputStream.Chunk chunk) throws IOException
Read the size+flags header from the input source and use it to initialize the chunk state- Returns:
- true if header read false if immediate eof encountered or chunk is too short
- Throws:
IOException
-
startChecksum
public void startChecksum()
-
computeChecksum
public void computeChecksum(byte[] b, int offset, int extent)
-
computeChecksum
public void computeChecksum(int b)
-
endChecksum
public long endChecksum()
-
-