com.feilong.net.mail.util.MimeType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of feilong Show documentation
Show all versions of feilong Show documentation
feilong is a suite of core and expanded libraries that include utility classes, http, excel,cvs, io classes, and much much more.
/*
* 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/html
* HTML文档
*
*
* application/xhtml+xml
* XHTML文档
*
*
* image/gif
* GIF图像
*
*
* image/jpeg
* JPEG图像【PHP中为:image/pjpeg】
*
*
* image/png
* PNG图像【PHP中为:image/x-png】
*
*
* video/mpeg
* MPEG动画
*
*
* application/octet-stream
* 任意的二进制数据
*
*
* application/pdf
* PDF文档
*
*
* application/msword
* Microsoft Word文件
*
*
* application/vnd.wap.xhtml+xml
* wap1.0+
*
*
* application/xhtml+xml
* wap2.0+
*
*
* message/rfc822
* RFC 822形式
*
*
* multipart/alternative
* HTML邮件的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!");
}
}