Package org.apache.james.mime4j.field

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


        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

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

        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

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

        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

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

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

        f = (ContentTypeField) Field.parse("Content-Type: text/html;");
        assertEquals("text/html", f.getMimeType());
    }
   
    public void testGetMimeType() throws Exception {
        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

        f = (ContentTypeField) Field.parse("CONTENT-TYPE:   yada");
        assertEquals("", f.getMimeType());
    }
   
    public void testGetMimeTypeStatic() throws Exception {
        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

TOP

Related Classes of org.apache.james.mime4j.field.ContentTypeField

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.