/** * Builder pattern method to add a newly configured {@link BodyPart} * to this {@link MultiPart}. * * @param entity entity object for this body part. * @param mediaType content type for this body part. */ public MultiPart bodyPart(Object entity, MediaType mediaType) { BodyPart bodyPart = new BodyPart(entity, mediaType); return bodyPart(bodyPart); }
@Override protected StringBuilder toStringBuffer() { StringBuilder sb = super.toStringBuffer(); addStringParameter(sb, "name", name); return sb; }
/** * Gets the control name. * * @return the control name. */ public String getName() { FormDataContentDisposition formDataContentDisposition = getFormDataContentDisposition(); if (formDataContentDisposition == null) { return null; } return formDataContentDisposition.getName(); }
/** * Performs any necessary cleanup at the end of processing this * {@link MultiPart}. */ @Override public void cleanup() { for (BodyPart bp : getBodyParts()) { bp.cleanup(); } }
/** * Instantiates a new {@code BodyPart} with the specified characteristics. * * @param entity entity for this body part. * @param mediaType {@link MediaType} for this body part. */ public BodyPart(final Object entity, final MediaType mediaType) { setEntity(entity); setMediaType(mediaType); }
/** * Gets the form data content disposition. * * @return the form data content disposition. */ public FormDataContentDisposition getFormDataContentDisposition() { return (FormDataContentDisposition) getContentDisposition(); }
/** * Builder pattern method to return this {@code BodyPart} after additional configuration. * * @param type media type to set for this {@code BodyPart}. * @return body-part instance. */ public BodyPart type(final MediaType type) { setMediaType(type); return this; }
/** * Builder pattern method to return this {@code BodyPart} after additional configuration. * * @param entity entity to set for this {@code BodyPart}. * @return body-part instance. */ public BodyPart entity(final Object entity) { setEntity(entity); return this; }
@Override public FormDataContentDisposition build() { return new FormDataContentDisposition(type, name, fileName, creationDate, modificationDate, readDate, size); } }
/** * @return a "multipart/mixed" with a boundary parameter. */ public static MediaType createMixed() { return create(MULTIPART_MIXED_TYPE); }
/** * Sets the form data content disposition. * * @param formDataContentDisposition the form data content disposition. */ public void setFormDataContentDisposition(FormDataContentDisposition formDataContentDisposition) { super.setContentDisposition(formDataContentDisposition); }
/** * Defers to {@link #cleanup}. */ public void close() throws IOException { cleanup(); }
/** * Override the entity set operation on a {@link MultiPart} to throw * {@code IllegalArgumentException}. * * @param entity entity to set for this {@link BodyPart}. */ @Override public BodyPart entity(Object entity) { setEntity(entity); return this; }
/** * Instantiates a named {@link FormDataBodyPart} with a * media type of {@code text/plain} and String value. * * @param name the control name for this body part. * @param value the value for this body part. */ public FormDataBodyPart(String name, String value) { super(value, MediaType.TEXT_PLAIN_TYPE); this.fileNameFix = false; setName(name); }
/** * Load and customize (if necessary) the configuration values for the * {@code jersey-multipart} injection binder. * * @throws IllegalArgumentException if the configuration resource * exists, but there are problems reading it */ public MultiPartProperties() { configure(); }
/** * Start building content disposition. * * @param type the disposition type. * @return the content disposition builder. */ public static ContentDispositionBuilder type(final String type) { return new ContentDispositionBuilder(type); }
/** * Instantiates a new {@code BodyPart} with the specified characteristics. * * @param mediaType {@link MediaType} for this body part. */ public BodyPart(final MediaType mediaType) { setMediaType(mediaType); }
/** * @return a "multipart/digest" with a boundary parameter. */ public static MediaType createDigest() { return create(MULTIPART_DIGEST_TYPE); }
/** * Builder pattern method to return this {@code BodyPart} after * additional configuration. * * @param contentDisposition content disposition to set for this {@code BodyPart}. * @return body-part instance. */ public BodyPart contentDisposition(final ContentDisposition contentDisposition) { setContentDisposition(contentDisposition); return this; }