T
- chunk type.public class ChunkedInput<T>
extends javax.ws.rs.core.GenericType<T>
implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
private static class |
ChunkedInput.AbstractBoundaryParser |
private static class |
ChunkedInput.FixedBoundaryParser |
private static class |
ChunkedInput.FixedMultiBoundaryParser |
Modifier and Type | Field and Description |
---|---|
private java.lang.annotation.Annotation[] |
annotations |
private java.util.concurrent.atomic.AtomicBoolean |
closed |
private javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> |
headers |
private java.io.InputStream |
inputStream |
private static java.util.logging.Logger |
LOGGER |
private javax.ws.rs.core.MediaType |
mediaType |
private MessageBodyWorkers |
messageBodyWorkers |
private ChunkParser |
parser |
private PropertiesDelegate |
propertiesDelegate |
Modifier | Constructor and Description |
---|---|
protected |
ChunkedInput(java.lang.reflect.Type chunkType,
java.io.InputStream inputStream,
java.lang.annotation.Annotation[] annotations,
javax.ws.rs.core.MediaType mediaType,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers,
MessageBodyWorkers messageBodyWorkers,
PropertiesDelegate propertiesDelegate)
Package-private constructor used by the
ChunkedInputReader . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
static ChunkParser |
createMultiParser(java.lang.String... boundaries)
Create a new chunk multi-parser that will split the response entity input stream
based on multiple fixed boundary strings.
|
static ChunkParser |
createParser(byte[] boundary)
Create new chunk parser that will split the response entity input stream
based on a fixed boundary sequence of bytes.
|
static ChunkParser |
createParser(java.lang.String boundary)
Create new chunk parser that will split the response entity input stream
based on a fixed boundary string.
|
javax.ws.rs.core.MediaType |
getChunkType()
Get chunk data media type.
|
ChunkParser |
getParser()
Get the underlying chunk parser.
|
boolean |
isClosed()
Check if the chunked input has been closed.
|
T |
read()
Read next chunk from the response stream and convert it to a Java instance
using the
chunk media type . |
void |
setChunkType(javax.ws.rs.core.MediaType mediaType)
Set custom chunk data media type.
|
void |
setChunkType(java.lang.String mediaType)
Set custom chunk data media type from a string value.
|
void |
setParser(ChunkParser parser)
Set new chunk parser.
|
private static final java.util.logging.Logger LOGGER
private final java.util.concurrent.atomic.AtomicBoolean closed
private ChunkParser parser
private javax.ws.rs.core.MediaType mediaType
private final java.io.InputStream inputStream
private final java.lang.annotation.Annotation[] annotations
private final javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers
private final MessageBodyWorkers messageBodyWorkers
private final PropertiesDelegate propertiesDelegate
protected ChunkedInput(java.lang.reflect.Type chunkType, java.io.InputStream inputStream, java.lang.annotation.Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> headers, MessageBodyWorkers messageBodyWorkers, PropertiesDelegate propertiesDelegate)
ChunkedInputReader
.chunkType
- chunk type.inputStream
- response input stream.annotations
- annotations associated with response entity.mediaType
- response entity media type.headers
- response headers.messageBodyWorkers
- message body workers.propertiesDelegate
- properties delegate for this request/response.public static ChunkParser createParser(java.lang.String boundary)
boundary
- chunk boundary.public static ChunkParser createParser(byte[] boundary)
boundary
- chunk boundary.public static ChunkParser createMultiParser(java.lang.String... boundaries)
boundaries
- chunk boundaries.public ChunkParser getParser()
Note: Access to internal chunk parser is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
public void setParser(ChunkParser parser)
Note: Access to internal chunk parser is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
parser
- new chunk parser.public javax.ws.rs.core.MediaType getChunkType()
setting
a custom non-null
chunk media type value.
Note: Access to internal chunk media type is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
public void setChunkType(javax.ws.rs.core.MediaType mediaType) throws java.lang.IllegalArgumentException
null
chunk media type. Once this method is invoked,
all subsequent chunk reads
will use the newly set chunk media
type when selecting the proper MessageBodyReader
for
chunk de-serialization.
Note: Access to internal chunk media type is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
mediaType
- custom chunk data media type. Must not be null
.java.lang.IllegalArgumentException
- in case the mediaType
is null
.public void setChunkType(java.lang.String mediaType) throws java.lang.IllegalArgumentException
Note: Access to internal chunk media type is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
mediaType
- custom chunk data media type. Must not be null
.java.lang.IllegalArgumentException
- in case the mediaType
cannot be parsed into
a valid MediaType
instance or is null
.setChunkType(javax.ws.rs.core.MediaType)
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean isClosed()
true
if this chunked input has been closed, false
otherwise.public T read() throws java.lang.IllegalStateException
chunk media type
. The method returns null
if the underlying entity input stream has been closed (either implicitly or explicitly
by calling the close()
method).
Note: Access to internal chunk parser is not a thread-safe operation and has to be explicitly synchronized in case the chunked input is used from multiple threads.
null
if the underlying entity input stream
has been closed while reading next chunk data.java.lang.IllegalStateException
- in case this chunked input has been closed.