Class EntityInputStream
java.lang.Object
java.io.InputStream
org.glassfish.jersey.message.internal.EntityInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Entity input stream customized for entity message processing:
- Author:
- Marek Potociar
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
static EntityInputStream
create
(InputStream inputStream) Create an entity input stream instance wrapping the original input stream.void
Check that the entity input stream has not been closed yet.final InputStream
Get the wrapped input stream instance.boolean
isClosed()
Get the closed status of this input stream.boolean
isEmpty()
Check if the underlying entity stream is empty.void
mark
(int readLimit) boolean
int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) void
reset()
final void
setWrappedStream
(InputStream wrapped) Set the wrapped input stream instance.long
skip
(long n) Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
EntityInputStream
Extension constructor.- Parameters:
input
- underlying wrapped input stream.
-
-
Method Details
-
create
Create an entity input stream instance wrapping the original input stream. In case the original entity stream is already of typeEntityInputStream
, the stream is returned without wrapping.- Parameters:
inputStream
- input stream.- Returns:
- entity input stream.
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readLimit) - Overrides:
mark
in classInputStream
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
reset
public void reset()The method is customized to not throw an
IOException
if the reset operation fails. Instead, a runtimeProcessingException
is thrown.- Overrides:
reset
in classInputStream
- Throws:
ProcessingException
- in case the reset operation on the underlying entity input stream failed.
-
close
The method is customized to not throw an
IOException
if the close operation fails. Instead, a warning message is logged.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
ProcessingException
-
isEmpty
public boolean isEmpty()Check if the underlying entity stream is empty.Note that the operation may need to block until a first byte (or EOF) is available in the stream.
- Returns:
true
if the entity stream is empty,false
otherwise.
-
ensureNotClosed
Check that the entity input stream has not been closed yet.- Throws:
IllegalStateException
- in case the entity input stream has been closed.
-
isClosed
public boolean isClosed()Get the closed status of this input stream.- Returns:
true
if the stream has been closed,false
otherwise.
-
getWrappedStream
Get the wrapped input stream instance.- Returns:
- wrapped input stream instance.
-
setWrappedStream
Set the wrapped input stream instance.- Parameters:
wrapped
- new input stream instance to be wrapped.
-