public static interface EntityPart.Builder
EntityPart instances.| Modifier and Type | Method and Description |
|---|---|
EntityPart |
build()
Builds a new EntityPart instance using the provided property values.
|
EntityPart.Builder |
content(java.io.InputStream content)
Sets the content for this part.
|
default EntityPart.Builder |
content(java.lang.Object content)
Sets the content for this part.
|
default EntityPart.Builder |
content(java.lang.String fileName,
java.io.InputStream content)
Convenience method, equivalent to calling
fileName(fileName).content(content). |
<T> EntityPart.Builder |
content(T content,
java.lang.Class<? extends T> type)
Sets the content for this part.
|
<T> EntityPart.Builder |
content(T content,
GenericType<T> type)
Sets the content for this part.
|
EntityPart.Builder |
fileName(java.lang.String fileName)
Sets the file name for this part.
|
EntityPart.Builder |
header(java.lang.String headerName,
java.lang.String... headerValues)
Adds a new header or replaces a previously added header and sets the header
value(s).
|
EntityPart.Builder |
headers(MultivaluedMap<java.lang.String,java.lang.String> newHeaders)
Adds new headers or replaces previously added headers.
|
EntityPart.Builder |
mediaType(MediaType mediaType)
Sets the media type for the EntityPart.
|
EntityPart.Builder |
mediaType(java.lang.String mediaTypeString)
Convenience method for setting the media type for the EntityPart.
|
EntityPart.Builder mediaType(MediaType mediaType) throws java.lang.IllegalArgumentException
Content-Type header for this part.mediaType - the media type for the part to be builtjava.lang.IllegalArgumentException - if mediaType is nullEntityPart.Builder mediaType(java.lang.String mediaTypeString) throws java.lang.IllegalArgumentException
Content-Type header for this part. This call is
effectively the same as
mediaType(MediaType.valueOf(mediaTypeString)).mediaTypeString - the media type for the part to be builtjava.lang.IllegalArgumentException - if mediaTypeString cannot be parsed
or is nullEntityPart.Builder header(java.lang.String headerName, java.lang.String... headerValues) throws java.lang.IllegalArgumentException
headerName - the header nameheaderValues - the header value(s)java.lang.IllegalArgumentException - if headerName is nullEntityPart.Builder headers(MultivaluedMap<java.lang.String,java.lang.String> newHeaders) throws java.lang.IllegalArgumentException
header(String, String...) method.newHeaders - the multivalued map of headers to add to this partjava.lang.IllegalArgumentException - if newHeaders is nullEntityPart.Builder fileName(java.lang.String fileName) throws java.lang.IllegalArgumentException
Content-Disposition header of this part. When this
method is called, the default media type used for the built part will be
"application/octet-stream" if not otherwise specified.fileName - the file name for this partjava.lang.IllegalArgumentException - if fileName is nullEntityPart.Builder content(java.io.InputStream content) throws java.lang.IllegalArgumentException
build() method.
The InputStream will be closed by the implementation code after
sending the multipart data. Closing the stream before it is sent could result
in unexpected behavior.
content - InputStream of the content of this partjava.lang.IllegalArgumentException - if content is nulldefault EntityPart.Builder content(java.lang.String fileName, java.io.InputStream content) throws java.lang.IllegalArgumentException
fileName(fileName).content(content).fileName - the filename of the part.content - the content stream of the part.java.lang.IllegalArgumentException - if either parameter is null.<T> EntityPart.Builder content(T content, java.lang.Class<? extends T> type) throws java.lang.IllegalArgumentException
build() method.
If the content is specified using this method, then the build()
method is responsible for finding a registered
MessageBodyWriter that is capable of writing the
object type specified here using the default MediaType or the
MediaType specified in the mediaType(MediaType) or
mediaType(String) methods and using any headers specified via the
header(String, String...) or headers(MultivaluedMap)
methods.
T - the entity typecontent - the object to be used as the contenttype - the type of this object which will be used when selecting the
appropriate MessageBodyWriterjava.lang.IllegalArgumentException - if content is nulldefault EntityPart.Builder content(java.lang.Object content) throws java.lang.IllegalArgumentException
build() method.
If the content is specified using this method, then the build()
method is responsible for finding a registered
MessageBodyWriter that is capable of writing the
object's class type specified here using the default MediaType or the
MediaType specified in the mediaType(MediaType) or
mediaType(String) methods and using any headers specified via the
header(String, String...) or headers(MultivaluedMap)
methods.
This is the equivalent of calling
content(content, content.getClass()).
content - the object to be used as the contentjava.lang.IllegalArgumentException - if content is null<T> EntityPart.Builder content(T content, GenericType<T> type) throws java.lang.IllegalArgumentException
build() method.
If the content is specified using this method, then the build()
method is responsible for finding a registered
MessageBodyWriter that is capable of writing the
object type specified here using the default MediaType or the
MediaType specified in the mediaType(MediaType) or
mediaType(String) methods and using any headers specified via the
header(String, String...) or headers(MultivaluedMap)
methods.
T - the entity typecontent - the object to be used as the contenttype - the generic type of this object which will be used when
selecting the appropriate
MessageBodyWriterjava.lang.IllegalArgumentException - if content is nullEntityPart build() throws java.lang.IllegalStateException, java.io.IOException, WebApplicationException
EntityPart instance built from the provided property values.java.lang.IllegalStateException - if the content was not specified or no
matching
MessageBodyWriter
was found.java.io.IOException - if the underlying
MessageBodyWriter
throws an IOExceptionWebApplicationException - if the underlying
MessageBodyWriter
throws a WebApplicationException