Examples of ContentTypeField


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

        assertEquals("text/html", f.getMimeType());
        assertEquals(1, f.getParameters().size());
    }

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

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

        assertEquals(1, f.getParameters().size());
        assertEquals("stuff", f.getParameter(""));
    }

    public void testGetMimeType() throws Exception {
        ContentTypeField f = parse("Content-Type: text/PLAIN");
        assertEquals("text/plain", f.getMimeType());

        f = parse("content-type:   TeXt / html   ");
        assertEquals("text/html", f.getMimeType());

        f = parse("CONTENT-TYPE:   x-app/yada ;"
                                                    + "  param = yada");
        assertEquals("x-app/yada", f.getMimeType());

        f = parse("CONTENT-TYPE:   yada");
        assertEquals(null, f.getMimeType());
    }
View Full Code Here

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

        f = parse("CONTENT-TYPE:   yada");
        assertEquals(null, f.getMimeType());
    }

    public void testGetParameter() throws Exception {
        ContentTypeField f = parse("CONTENT-TYPE:   text / html ;"
                                                + "  boundary=yada yada");
        assertEquals("yada yada", f.getParameter("boundary"));

        f = parse("Content-Type: x-app/yada;"
                                                + "  boUNdarY= \"ya:\\\"*da\"; "
                                                + "\tcharset\t =  us-ascii");
        assertEquals("ya:\"*da", f.getParameter("boundary"));
        assertEquals("us-ascii", f.getParameter("charset"));

        f = parse("Content-Type: x-app/yada;  "
                            + "boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
                            + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
        assertEquals("ya \"\"\tda \"", f.getParameter("boundary"));
        assertEquals("\"hepp\"  =us\t-ascii", f.getParameter("charset"));
    }
View Full Code Here

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

        Message message = builder.parseMessage(
                new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
        assertEquals("multipart/form-data", message.getMimeType());
        assertEquals(1, message.getHeader().getFields().size());
        ContentTypeField contentTypeField = ((ContentTypeField) message
                .getHeader().getField(FieldName.CONTENT_TYPE));
        assertEquals("foo", contentTypeField.getBoundary());
        Multipart multipart = (Multipart) message.getBody();
        assertEquals(3, multipart.getCount());
    }
View Full Code Here

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

  }

  @Override
  public void parse(InputStream is) throws IOException {
    super.parse(is);
    ContentTypeField contentTypeField = (ContentTypeField) mimeMessage
        .getHeader().getField(FieldName.CONTENT_TYPE);
    start = contentTypeField.getParameter("start");
    startInfo = contentTypeField.getParameter("start-info");
    type = contentTypeField.getParameter("type");
    rootPart = start == null ? getParts().get(0) : relatedMap.get(start);
  }
View Full Code Here

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

        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
            charset = MIME.DEFAULT_CHARSET;
            break;
        case BROWSER_COMPATIBLE:
            if (cField.getCharset() != null) {
                charset = CharsetUtil.getCharset(cField.getCharset());
            } else {
                charset = CharsetUtil.getCharset(HTTP.DEFAULT_CONTENT_CHARSET);
            }
            break;
        }
View Full Code Here

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

        return charset;
    }
   
    protected String getBoundary() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        return cField.getBoundary();
    }
View Full Code Here

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

        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
            charset = MIME.DEFAULT_CHARSET;
            break;
        case BROWSER_COMPATIBLE:
            if (cField.getCharset() != null) {
                charset = CharsetUtil.getCharset(cField.getCharset());
            } else {
                charset = CharsetUtil.getCharset(HTTP.DEFAULT_CONTENT_CHARSET);
            }
            break;
        }
View Full Code Here

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

        return charset;
    }
   
    protected String getBoundary() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        return cField.getBoundary();
    }
View Full Code Here

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

        this.mode = mode;
    }

    protected Charset getCharset() {
        Entity e = getParent();
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        Charset charset = null;
       
        switch (this.mode) {
        case STRICT:
            charset = MIME.DEFAULT_CHARSET;
            break;
        case BROWSER_COMPATIBLE:
            if (cField.getCharset() != null) {
                charset = CharsetUtil.getCharset(cField.getCharset());
            } else {
                charset = CharsetUtil.getCharset(HTTP.DEFAULT_CONTENT_CHARSET);
            }
            break;
        }
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.