当前位置: 首页>>代码示例>>Java>>正文


Java ContentType.toString方法代码示例

本文整理汇总了Java中javax.mail.internet.ContentType.toString方法的典型用法代码示例。如果您正苦于以下问题:Java ContentType.toString方法的具体用法?Java ContentType.toString怎么用?Java ContentType.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.mail.internet.ContentType的用法示例。


在下文中一共展示了ContentType.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanContentType

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:nickrussler,项目名称:eml-to-pdf-converter,代码行数:31,代码来源:ContentTypeCleaner.java

示例2: updateContentType

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private void updateContentType(boolean cleanDefaultRoot) throws MessagingException {
    BodyPart part = null;
    if (rootId == null) {
        part = getBodyPart(0);
    } else {
        part = getBodyPart(rootId);
        if (part == null) {
            if (cleanDefaultRoot)
                rootId = null;
            else
                throw new MessagingException("Can not set root: " + rootId + ": not found");
        }
    }
    if (part != null) {
        String primaryType = baseContentTypeObject.getPrimaryType();
        String subType = baseContentTypeObject.getSubType();
        ParameterList params = baseContentTypeObject.getParameterList();
        ContentType newContentType = new ContentType(primaryType, subType, params);
        ContentType rootContentType = new ContentType(part.getDataHandler().getContentType());
        newContentType.setParameter("type", rootContentType.getBaseType());
        if (rootId != null)
            newContentType.setParameter("start", stripBrackets(rootId));
        contentType = newContentType.toString();
    }
}
 
开发者ID:sviperll,项目名称:chicory,代码行数:26,代码来源:MimeMultipartRelated.java

示例3: AlfrescoMimeMultipart

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
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();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:ContentModelMessage.java

示例4: SoapMimeMultipart

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
public SoapMimeMultipart (@Nonnull final ESOAPVersion eSOAPVersion,
                          @Nonnull final Charset aCharset) throws ParseException
{
  super ("related");

  // type parameter is essential for Axis to work!
  // But no charset! RFC 2387, section 3.4 has a special definition
  final ContentType aContentType = new ContentType (contentType);
  aContentType.setParameter ("type", eSOAPVersion.getMimeType ().getAsString ());
  aContentType.setParameter ("charset", aCharset.name ());
  contentType = aContentType.toString ();
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:13,代码来源:SoapMimeMultipart.java

示例5: writeBodyPart

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private void writeBodyPart(byte[] bodyContent, Part part, ContentType contentType) throws MessagingException {
    DataSource ds = new ByteArrayDataSource(bodyContent, contentType.toString());
    part.setDataHandler(new DataHandler(ds));
    part.setHeader(CONTENT_TYPE, contentType.toString());
    if (contentType.match("text/*")) {
        part.setHeader(CONTENT_TRANSFER_ENCODING, "8bit");
    } else if (binaryContent) {
        part.setHeader(CONTENT_TRANSFER_ENCODING, "binary");
    } else {
        part.setHeader(CONTENT_TRANSFER_ENCODING, "base64");
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:MimeMultipartDataFormat.java

示例6: sendMessage

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
protected String sendMessage(ContentType contentType, byte[] message) throws Exception {
    String msgId = UUIDGenerator.getUUID();
    MimeMessage msg = new MimeMessage(session);
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(channel.getRecipient().getAddress()));
    msg.setFrom(new InternetAddress(channel.getSender().getAddress()));
    msg.setSentDate(new Date());
    msg.setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, msgId);
    msg.setHeader(MailConstants.MAIL_HEADER_X_MESSAGE_ID, msgId);
    DataHandler dh = new DataHandler(new ByteArrayDataSource(message, contentType.toString()));
    layout.setupMessage(msg, dh);
    Transport.send(msg);
    return msgId;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:14,代码来源:MailClient.java


注:本文中的javax.mail.internet.ContentType.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。