Class MultiPart

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    FormDataMultiPart

    public class MultiPart
    extends BodyPart
    implements java.io.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.
    • Constructor Detail

      • MultiPart

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

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

      • getEntity

        public java.lang.Object getEntity()
        Disables access to the entity for a MultiPart. Use the list returned by getBodyParts() to access the relevant BodyPart instead.
        Overrides:
        getEntity in class BodyPart
        Returns:
        an entity of this body part.
        Throws:
        java.lang.IllegalStateException - thrown unconditionally.
      • setEntity

        public void setEntity​(java.lang.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​(javax.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:
        java.lang.IllegalArgumentException - if the type property is not set to multipart.
      • bodyPart

        public MultiPart bodyPart​(java.lang.Object entity,
                                  javax.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​(java.lang.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​(javax.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
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException