Class EntityInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.glassfish.jersey.message.internal.EntityInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
InboundMessageContext.EntityContent
public class EntityInputStream extends java.io.InputStream
-
-
Constructor Summary
Constructors Constructor Description EntityInputStream(java.io.InputStream input)Extension constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()static EntityInputStreamcreate(java.io.InputStream inputStream)Create an entity input stream instance wrapping the original input stream.voidensureNotClosed()Check that the entity input stream has not been closed yet.java.io.InputStreamgetWrappedStream()Get the wrapped input stream instance.booleanisClosed()Get the closed status of this input stream.booleanisEmpty()Check if the underlying entity stream is empty.voidmark(int readLimit)booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()voidsetWrappedStream(java.io.InputStream wrapped)Set the wrapped input stream instance.longskip(long n)
-
-
-
Method Detail
-
create
public static EntityInputStream create(java.io.InputStream inputStream)
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
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readLimit)
- Overrides:
markin classjava.io.InputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
reset
public void reset()
The method is customized to not throw an
IOExceptionif the reset operation fails. Instead, a runtimeProcessingExceptionis thrown.- Overrides:
resetin classjava.io.InputStream- Throws:
javax.ws.rs.ProcessingException- in case the reset operation on the underlying entity input stream failed.
-
close
public void close() throws javax.ws.rs.ProcessingExceptionThe method is customized to not throw an
IOExceptionif the close operation fails. Instead, a warning message is logged.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
javax.ws.rs.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:
trueif the entity stream is empty,falseotherwise.
-
ensureNotClosed
public void ensureNotClosed() throws java.lang.IllegalStateExceptionCheck that the entity input stream has not been closed yet.- Throws:
java.lang.IllegalStateException- in case the entity input stream has been closed.
-
isClosed
public boolean isClosed()
Get the closed status of this input stream.- Returns:
trueif the stream has been closed,falseotherwise.
-
getWrappedStream
public final java.io.InputStream getWrappedStream()
Get the wrapped input stream instance.- Returns:
- wrapped input stream instance.
-
setWrappedStream
public final void setWrappedStream(java.io.InputStream wrapped)
Set the wrapped input stream instance.- Parameters:
wrapped- new input stream instance to be wrapped.
-
-