javax.mail.internet.ContentType#toString ( )源码实例Demo

下面列出了javax.mail.internet.ContentType#toString ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: eml-to-pdf-converter   文件: ContentTypeCleaner.java
/**
 * Attempt to repair the given contentType if broken.
 * @param mp Mimepart holding the contentType
 * @param contentType ContentType
 * @return fixed contentType String
 * @throws MessagingException
 */
public static String cleanContentType(MimePart mp, String contentType) throws MessagingException {
	ContentType ct = parseContentType(contentType);

	if (ct == null) {
		ct = getParsableContentType(contentType);
	}

	if (ct.getBaseType().equalsIgnoreCase("text/plain") || ct.getBaseType().equalsIgnoreCase("text/html")) {
		Charset charset = parseCharset(ct);
		if (charset == null) {
			Logger.debug("Charset of the ContentType could not be read, try to decode the contentType as quoted-printable");

			ContentType ctTmp = decodeContentTypeAsQuotedPrintable(contentType);
			if (parseCharset(ctTmp) != null) {
				ct = ctTmp;
			} else {
				ct.setParameter("charset", ContentTypeCleaner.DEFAULT_CHARSET);
			}
		}
	}

	return ct.toString();
}
 
源代码2 项目: alfresco-repository   文件: ContentModelMessage.java
public AlfrescoMimeMultipart(String subtype, FileInfo messageFileInfo)
{
    super();
    String boundary = getBoundaryValue(messageFileInfo);
    ContentType cType = new ContentType("multipart", subtype, null);
    cType.setParameter("boundary", boundary);
    contentType = cType.toString();
}
 
源代码3 项目: james-project   文件: ContentReplacer.java
private String getContentType(Mail mail, Optional<Charset> charset) throws MessagingException, ParseException {
    String contentTypeAsString = mail.getMessage().getContentType();
    if (charset.isPresent()) {
        ContentType contentType = new ContentType(contentTypeAsString);
        contentType.setParameter("charset", charset.get().name());
        return contentType.toString();
    }
    return contentTypeAsString;
}
 
源代码4 项目: james-project   文件: OnlyText.java
private static void setContentFromPart(Message m, Part p, String newText, boolean setTextPlain) throws MessagingException, IOException {
    String contentType = p.getContentType();
    if (setTextPlain) {
        ContentType ct = new ContentType(contentType);
        ct.setPrimaryType("text");
        ct.setSubType("plain");
        contentType = ct.toString();
    }
    m.setContent(newText != null ? newText : p.getContent(), contentType);
    String[] h = p.getHeader("Content-Transfer-Encoding");
    if (h != null && h.length > 0) {
        m.setHeader("Content-Transfer-Encoding", h[0]);
    }
    m.saveChanges();
}
 
源代码5 项目: james-project   文件: MimeMultipartReport.java
/**
 * Sets the content type
 * @param aContentType
 */
protected void setContentType(ContentType aContentType) {
    contentType = aContentType.toString();
}