Package org.apache.james.mime4j.dom.field

Examples of org.apache.james.mime4j.dom.field.ContentDispositionField


     *            filename parameter value or <code>null</code> if the
     *            parameter should be removed.
     */
    public void setFilename(String filename) {
        Header header = obtainHeader();
        ContentDispositionField field = (ContentDispositionField) header
                .getField(FieldName.CONTENT_DISPOSITION);
        if (field == null) {
            if (filename != null) {
                header.setField(newContentDisposition(
                        ContentDispositionField.DISPOSITION_TYPE_ATTACHMENT,
                        filename, -1, null, null, null));
            }
        } else {
            String dispositionType = field.getDispositionType();
            Map<String, String> parameters = new HashMap<String, String>(field
                    .getParameters());
            if (filename == null) {
                parameters.remove(ContentDispositionField.PARAM_FILENAME);
            } else {
                parameters
View Full Code Here


     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return content disposition type,
     * or null when this has not been set
     */
    public String getContentDispositionType() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getDispositionType() : null;
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return parameter value strings indexed by parameter name strings,
     * not null
     */
    public Map<String, String> getContentDispositionParameters() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getParameters() :
            Collections.<String, String>emptyMap();
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return filename parameter value,
     * or null when it is not present
     */
    public String getContentDispositionFilename() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getFilename() : null;
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return modification-date parameter value,
     * or null when this is not present
     */
    public Date getContentDispositionModificationDate() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getModificationDate() : null;
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return creation-date parameter value,
     * or null when this is not present
     */
    public Date getContentDispositionCreationDate() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getCreationDate() : null;
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return read-date parameter value,
     * or null when this is not present
     */
    public Date getContentDispositionReadDate() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getReadDate() : null;
    }
View Full Code Here

     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
     * @return size parameter value,
     * or -1 if this size has not been set
     */
    public long getContentDispositionSize() {
        ContentDispositionField contentDispositionField =
            (ContentDispositionField) fields.get(CONTENT_DISPOSITION);
        return contentDispositionField != null ? contentDispositionField.getSize() : -1;
    }
View Full Code Here

        assertEquals("Content-Transfer-Encoding: base64",
                decode(field));
    }

    public void testContentDispositionString() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("inline; "
                + "filename=\"testing 1 2.dat\"; size=12345; "
                + "creation-date=\"Thu, 1 Jan 1970 00:00:00 +0000\"");
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Disposition: inline; filename="
                + "\"testing 1 2.dat\"; size=12345;\r\n creation-date="
                + "\"Thu, 1 Jan 1970 00:00:00 +0000\"";
        assertEquals(expectedRaw, decode(field));
View Full Code Here

    public void testContentDispositionStringParameters() throws Exception {
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("creation-date", MimeUtil.formatDate(new Date(0),
                TimeZone.getTimeZone("GMT")));
        ContentDispositionField field = Fields.contentDisposition("attachment",
                parameters);
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Disposition: attachment; "
                + "creation-date=\"Thu, 1 Jan 1970 00:00:00\r\n +0000\"";
        assertEquals(expectedRaw, decode(field));

        assertEquals(new Date(0), field.getCreationDate());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.field.ContentDispositionField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.