public class Chunk
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
closingChunk |
static java.lang.String |
COUNT_EXTENSION |
static int |
DATA |
static int |
DEFAULT_SIZE |
static java.lang.String |
EMERGENCY_EXIT_STATUS |
static java.lang.String |
ERROR_STATUS |
static java.lang.String |
EXIT_STATUS |
static int |
EXTENSION |
static int |
HEADER_SIZE |
static int |
HEADER_SIZE_ENCODING_BYTES |
static int |
HEADER_TYPE_ENCODING_BYTES |
static int |
MAX_SIZE |
static int |
SIZE_BIT_MASK |
static java.lang.String |
STATUS_EXTENSION |
Constructor and Description |
---|
Chunk() |
Modifier and Type | Method and Description |
---|---|
static int |
getDataSize(byte[] chunkHeader) |
static int |
getType(byte[] chunkHeader) |
static boolean |
isLastChunk(byte[] chunkHeader) |
static int |
readChunkHeader(java.io.InputStream is,
byte[] header,
int off)
Reads a chunk header into the passed byte buffer begining at location
off.
|
java.lang.String |
toString() |
static void |
writeChunkHeader(java.io.OutputStream os,
int dataSize,
int type)
Writes a chunk header to the underlying stream.
|
static void |
writeClosingChunkHeader(java.io.OutputStream os)
Send closing chunk.
|
public static final int HEADER_SIZE_ENCODING_BYTES
public static final int HEADER_TYPE_ENCODING_BYTES
public static final int HEADER_SIZE
public static final int SIZE_BIT_MASK
public static final int MAX_SIZE
public static final int DATA
public static final int EXTENSION
public static final int DEFAULT_SIZE
public static final byte[] closingChunk
public static final java.lang.String STATUS_EXTENSION
public static final java.lang.String ERROR_STATUS
public static final java.lang.String EMERGENCY_EXIT_STATUS
public static final java.lang.String EXIT_STATUS
public static final java.lang.String COUNT_EXTENSION
public static int getDataSize(byte[] chunkHeader) throws java.io.IOException
chunkHeader
- java.io.IOException
public static boolean isLastChunk(byte[] chunkHeader)
public static int getType(byte[] chunkHeader) throws java.io.IOException
java.io.IOException
public static void writeClosingChunkHeader(java.io.OutputStream os) throws java.io.IOException
Example: {'0','0','0','0','d'}
os
- The stream to which to write the closing chunk header.java.io.IOException
- When the wrapped OutputStream encounters a problem.public static void writeChunkHeader(java.io.OutputStream os, int dataSize, int type) throws java.io.IOException
dataSize parameter specifies the size of the data about to be sent,
not including the size of the chunk header. The chunk header size is
added by this method prior writing the size to the stream.
os
- The stream to which to write the chunk header.dataSize
- The size of the data portion of the chunk.type
- The type of the chunkjava.io.IOException
- When things go wrong.public java.lang.String toString()
toString
in class java.lang.Object
public static int readChunkHeader(java.io.InputStream is, byte[] header, int off) throws java.io.IOException
HEADER_SIZE constant
is
- The InputStream from which to read the header.header
- The array into which to read the chunk header.off
- The offset within the array header at which to start placing
the bytes of header.java.io.IOException
- When the underlying stream does.HEADER_SIZE