com.sun.jersey.multipart.impl
Class MultiPartReaderClientSide

java.lang.Object
  extended by com.sun.jersey.multipart.impl.MultiPartReaderClientSide
All Implemented Interfaces:
MessageBodyReader<MultiPart>
Direct Known Subclasses:
MultiPartReaderServerSide

@ConstrainedTo(value=ClientSide.class)
public class MultiPartReaderClientSide
extends Object
implements MessageBodyReader<MultiPart>

Provider MessageBodyReader implementation for MultiPart entities.


Constructor Summary
MultiPartReaderClientSide(Providers providers, MultiPartConfig config)
          Accept constructor injection of the configuration parameters for this application.
 
Method Summary
 boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
          Ascertain if the MessageBodyReader can produce an instance of a particular type.
 MultiPart readFrom(Class<MultiPart> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> headers, InputStream stream)
          Read the entire list of body parts from the Input stream, using the appropriate provider implementation to deserialize each body part's entity.
protected  MultiPart readMultiPart(Class<MultiPart> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> headers, InputStream stream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiPartReaderClientSide

public MultiPartReaderClientSide(@Context
                                 Providers providers,
                                 @Context
                                 MultiPartConfig config)

Accept constructor injection of the configuration parameters for this application.

Method Detail

isReadable

public boolean isReadable(Class<?> type,
                          Type genericType,
                          Annotation[] annotations,
                          MediaType mediaType)
Description copied from interface: MessageBodyReader
Ascertain if the MessageBodyReader can produce an instance of a particular type. The type parameter gives the class of the object that should be produced, the genericType parameter gives the java.lang.reflect.Type of the object that should be produced. E.g. if the object to be produced is List, the type parameter will be java.util.List and the genericType parameter will be java.lang.reflect.ParameterizedType.

Specified by:
isReadable in interface MessageBodyReader<MultiPart>
Parameters:
type - the class of object to be produced.
genericType - the type of object to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned by Method.getGenericParameterTypes.
annotations - an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by Method.getParameterAnnotations.
mediaType - the media type of the HTTP entity, if one is not specified in the request then application/octet-stream is used.
Returns:
true if the type is supported, otherwise false.

readFrom

public MultiPart readFrom(Class<MultiPart> type,
                          Type genericType,
                          Annotation[] annotations,
                          MediaType mediaType,
                          MultivaluedMap<String,String> headers,
                          InputStream stream)
                   throws IOException,
                          WebApplicationException

Read the entire list of body parts from the Input stream, using the appropriate provider implementation to deserialize each body part's entity.

Specified by:
readFrom in interface MessageBodyReader<MultiPart>
Parameters:
type - The class of the object to be read (i.e. MultiPart.class)
genericType - The type of object to be written
annotations - Annotations on the resource method that returned this object
mediaType - Media type (multipart/*) of this entity
headers - Mutable map of HTTP headers for the entire response
stream - Output stream to which the entity should be written
Returns:
the type that was read from the stream.
Throws:
IOException - if an I/O error occurs
WebApplicationException - if an HTTP error response needs to be produced (only effective if the response is not committed yet)
WebApplicationException - if the Content-Disposition header of a multipart/form-data body part cannot be parsed

readMultiPart

protected MultiPart readMultiPart(Class<MultiPart> type,
                                  Type genericType,
                                  Annotation[] annotations,
                                  MediaType mediaType,
                                  MultivaluedMap<String,String> headers,
                                  InputStream stream)
                           throws IOException,
                                  org.jvnet.mimepull.MIMEParsingException
Throws:
IOException
org.jvnet.mimepull.MIMEParsingException


Copyright © 2013 Oracle Corporation. All Rights Reserved.