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 class
DeChunkedInputStream.Chunk
static class
DeChunkedInputStream.State
-
Field Summary
Fields Modifier and Type Field Description protected boolean
checksumming
protected DeChunkedInputStream.Chunk
chunk
protected long
crc32
protected Checksum
crc32alg
protected String
dmrtext
protected String
errortext
protected RequestMode
mode
protected ByteOrder
remoteorder
protected DeChunkedInputStream.State
state
-
Constructor Summary
Constructors Constructor Description DeChunkedInputStream(InputStream src, RequestMode mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
void
computeChecksum(byte[] b, int offset, int extent)
void
computeChecksum(int b)
long
endChecksum()
byte[]
getCurrentChunk()
String
getDMRText()
String
getErrorText()
ByteOrder
getRemoteOrder()
DeChunkedInputStream.State
getState()
void
mark(int readlimit)
boolean
markSupported()
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
protected int
readChunk(DeChunkedInputStream.Chunk chunk)
protected int
readDMR(DeChunkedInputStream.Chunk chunk)
protected boolean
readHeader(DeChunkedInputStream.Chunk chunk)
Read the size+flags header from the input source and use it to initialize the chunk statevoid
reset()
long
skip(long n)
void
startChecksum()
-
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:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classInputStream
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in 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()
-
-