public class ChunkInputStream
extends java.io.InputStream
Modifier and Type | Field and Description |
---|---|
protected int |
avail |
protected int |
chunksize |
protected int |
flags |
protected java.io.InputStream |
input |
protected java.nio.ByteOrder |
localorder |
protected java.nio.ByteOrder |
remoteorder |
protected RequestMode |
requestmode |
protected dap4.dap4shared.ChunkInputStream.State |
state |
Constructor and Description |
---|
ChunkInputStream(java.io.InputStream input,
RequestMode requestmode) |
ChunkInputStream(java.io.InputStream input,
RequestMode requestmode,
java.nio.ByteOrder order) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of databuffer that can be read
(or skipped over) from this input stream without
blocking by the next invocation of a method for this
input stream.
|
void |
close()
Closes this output stream and releases any system resources
associated with this stream.
|
java.nio.ByteOrder |
getByteOrder() |
int |
read()
Reads the next byte of databuffer from the input stream.
|
int |
read(byte[] buf,
int off,
int len)
Reads up to len databuffer of databuffer from the input stream into an
array of databuffer.
|
java.lang.String |
readDMR()
Read the DMR, trimmed.
|
java.lang.String |
readError()
Read an error chunk
|
void |
throwError(java.lang.String document)
Convert an error chunk to an exception
|
protected java.io.InputStream input
protected dap4.dap4shared.ChunkInputStream.State state
protected RequestMode requestmode
protected java.nio.ByteOrder localorder
protected java.nio.ByteOrder remoteorder
protected int flags
protected int chunksize
protected int avail
public ChunkInputStream(java.io.InputStream input, RequestMode requestmode)
public ChunkInputStream(java.io.InputStream input, RequestMode requestmode, java.nio.ByteOrder order)
public java.nio.ByteOrder getByteOrder()
public java.lang.String readDMR() throws DapException
DapException
public void throwError(java.lang.String document) throws ErrorException
document
- XML representation of the errorDapException
- containing the contents of the error chunkErrorException
public java.lang.String readError() throws java.io.IOException
java.io.IOException
public int read() throws java.io.IOException
int
in the range 0
to
255
. If no byte is available because the end of the stream
has been reached, the value -1
is returned. This method
blocks until input databuffer is available, the end of the stream is detected,
or an exception is thrown.
Operates by loading chunk by chunk. If an error chunk is detected,
then return ErrorException (which is a subclass of IOException).read
in class java.io.InputStream
-1
if the end of the
stream is reached.java.io.IOException
- if an I/O error occurs.public int read(byte[] buf, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
buf
- the byte array into which databuffer is readoff
- the offset in the byte array at which to writelen
- the amount to readjava.io.IOException
public int available()
available
in class java.io.InputStream
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException