All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.feilong.net.mail.util.MimeType Maven / Gradle / Ivy

Go to download

feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.

There is a newer version: 4.0.8
Show newest version
/*
 * Copyright (C) 2008 feilong
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.feilong.net.mail.util;

/**
 * 多用途互联网邮件扩展(MIME,Multipurpose Internet Mail Extensions)是一个互联网标准,它扩展了电子邮件标准.
 * 
 * 
*

* 这个标准被定义在RFC 2045、RFC 2046、RFC 2047、RFC 2048、RFC 2049等RFC中. *

*
* *

内容类型(Content-Type):

* *
*

* 这个头部领域用于指定消息的类型.一般以下面的形式出现:
* Content-Type: [type]/[subtype]; parameter *

*
* *

type有下面的形式:

* *
* *

*

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
字段说明
Text用于标准化地表示的文本信息,文本消息可以是多种字符集和或者多种格式的;
Multipart用于连接消息体的多个部分构成一个消息,这些部分可以是不同类型的数据;
Application用于传输应用程序数据或者二进制数据;
Message用于包装一个E-mail消息;
Image用于传输静态图片数据;
Audio用于传输音频或者音声数据;
Video用于传输动态影像数据,可以是与音频编辑在一起的视频数据格式.
*
*

*
* * *

subtype用于指定type的详细形式:

* *
*

* * content-type/subtype配对的集合和与此相关的参数,将随着时间而增长.
* * 为了确保这些值在一个有序而且公开的状态下开发,
* MIME使用Internet Assigned Numbers Authority (IANA)作为中心的注册机制来管理这些值.
* * 常用的subtype值如下所示:
* *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
字段说明
text/plain纯文本
text/htmlHTML文档
application/xhtml+xmlXHTML文档
image/gifGIF图像
image/jpegJPEG图像【PHP中为:image/pjpeg】
image/pngPNG图像【PHP中为:image/x-png】
video/mpegMPEG动画
application/octet-stream任意的二进制数据
application/pdfPDF文档
application/mswordMicrosoft Word文件
application/vnd.wap.xhtml+xmlwap1.0+
application/xhtml+xmlwap2.0+
message/rfc822RFC 822形式
multipart/alternativeHTML邮件的HTML形式和纯文本形式,相同内容使用不同形式表示,alternative content, such as a message sent in both plain text and another format such as HTML * (multipart/alternative with the same content in text/plain and text/html forms)
application/x-www-form-urlencoded使用HTTP的POST方法提交的表单
multipart/form-data同上,但主要用于表单提交时伴随文件上传的场合
*
* * 此外,尚未被接受为正式数据类型的subtype,可以使用x-开始的独立名称(例如application/x-gzip).
* vnd-开始的固有名称也可以使用(例:application/vnd.ms-excel). * *

*
* * *

parameter可以用来指定附加的信息:

* *
*

* 更多情况下是用于指定text/plain和text/htm等的文字编码方式的charset参数.
* * MIME根据type制定了默认的subtype, 当客户端不能确定消息的subtype的情况下,消息被看作默认的subtype进行处理.
* * Text默认是text/plain,
* Application默认是application/octet-stream
* 而Multipart默认情况下被看作multipart/mixed.
*

*
* * @author feilong * @see com.feilong.io.entity.MimeType * @since 1.2.0 */ public final class MimeType{ /** {@value}. */ public static final String TEXT_ALL = "text/*"; /** {@value}. */ public static final String TEXT_HTML = com.feilong.io.entity.MimeType.HTML.getMime(); //--------------------------------------------------------------- /** {@value}. */ public static final String MULTIPART_ALL = "multipart/*"; /** HTML邮件的HTML形式和纯文本形式,相同内容使用不同形式表示 {@value}. */ public static final String MULTIPART_ALTERNATIVE = "multipart/alternative"; /** {@value}. */ public static final String MESSAGE_RFC822 = "message/rfc822"; /** * 日历数据交换的标准{@value}. * * @since 1.10.2 * @see iCalendar 编程基础:了解和使用 iCal4j * @see ICalendar * @see Internet Calendaring and Scheduling Core Object Specification * (iCalendar) * @see Internet Calendaring and Scheduling Core Object Specification(iCalendar) */ public static final String TYPE_ICS = "text/calendar;method=REQUEST;charset=\"UTF-8\""; //--------------------------------------------------------------- /** Don't let anyone instantiate this class. */ private MimeType(){ //AssertionError不是必须的. 但它可以避免不小心在类的内部调用构造器. 保证该类在任何情况下都不会被实例化. //see 《Effective Java》 2nd throw new AssertionError("No " + getClass().getName() + " instances for you!"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy