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


Java ContentType.setParameter方法代码示例

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


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

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private ContentType getContentType(Exchange exchange) throws ParseException {
    String contentTypeStr = ExchangeHelper.getContentType(exchange);
    if (contentTypeStr == null) {
        contentTypeStr = DEFAULT_CONTENT_TYPE;
    }
    ContentType contentType = new ContentType(contentTypeStr);
    String contentEncoding = ExchangeHelper.getContentEncoding(exchange);
    // add a charset parameter for text subtypes
    if (contentEncoding != null && contentType.match("text/*")) {
        contentType.setParameter("charset", MimeUtility.mimeCharset(contentEncoding));
    }
    return contentType;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:MimeMultipartDataFormat.java

示例6: addAttachments

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private void addAttachments( Enumeration<fileAttachment> _attach, Multipart _parent, boolean _isInline ) throws MessagingException{
	while ( _attach.hasMoreElements() ){
		fileAttachment nextFile = _attach.nextElement();
		FileDataSource fds 			= new FileDataSource( nextFile.getFilepath() );
		String mimeType = nextFile.getMimetype();
		if (mimeType == null){
			// if mime type not supplied then auto detect
			mimeType = FileTypeMap.getDefaultFileTypeMap().getContentType(nextFile.getFilepath());
     }else{
			// since mime type is not null then it the mime type has been set manually therefore
			// we need to ensure that any call to the underlying FileDataSource.getFileTypeMap()
			// returns a FileTypeMap that will map to this type
			fds.setFileTypeMap(new CustomFileTypeMap(mimeType));
		}
		
		String filename = cleanName(fds.getName());
		try {
			// encode the filename to ensure that it contains US-ASCII characters only
			filename = MimeUtility.encodeText( filename, "utf-8", "b" );
		} catch (UnsupportedEncodingException e5) {
			// shouldn't occur
		}
	  MimeBodyPart mimeAttach	= new MimeBodyPart();
	  mimeAttach.setDataHandler( new DataHandler(fds) );
		mimeAttach.setFileName( filename );

		ContentType ct = new ContentType(mimeType);
		ct.setParameter("name", filename );
		
		mimeAttach.setHeader("Content-Type", ct.toString() );

		if ( _isInline ){
       mimeAttach.setDisposition( "inline" );
       mimeAttach.addHeader( "Content-id", "<" + nextFile.getContentid() + ">" );
		}
     
		_parent.addBodyPart(mimeAttach);
	}
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:40,代码来源:cfMAIL.java

示例7: createAlternativePart

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private MimeMultipart createAlternativePart(ZCalendar.ZVCalendar cal, String desc, String descHtml)
  throws MessagingException, ZimbraException
{
  MimeMultipart multipart = new MimeMultipart("alternative");

  cal.addDescription(desc, null);

  MimeBodyPart textPart = new MimeBodyPart();
  textPart.setText(desc, MimeConstants.P_CHARSET_UTF8);
  multipart.addBodyPart(textPart);

  if (descHtml == null || descHtml.isEmpty())
  {
    descHtml = mPlainTextToHtmlConverter.plainText2HTML(desc);
  }

  if (!descHtml.isEmpty())
  {
    MimeBodyPart htmlPart = new MimeBodyPart();
    ContentType ct = new ContentType(MimeConstants.CT_TEXT_HTML);
    ct.setParameter(MimeConstants.P_CHARSET, MimeConstants.P_CHARSET_UTF8);
    htmlPart.setText(descHtml, MimeConstants.P_CHARSET_UTF8);
    htmlPart.setHeader("Content-Type", ct.toString());

    multipart.addBodyPart(htmlPart);
  }

  MimeBodyPart icalPart;
  try {
    icalPart = CalendarMailSender.makeICalIntoMimePart(cal);
  }
  catch (ServiceException ex)
  {
    throw ExceptionWrapper.wrap(ex);
  }
  multipart.addBodyPart(icalPart);

  return multipart;
}
 
开发者ID:ZeXtras,项目名称:OpenZAL,代码行数:40,代码来源:CalendarMime.java


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