private abstract static class ChunkedInput.AbstractBoundaryParser extends java.lang.Object implements ChunkParser
Modifier | Constructor and Description |
---|---|
private |
AbstractBoundaryParser() |
Modifier and Type | Method and Description |
---|---|
(package private) abstract byte[] |
getDelimiter(byte b,
int pos,
byte[] delimiterBuffer)
Selects a delimiter which corresponds to delimiter buffer.
|
(package private) abstract byte[] |
getDelimiter(int pos,
byte[] delimiterBuffer)
Selects a delimiter which corresponds to delimiter buffer.
|
(package private) abstract int |
getDelimiterBufferSize()
Returns a delimiter buffer size depending on the selected strategy.
|
private static int |
matchTail(byte[] buffer,
int offset,
int length,
byte[] pattern)
Tries to find an element intersection between two arrays in a way that intersecting elements must be
at the tail of the first array and at the beginning of the second array.
|
byte[] |
readChunk(java.io.InputStream in)
Invoked by
ChunkedInput to get the data for
the next chunk. |
public byte[] readChunk(java.io.InputStream in) throws java.io.IOException
ChunkParser
ChunkedInput
to get the data for
the next chunk.readChunk
in interface ChunkParser
in
- response entity input stream.null
if no more chunks are available.java.io.IOException
- in case reading from the response entity fails.abstract byte[] getDelimiter(byte b, int pos, byte[] delimiterBuffer)
b
param on the
pos
position of delimiterBuffer
array and then starts the selection process with a newly created array.b
- byte which will be added on the pos
position of delimiterBuffer
arraypos
- number of bytes from the delimiter buffer which will be used in processingdelimiterBuffer
- current content of the delimiter bufferabstract byte[] getDelimiter(int pos, byte[] delimiterBuffer)
pos
- position of the last read bytedelimiterBuffer
- number of bytes from the delimiter buffer which will be used in processingabstract int getDelimiterBufferSize()
If a strategy has multiple registered delimiters, then the delimiter buffer should be a length of the longest delimiter.
private static int matchTail(byte[] buffer, int offset, int length, byte[] pattern)
For example, consider the following two arrays:
a1: {a, b, c, d, e} a2: {d, e, f, g}In this example, the intersection of tail of
a1
with head of a2
is {d, e}
and consists of 2 overlapping elements.
The method takes the first array represented as a sub-array in buffer demarcated by an offset and length.
The second array is a fixed pattern to be matched. The method then compares the tail of the
array in the buffer with the head of the pattern and returns the number of intersecting elements,
or zero in case the two arrays do not intersect tail to head.buffer
- byte buffer containing the array whose tail to intersect.offset
- start of the array to be tail-matched in the buffer
.length
- length of the array to be tail-matched.pattern
- pattern to be head-matched.0
if any part of the tail of the array in the buffer does not match
any part of the head of the pattern, otherwise returns number of overlapping elements.