Examples of ContentTypeField


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(
                FieldName.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(
                FieldName.CONTENT_TYPE);
        return cField.getBoundary();
    }
View Full Code Here

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

               
            } else if (o instanceof ContentTypeField) {
                /*
                 * Content-Type field.
                 */
                ContentTypeField field = (ContentTypeField) o;
                StringBuffer sb = new StringBuffer();
                sb.append("MIME type: " + field.getMimeType() + "\n");
                Map params = field.getParameters();
                for (Iterator it = params.keySet().iterator(); it.hasNext();) {
                    String name = (String) it.next();
                    sb.append(name + " = " + params.get(name) + "\n");
                }
                textView.setText(sb.toString());
               
            } else if (o instanceof AddressListField) {
                /*
                 * An address field (From, To, Cc, etc)
                 */
                AddressListField field = (AddressListField) o;
                MailboxList list = field.getAddressList().flatten();
                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < list.size(); i++) {
                    Mailbox mb = list.get(i);
                    sb.append(mb.getAddressString() + "\n");
                }
View Full Code Here

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

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

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

        f = (ContentTypeField) Field.parse("Content-Type: text/html;");
        assertEquals("text/html", f.getMimeType());
    }
   
    public void testGetMimeType() {
        ContentTypeField f = null;
       
        f = (ContentTypeField) Field.parse("Content-Type: text/PLAIN");
        assertEquals("text/plain", f.getMimeType());
       
        f = (ContentTypeField) Field.parse("content-type:   TeXt / html   ");
        assertEquals("text/html", f.getMimeType());
       
        f = (ContentTypeField) Field.parse("CONTENT-TYPE:   x-app/yada ;"
                                                    + "  param = yada");
        assertEquals("x-app/yada", f.getMimeType());
       
        f = (ContentTypeField) Field.parse("CONTENT-TYPE:   yada");
        assertEquals("", f.getMimeType());
    }
View Full Code Here

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

        f = (ContentTypeField) Field.parse("CONTENT-TYPE:   yada");
        assertEquals("", f.getMimeType());
    }
   
    public void testGetMimeTypeStatic() {
        ContentTypeField child = null;
        ContentTypeField parent = null;
       
        child = (ContentTypeField) Field.parse("Content-Type: child/type");
        parent = (ContentTypeField) Field.parse("Content-Type: parent/type");
        assertEquals("child/type", ContentTypeField.getMimeType(child, parent));
       
View Full Code Here

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

        parent = (ContentTypeField) Field.parse("Content-Type: multipart/digest");
        assertEquals("message/rfc822", ContentTypeField.getMimeType(child, parent));
    }
   
    public void testGetCharsetStatic() {
        ContentTypeField f = null;
       
        f = (ContentTypeField) Field.parse("Content-Type: some/type; charset=iso8859-1");
        assertEquals("iso8859-1", ContentTypeField.getCharset(f));
       
        f = (ContentTypeField) Field.parse("Content-Type: some/type;");
View Full Code Here

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

        f = (ContentTypeField) Field.parse("Content-Type: some/type;");
        assertEquals("us-ascii", ContentTypeField.getCharset(f));
    }
   
    public void testGetParameter() {
        ContentTypeField f = null;
       
        f = (ContentTypeField) Field.parse("CONTENT-TYPE:   text / html ;"
                                                + "  boundary=yada yada");
        assertEquals("yada", f.getParameter("boundary"));
       
        f = (ContentTypeField) Field.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 = (ContentTypeField) Field.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.field.ContentTypeField

     * @throws MimeException if case of a MIME protocol violation
     */
    public void writeTo(final OutputStream out, int mode) throws IOException, MimeException {
        Entity e = getParent();
       
        ContentTypeField cField = (ContentTypeField) e.getHeader().getField(
                Field.CONTENT_TYPE);
        if (cField == null || cField.getBoundary() == null) {
            throw new MimeException("Multipart boundary not specified");
        }
        String boundary = cField.getBoundary();

        Charset charset = null;
        if (mode == MessageUtils.LENIENT) {
            if (cField != null && cField.getCharset() != null) {
                charset = CharsetUtil.getCharset(cField.getCharset());
            } else {
                charset = MessageUtils.ISO_8859_1;
            }
        } else {
            charset = MessageUtils.DEFAULT_CHARSET;
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.