Examples of ContentTypeField


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

     * Content-Type field is set for this <code>Entity</code>.
     *
     * @return the MIME type.
     */
    public String getMimeType() {
        ContentTypeField child =
            getContentTypeField();
        ContentTypeField parent = getParent() != null
            ? (ContentTypeField) getParent().getHeader().
                                                getField(FieldName.CONTENT_TYPE)
            : null;

        return calcMimeType(child, parent);
View Full Code Here

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

     * method returns <code>false</code> if no boundary exists.
     *
     * @return <code>true</code> on match, <code>false</code> otherwise.
     */
    public boolean isMultipart() {
        ContentTypeField f = getContentTypeField();
        return f != null
                && f.getBoundary() != null
                && getMimeType().startsWith(
                        ContentTypeField.TYPE_MULTIPART_PREFIX);
    }
View Full Code Here

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

    public String getSubType() {
        return subType;
    }

    public Map<String, String> getContentTypeParameters() {
        ContentTypeField contentTypeField = (ContentTypeField) fields.get(CONTENT_TYPE);
        return contentTypeField != null ? contentTypeField.getParameters() :
            Collections.<String, String>emptyMap();
    }
View Full Code Here

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

import org.apache.james.mime4j.util.MimeUtil;

public class FieldsTest extends TestCase {

    public void testContentTypeString() throws Exception {
        ContentTypeField field = Fields.contentType("multipart/mixed; "
                + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                + ".2dce5678cbc933d5=-\"");
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Type: multipart/mixed;\r\n "
                + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                + ".2dce5678cbc933d5=-\"";
        assertEquals(expectedRaw, decode(field));
View Full Code Here

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

    public void testContentTypeStringParameters() throws Exception {
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("boundary",
                "-=Part.0.37877968dd4f6595.11eccf0271c.2dce5678cbc933d5=-");
        ContentTypeField field = Fields.contentType("multipart/mixed",
                parameters);
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Type: multipart/mixed;\r\n "
                + "boundary=\"-=Part.0.37877968dd4f6595.11eccf0271c"
                + ".2dce5678cbc933d5=-\"";
        assertEquals(expectedRaw, decode(field));
View Full Code Here

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

    }

    public void testContentTypeStringParametersWithSpaces() throws Exception {
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("param", "value with space chars");
        ContentTypeField field = Fields.contentType("multipart/mixed",
                parameters);
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Type: multipart/mixed; "
                + "param=\"value with space chars\"";
        assertEquals(expectedRaw, decode(field));
    }
View Full Code Here

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

                + "param=\"value with space chars\"";
        assertEquals(expectedRaw, decode(field));
    }

    public void testContentTypeStringNullParameters() throws Exception {
        ContentTypeField field = Fields.contentType("text/plain", null);
        assertTrue(field.isValidField());

        String expectedRaw = "Content-Type: text/plain";
        assertEquals(expectedRaw, decode(field));
    }
View Full Code Here

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

        String expectedRaw = "Content-Type: text/plain";
        assertEquals(expectedRaw, decode(field));
    }

    public void testInvalidContentType() throws Exception {
        ContentTypeField field = Fields.contentType("multipart/mixed; "
                + "boundary=-=Part.0.37877968dd4f6595.11eccf0271c"
                + ".2dce5678cbc933d5=-");
        assertFalse(field.isValidField());

        assertEquals("multipart/mixed", field.getMimeType());
    }
View Full Code Here

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

        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return ContentTypeFieldLenientImpl.PARSER.parse(rawField, null);
    }

    public void testMimeTypeWithSemiColonNoParams() throws Exception  {
        ContentTypeField f = parse("Content-Type: text/html;");
        assertEquals("text/html", f.getMimeType());
    }
View Full Code Here

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

        ContentTypeField f = parse("Content-Type: text/html;");
        assertEquals("text/html", f.getMimeType());
    }

    public void testMimeTypeWithMultipleSemiColon() throws Exception  {
        ContentTypeField f = parse("Content-Type: text/html;;;");
        assertEquals("text/html", f.getMimeType());
        assertEquals(1, f.getParameters().size());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.