com.sun.jersey.multipart.impl
Class MultiPartWriter

java.lang.Object
  extended by com.sun.jersey.multipart.impl.MultiPartWriter
All Implemented Interfaces:
MessageBodyWriter<MultiPart>

public class MultiPartWriter
extends Object
implements MessageBodyWriter<MultiPart>

Provider MessageBodyWriter implementation for MultiPart entities.


Constructor Summary
MultiPartWriter(Providers providers)
           
 
Method Summary
 long getSize(MultiPart entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
          Called before writeTo to ascertain the length in bytes of the serialized form of t.
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
          Ascertain if the MessageBodyWriter supports a particular type.
 void writeTo(MultiPart entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> headers, OutputStream stream)
          Write the entire list of body parts to the output stream, using the appropriate provider implementation to serialize each body part's entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiPartWriter

public MultiPartWriter(@Context
                       Providers providers)
Method Detail

getSize

public long getSize(MultiPart entity,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    MediaType mediaType)
Description copied from interface: MessageBodyWriter
Called before writeTo to ascertain the length in bytes of the serialized form of t. A non-negative return value is used in a HTTP Content-Length header.

Specified by:
getSize in interface MessageBodyWriter<MultiPart>
Parameters:
entity - the instance to write
type - the class of object that is to be written.
genericType - the type of object to be written, obtained either by reflection of a resource method return type or by inspection of the returned instance. GenericEntity provides a way to specify this information at runtime.
annotations - an array of the annotations on the resource method that returns the object.
mediaType - the media type of the HTTP entity.
Returns:
length in bytes or -1 if the length cannot be determined in advance

isWriteable

public boolean isWriteable(Class<?> type,
                           Type genericType,
                           Annotation[] annotations,
                           MediaType mediaType)
Description copied from interface: MessageBodyWriter
Ascertain if the MessageBodyWriter supports a particular type.

Specified by:
isWriteable in interface MessageBodyWriter<MultiPart>
Parameters:
type - the class of object that is to be written.
genericType - the type of object to be written, obtained either by reflection of a resource method return type or via inspection of the returned instance. GenericEntity provides a way to specify this information at runtime.
annotations - an array of the annotations on the resource method that returns the object.
mediaType - the media type of the HTTP entity.
Returns:
true if the type is supported, otherwise false.

writeTo

public void writeTo(MultiPart entity,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    MediaType mediaType,
                    MultivaluedMap<String,Object> headers,
                    OutputStream stream)
             throws IOException,
                    WebApplicationException

Write the entire list of body parts to the output stream, using the appropriate provider implementation to serialize each body part's entity.

Specified by:
writeTo in interface MessageBodyWriter<MultiPart>
Parameters:
entity - The MultiPart instance to write
type - The class of the object to be written (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
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)


Copyright © 2013 Oracle Corporation. All Rights Reserved.