javax.ws.rs.ext
Interface EntityProvider<T>


@Contract
public interface EntityProvider<T>


A provider that supports the conversion of a type to and from a stream. To add a EntityProvider implementation, annotate the implementation class with @Provider.

See Also:
Provider

Method Summary
 T readFrom(java.lang.Class<T> type, java.lang.String mediaType, MultivaluedMap<java.lang.String,java.lang.String> httpHeaders, java.io.InputStream entityStream)
          Read a type from the InputStream.
 boolean supports(java.lang.Class<?> type)
          Ascertain if the Provider supports a particular type.
 void writeTo(T t, MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders, java.io.OutputStream entityStream)
          Write a type to an HTTP response.
 

Method Detail

supports

boolean supports(java.lang.Class<?> type)
Ascertain if the Provider supports a particular type.

Parameters:
type - the type that is to be supported.
Returns:
true if the type is supported, otherwise false.

readFrom

T readFrom(java.lang.Class<T> type,
           java.lang.String mediaType,
           MultivaluedMap<java.lang.String,java.lang.String> httpHeaders,
           java.io.InputStream entityStream)
           throws java.io.IOException
Read a type from the InputStream.

Parameters:
type - the type that is to be read from the entity stream. May be null if only one type is supported.
mediaType - the media type of the HTTP entity.
httpHeaders - the HTTP headers associated with HTTP entity.
entityStream - the InputStream of the HTTP entity.
Returns:
the type that was read from the stream.
Throws:
java.io.IOException - if an IO error arises

writeTo

void writeTo(T t,
             MultivaluedMap<java.lang.String,java.lang.Object> httpHeaders,
             java.io.OutputStream entityStream)
             throws java.io.IOException
Write a type to an HTTP response.

Parameters:
t - the type to write.
httpHeaders - the HTTP response headers.
entityStream - the OutputStream for the HTTP entity.
Throws:
java.io.IOException - if an IO error arises


Terms of Use; Privacy Policy; Copyright ©2013-2016 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close