/** * Sets the field media type and value for this body part. * * @param mediaType the media type for this field value. * @param value the field value as a Java object. */ public void setValue(MediaType mediaType, Object value) { setMediaType(mediaType); setEntity(value); }
/** * Sets the field value for this body part. This should be called * only on body parts representing simple field values. * * @param value the field value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain}. */ public void setValue(String value) { if (!MediaType.TEXT_PLAIN_TYPE.equals(getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } setEntity(value); }
/** * Allows to explicitly set the value and the MIME type of the body part * entity. This method doesn't have to be invoked if one of the non-default * constructors was already called. * <p/> * Either this method or {@link StreamDataBodyPart#setStreamEntity(InputStream)} * <strong>must</strong> be invoked if the default constructor was called. * * @param streamEntity entity to be set as a body part. * @param mediaType MIME type of the {@code streamEntity} attachment. */ public void setStreamEntity(final InputStream streamEntity, MediaType mediaType) { if (streamEntity == null) { throw new IllegalArgumentException("Stream body part entity cannot be null."); } if (mediaType == null) { mediaType = getDefaultMediaType(); } this.streamEntity = streamEntity; // Be sure to hit the parent (non-overloaded) method. super.setMediaType(mediaType); super.setEntity(streamEntity); setFormDataContentDisposition(buildContentDisposition()); }
/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Sets the field media type and value for this body part. * * @param mediaType the media type for this field value. * @param value the field value as a Java object. */ public void setValue(MediaType mediaType, Object value) { setMediaType(mediaType); setEntity(value); }
/** * Sets the field media type and value for this body part. * * @param mediaType the media type for this field value. * @param value the field value as a Java object. */ public void setValue(MediaType mediaType, Object value) { setMediaType(mediaType); setEntity(value); }
/** * Sets the field media type and value for this body part. * * @param mediaType the media type for this field value. * @param value the field value as a Java object. */ public void setValue(MediaType mediaType, Object value) { setMediaType(mediaType); setEntity(value); }
/** * Sets the field media type and value for this body part. * * @param mediaType the media type for this field value. * @param value the field value as a Java object. */ public void setValue(MediaType mediaType, Object value) { setMediaType(mediaType); setEntity(value); }
/** * Sets the field value for this body part. This should be called * only on body parts representing simple field values. * * @param value the field value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain}. */ public void setValue(String value) { if (!MediaType.TEXT_PLAIN_TYPE.equals(getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } setEntity(value); }
/** * Sets the field value for this body part. This should be called * only on body parts representing simple field values. * * @param value the field value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain}. */ public void setValue(String value) { if (!MediaType.TEXT_PLAIN_TYPE.equals(getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } setEntity(value); }
/** * Sets the field value for this body part. This should be called * only on body parts representing simple field values. * * @param value the field value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain}. */ public void setValue(String value) { if (!MediaType.TEXT_PLAIN_TYPE.equals(getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } setEntity(value); }
/** * Sets the field value for this body part. This should be called * only on body parts representing simple field values. * * @param value the field value. * @throws IllegalStateException if called on a body part with a media type other than {@code text/plain}. */ public void setValue(String value) { if (!MediaType.TEXT_PLAIN_TYPE.equals(getMediaType())) { throw new IllegalStateException(LocalizationMessages.MEDIA_TYPE_NOT_TEXT_PLAIN()); } setEntity(value); }
/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Allows to explicitly set the value and the MIME type of the body part * entity. This method doesn't have to be invoked if one of the non-default * constructors was already called. * <p/> * Either this method or {@link StreamDataBodyPart#setStreamEntity(InputStream)} * <strong>must</strong> be invoked if the default constructor was called. * * @param streamEntity entity to be set as a body part. * @param mediaType MIME type of the {@code streamEntity} attachment. */ public void setStreamEntity(final InputStream streamEntity, MediaType mediaType) { if (streamEntity == null) { throw new IllegalArgumentException("Stream body part entity cannot be null."); } if (mediaType == null) { mediaType = getDefaultMediaType(); } this.streamEntity = streamEntity; // Be sure to hit the parent (non-overloaded) method. super.setMediaType(mediaType); super.setEntity(streamEntity); setFormDataContentDisposition(buildContentDisposition()); }
/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Sets the {@link MediaType} and fileEntity for this {@link FormDataBodyPart}. * * @param fileEntity the entity of this body part. * @param mediaType the media type. */ public void setFileEntity(final File fileEntity, final MediaType mediaType) { super.setMediaType(mediaType); super.setEntity(fileEntity); this.fileEntity = fileEntity; if (fileEntity != null) { FormDataContentDisposition.FormDataContentDispositionBuilder builder = FormDataContentDisposition.name(getName()); builder.fileName(fileEntity.getName()); if (fileEntity.exists()) { builder.size(fileEntity.length()); builder.modificationDate(new Date(fileEntity.lastModified())); } setFormDataContentDisposition(builder.build()); } }
/** * Allows to explicitly set the value and the MIME type of the body part * entity. This method doesn't have to be invoked if one of the non-default * constructors was already called. * <p/> * Either this method or {@link StreamDataBodyPart#setStreamEntity(InputStream)} * <strong>must</strong> be invoked if the default constructor was called. * * @param streamEntity entity to be set as a body part. * @param mediaType MIME type of the {@code streamEntity} attachment. */ public void setStreamEntity(final InputStream streamEntity, MediaType mediaType) { if (streamEntity == null) { throw new IllegalArgumentException("Stream body part entity cannot be null."); } if (mediaType == null) { mediaType = getDefaultMediaType(); } this.streamEntity = streamEntity; // Be sure to hit the parent (non-overloaded) method. super.setMediaType(mediaType); super.setEntity(streamEntity); setFormDataContentDisposition(buildContentDisposition()); }
/** * Allows to explicitly set the value and the MIME type of the body part * entity. This method doesn't have to be invoked if one of the non-default * constructors was already called. * <p/> * Either this method or {@link StreamDataBodyPart#setStreamEntity(InputStream)} * <strong>must</strong> be invoked if the default constructor was called. * * @param streamEntity entity to be set as a body part. * @param mediaType MIME type of the {@code streamEntity} attachment. */ public void setStreamEntity(final InputStream streamEntity, MediaType mediaType) { if (streamEntity == null) { throw new IllegalArgumentException("Stream body part entity cannot be null."); } if (mediaType == null) { mediaType = getDefaultMediaType(); } this.streamEntity = streamEntity; // Be sure to hit the parent (non-overloaded) method. super.setMediaType(mediaType); super.setEntity(streamEntity); setFormDataContentDisposition(buildContentDisposition()); }
/** * Allows to explicitly set the value and the MIME type of the body part * entity. This method doesn't have to be invoked if one of the non-default * constructors was already called. * <p/> * Either this method or {@link StreamDataBodyPart#setStreamEntity(InputStream)} * <strong>must</strong> be invoked if the default constructor was called. * * @param streamEntity entity to be set as a body part. * @param mediaType MIME type of the {@code streamEntity} attachment. */ public void setStreamEntity(final InputStream streamEntity, MediaType mediaType) { if (streamEntity == null) { throw new IllegalArgumentException("Stream body part entity cannot be null."); } if (mediaType == null) { mediaType = getDefaultMediaType(); } this.streamEntity = streamEntity; // Be sure to hit the parent (non-overloaded) method. super.setMediaType(mediaType); super.setEntity(streamEntity); setFormDataContentDisposition(buildContentDisposition()); }