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

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


        assertEquals(new Date(0), field.getCreationDate());
    }

    public void testContentDispositionStringNullParameters() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("inline",
                (Map<String, String>) null);
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Disposition: inline";
        assertEquals(expectedRaw, decode(field));
    }
View Full Code Here


        String expectedRaw = "Content-Disposition: inline";
        assertEquals(expectedRaw, decode(field));
    }

    public void testContentDispositionFilename() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("attachment",
                "some file.dat");
        assertTrue(field.isValidField());

        assertEquals("attachment", field.getDispositionType());
        assertEquals("some file.dat", field.getFilename());
    }
View Full Code Here

        assertEquals("attachment", field.getDispositionType());
        assertEquals("some file.dat", field.getFilename());
    }

    public void testContentDispositionFilenameSize() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("attachment",
                "some file.dat", 300);
        assertTrue(field.isValidField());

        assertEquals("attachment", field.getDispositionType());
        assertEquals("some file.dat", field.getFilename());
        assertEquals(300, field.getSize());
    }
View Full Code Here

        assertEquals("some file.dat", field.getFilename());
        assertEquals(300, field.getSize());
    }

    public void testContentDispositionFilenameSizeDate() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("attachment",
                "some file.dat", 300, new Date(1000), new Date(2000), new Date(
                        3000));
        assertTrue(field.isValidField());

        assertEquals("attachment", field.getDispositionType());
        assertEquals("some file.dat", field.getFilename());
        assertEquals(300, field.getSize());
        assertEquals(new Date(1000), field.getCreationDate());
        assertEquals(new Date(2000), field.getModificationDate());
        assertEquals(new Date(3000), field.getReadDate());
    }
View Full Code Here

        assertEquals(new Date(2000), field.getModificationDate());
        assertEquals(new Date(3000), field.getReadDate());
    }

    public void testInvalidContentDisposition() throws Exception {
        ContentDispositionField field = Fields.contentDisposition("inline; "
                + "filename=some file.dat");
        assertFalse(field.isValidField());

        assertEquals("inline", field.getDispositionType());
    }
View Full Code Here

     *
     * @return the disposition type or <code>null</code> if no disposition
     *         type has been set.
     */
    public String getDispositionType() {
        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
        if (field == null)
            return null;

        return field.getDispositionType();
    }
View Full Code Here

     *
     * @return the filename parameter of the content disposition or
     *         <code>null</code> if the filename has not been set.
     */
    public String getFilename() {
        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
        if (field == null)
            return null;

        return field.getFilename();
    }
View Full Code Here

     *            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

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.