Class MultiPart

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    FormDataMultiPart

    public class MultiPart
    extends BodyPart
    implements Closeable
    A mutable model representing a MIME MultiPart entity. This class extends BodyPart because MultiPart entities can be nested inside other MultiPart entities to an arbitrary depth.
    Author:
    Craig McClanahan, Paul Sandoz, Michal Gajdos
    • Constructor Detail

      • MultiPart

        public MultiPart()
        Instantiates a new MultiPart with a mediaType of multipart/mixed.
      • MultiPart

        public MultiPart​(jakarta.ws.rs.core.MediaType mediaType)
        Instantiates a new MultiPart with the specified characteristics.
        Parameters:
        mediaType - the MediaType for this multipart.
    • Method Detail

      • setEntity

        public void setEntity​(Object entity)
        Disables access to the entity for a MultiPart. Use the list returned by getBodyParts() to access the relevant BodyPart instead.
        Overrides:
        setEntity in class BodyPart
        Parameters:
        entity -
      • setMediaType

        public void setMediaType​(jakarta.ws.rs.core.MediaType mediaType)
        Sets the MediaType for this MultiPart. If never set, the default MediaType MUST be multipart/mixed.
        Overrides:
        setMediaType in class BodyPart
        Parameters:
        mediaType - the new MediaType.
        Throws:
        IllegalArgumentException - if the type property is not set to multipart.
      • bodyPart

        public MultiPart bodyPart​(Object entity,
                                  jakarta.ws.rs.core.MediaType mediaType)
        Builder pattern method to add a newly configured BodyPart to this MultiPart.
        Parameters:
        entity - entity object for this body part.
        mediaType - content type for this body part.
      • entity

        public BodyPart entity​(Object entity)
        Override the entity set operation on a MultiPart to throw IllegalArgumentException.
        Overrides:
        entity in class BodyPart
        Parameters:
        entity - entity to set for this BodyPart.
        Returns:
        body-part instance.
      • type

        public MultiPart type​(jakarta.ws.rs.core.MediaType type)
        Builder pattern method to return this MultiPart after additional configuration.
        Overrides:
        type in class BodyPart
        Parameters:
        type - media type to set for this MultiPart.
        Returns:
        body-part instance.
      • cleanup

        public void cleanup()
        Performs any necessary cleanup at the end of processing this MultiPart.
        Overrides:
        cleanup in class BodyPart