Class MultiPartWriter

  • All Implemented Interfaces:
    jakarta.ws.rs.ext.MessageBodyWriter<MultiPart>

    @Singleton
    @Produces("multipart/*")
    public class MultiPartWriter
    extends Object
    implements jakarta.ws.rs.ext.MessageBodyWriter<MultiPart>
    Provider MessageBodyWriter implementation for MultiPart entities.
    Author:
    Craig McClanahan, Paul Sandoz, Michal Gajdos
    • Constructor Detail

      • MultiPartWriter

        public MultiPartWriter​(@Context
                               jakarta.ws.rs.ext.Providers providers)
    • Method Detail

      • getSize

        public long getSize​(MultiPart entity,
                            Class<?> type,
                            Type genericType,
                            Annotation[] annotations,
                            jakarta.ws.rs.core.MediaType mediaType)
        Specified by:
        getSize in interface jakarta.ws.rs.ext.MessageBodyWriter<MultiPart>
      • isWriteable

        public boolean isWriteable​(Class<?> type,
                                   Type genericType,
                                   Annotation[] annotations,
                                   jakarta.ws.rs.core.MediaType mediaType)
        Specified by:
        isWriteable in interface jakarta.ws.rs.ext.MessageBodyWriter<MultiPart>
      • writeTo

        public void writeTo​(MultiPart entity,
                            Class<?> type,
                            Type genericType,
                            Annotation[] annotations,
                            jakarta.ws.rs.core.MediaType mediaType,
                            jakarta.ws.rs.core.MultivaluedMap<String,​Object> headers,
                            OutputStream stream)
                     throws IOException,
                            jakarta.ws.rs.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 jakarta.ws.rs.ext.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.
        jakarta.ws.rs.WebApplicationException - if an HTTP error response needs to be produced (only effective if the response is not committed yet).