📄 mimetype.java
字号:
/*******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License. The
* Original Code is Compiere ERP & CRM Business Solution The Initial Developer
* of the Original Code is Jorg Janke and ComPiere, Inc. Portions created by
* Jorg Janke are Copyright (C) 1999-2005 Jorg Janke, parts created by ComPiere
* are Copyright (C) ComPiere, Inc.; All Rights Reserved. Contributor(s):
* ______________________________________.
******************************************************************************/
package org.compiere.util;
/**
* Mime - Content type map.
* http://www.iana.org/assignments/media-types/
*
* @author Jorg Janke
* @version $Id: MimeType.java,v 1.4 2005/10/08 02:03:38 jjanke Exp $
*/
public class MimeType
{
/**
* Get Mime Type of file name
* @param fileName file name
* @return mime type
*/
public static String getMimeType (String fileName)
{
if (fileName == null || fileName.indexOf('.') < 0)
return BINARY;
//
String extension = fileName.substring(fileName.lastIndexOf('.'));
for (int i = 0; i < TYPES.length; i++)
{
String[] type = TYPES[i];
if (type[0].equals(extension))
return type[1];
}
return "application/octet-stream";
} // getMimeType
/**
* Get Mime Type of file name
* @param fileName file name
* @return mime type
*/
public static MimeType get (String fileName)
{
if (fileName == null || fileName.indexOf('.') < 0)
return new MimeType (fileName, BINARY);
//
String extension = fileName.substring(fileName.lastIndexOf('.'));
for (int i = 0; i < TYPES.length; i++)
{
String[] type = TYPES[i];
if (type[0].equals(extension))
return new MimeType (fileName, type[1]);
}
return new MimeType (extension, BINARY);
} // get
/** application/octet-stream */
public static String BINARY = "application/octet-stream";
/**************************************************************************
* MimeType
* @param extension extension (with dot)
* @param mimeType mime type
*/
public MimeType (String extension, String mimeType)
{
setExtension(extension);
setMimeType(mimeType);
} // MimeType
/** Extension */
private String m_extension = null;
/** MIME Type */
private String m_mimeType = null;
/**
* @return Returns the extension.
*/
public String getExtension ()
{
return m_extension;
} // getExtension
/**
* @param extension The extension to set.
*/
public void setExtension (String extension)
{
m_extension = extension;
} // setExtension
/**
* @return Returns the Mime Type (Content Type).
*/
public String getMimeType ()
{
return m_mimeType;
} // getMimeType
/**
* @param mimeType The mimeType to set.
*/
public void setMimeType (String mimeType)
{
m_mimeType = mimeType;
} // setMimeType
/**
* String representation
* @return info
*/
public String toString ()
{
return m_mimeType + "(" + m_extension + ")";
} // toString
/**************************************************************************
* Mime / Content Type Map
*/
public static final String[][] TYPES = new String[][] {
{ ".3dm", "x-world/x-3dmf"},
{ ".3dmf", "x-world/x-3dmf"},
{ ".a", "application/octet-stream"},
{ ".aab", "application/x-authorware-bin"},
{ ".aam", "application/x-authorware-map"},
{ ".aas", "application/x-authorware-seg"},
{ ".abc", "text/vnd.abc"},
{ ".acgi", "text/html"},
{ ".afl", "video/animaflex"},
{ ".ai", "application/postscript"},
{ ".aif", "audio/aiff"},
// { ".aif", "audio/x-aiff"},
{ ".aifc", "audio/aiff"},
// { ".aifc", "audio/x-aiff"},
{ ".aiff", "audio/aiff"},
// { ".aiff", "audio/x-aiff"},
{ ".aim", "application/x-aim"},
{ ".aip", "text/x-audiosoft-intra"},
{ ".ani", "application/x-navi-animation"},
{ ".aos", "application/x-nokia-9000-communicator-add-on-software"},
{ ".aps", "application/mime"},
{ ".arc", "application/octet-stream"},
{ ".arj", "application/arj"},
// { ".arj", "application/octet-stream"},
{ ".art", "image/x-jg"},
{ ".asf", "video/x-ms-asf"},
{ ".asm", "text/x-asm"},
{ ".asp", "text/asp"},
{ ".asx", "application/x-mplayer2"},
{ ".asx", "video/x-ms-asf"},
// { ".asx", "video/x-ms-asf-plugin"},
{ ".au", "audio/basic"},
// { ".au", "audio/x-au"},
// { ".avi", "application/x-troff-msvideo"},
{ ".avi", "video/avi"},
// { ".avi", "video/msvideo"},
// { ".avi", "video/x-msvideo"},
// { ".avs", "video/avs-video"},
// b
{ ".bcpio", "application/x-bcpio"},
// { ".bin", "application/mac-binary"},
// { ".bin", "application/macbinary"},
// { ".bin", "application/octet-stream"},
{ ".bin", "application/x-binary"},
// { ".bin", "application/x-macbinary"},
{ ".bm", "image/bmp"},
{ ".bmp", "image/bmp"},
// { ".bmp", "image/x-windows-bmp"},
{ ".boo", "application/book"},
{ ".book", "application/book"},
{ ".boz", "application/x-bzip2"},
{ ".bsh", "application/x-bsh"},
{ ".bz", "application/x-bzip"},
{ ".bz2", "application/x-bzip2"},
{ ".c", "text/plain"},
{ ".c", "text/x-c"},
{ ".c++", "text/plain"},
{ ".cat", "application/vnd.ms-pki.seccat"},
{ ".cc", "text/plain"},
// { ".cc", "text/x-c"},
{ ".ccad", "application/clariscad"},
{ ".cco", "application/x-cocoa"},
{ ".cdf", "application/cdf"},
// { ".cdf", "application/x-cdf"},
// { ".cdf", "application/x-netcdf"},
{ ".cer", "application/pkix-cert"},
// { ".cer", "application/x-x509-ca-cert"},
{ ".cha", "application/x-chat"},
{ ".chat", "application/x-chat"},
// { ".class", "application/java"},
// { ".class", "application/x-java-applet"},
{ ".class", "application/x-java-vm "},
{ ".com", "application/octet-stream"},
// { ".com", "text/plain"},
{ ".conf", "text/plain"},
{ ".cpio", "application/x-cpio"},
{ ".cpp", "text/x-c"},
// { ".cpt", "application/mac-compactpro"},
// { ".cpt", "application/x-compactpro"},
{ ".cpt", "application/x-cpt"},
{ ".crl", "application/pkcs-crl"},
// { ".crl", "application/pkix-crl"},
{ ".crt", "application/pkix-cert"},
// { ".crt", "application/x-x509-ca-cert"},
// { ".crt", "application/x-x509-user-cert"},
// { ".csh", "application/x-csh"},
{ ".csh", "text/x-script.csh"},
// { ".css", "application/x-pointplus"},
{ ".css", "text/css"},
{ ".cvs", "application/vnd.ms-excel"},
{ ".cxx", "text/plain"},
{ ".dcr", "application/x-director"},
{ ".deepv", "application/x-deepv"},
{ ".def", "text/plain"},
{ ".der", "application/x-x509-ca-cert"},
{ ".dif", "video/x-dv"},
{ ".dir", "application/x-director"},
{ ".dl", "video/dl"},
// { ".dl", "video/x-dl"},
{ ".doc", "application/msword"},
{ ".dot", "application/msword"},
{ ".dp", "application/commonground"},
{ ".drw", "application/drafting"},
{ ".dump", "application/octet-stream"},
{ ".dv", "video/x-dv"},
{ ".dvi", "application/x-dvi"},
// { ".dwf", "drawing/x-dwf (old)"},
{ ".dwf", "model/vnd.dwf"},
// { ".dwg", "application/acad"},
{ ".dwg", "image/vnd.dwg"},
// { ".dwg", "image/x-dwg"},
// { ".dxf", "application/dxf"},
{ ".dxf", "image/vnd.dwg"},
// { ".dxf", "image/x-dwg"},
{ ".dxr", "application/x-director"},
{ ".el", "text/x-script.elisp"},
// { ".elc", "application/x-bytecode.elisp (Compiled ELisp)"},
{ ".elc", "application/x-elc"},
{ ".env", "application/x-envoy"},
{ ".eps", "application/postscript"},
{ ".es", "application/x-esrehber"},
{ ".etx", "text/x-setext"},
{ ".evy", "application/envoy"},
// { ".evy", "application/x-envoy"},
{ ".exe", "application/octet-stream"},
// { ".f", "text/plain"},
{ ".f", "text/x-fortran"},
{ ".f77", "text/x-fortran"},
// { ".f90", "text/plain"},
{ ".f90", "text/x-fortran"},
{ ".fdf", "application/vnd.fdf"},
// { ".fif", "application/fractals"},
{ ".fif", "image/fif"},
// { ".fli", "video/fli"},
{ ".fli", "video/x-fli"},
{ ".flo", "image/florian"},
{ ".flx", "text/vnd.fmi.flexstor"},
{ ".fmf", "video/x-atomic3d-feature"},
// { ".for", "text/plain"},
{ ".for", "text/x-fortran"},
{ ".fpx", "image/vnd.fpx"},
// { ".fpx", "image/vnd.net-fpx"},
{ ".frl", "application/freeloader"},
{ ".funk", "audio/make"},
{ ".g", "text/plain"},
{ ".g3", "image/g3fax"},
{ ".gif", "image/gif"},
{ ".gl", "video/gl"},
{ ".gl", "video/x-gl"},
{ ".gsd", "audio/x-gsm"},
{ ".gsm", "audio/x-gsm"},
{ ".gsp", "application/x-gsp"},
{ ".gss", "application/x-gss"},
{ ".gtar", "application/x-gtar"},
// { ".gz", "application/x-compressed"},
{ ".gz", "application/x-gzip"},
{ ".gzip", "application/x-gzip"},
// { ".gzip", "multipart/x-gzip"},
// { ".h", "text/plain"},
{ ".h", "text/x-h"},
{ ".hdf", "application/x-hdf"},
{ ".help", "application/x-helpfile"},
{ ".hgl", "application/vnd.hp-HPGL"},
// { ".hh", "text/plain"},
{ ".hh", "text/x-h"},
{ ".hlb", "text/x-script"},
{ ".hlp", "application/hlp"},
// { ".hlp", "application/x-helpfile"},
// { ".hlp", "application/x-winhelp"},
{ ".hpg", "application/vnd.hp-HPGL"},
{ ".hpgl", "application/vnd.hp-HPGL"},
{ ".hqx", "application/binhex"},
// { ".hqx", "application/binhex4"},
// { ".hqx", "application/mac-binhex"},
// { ".hqx", "application/mac-binhex40"},
// { ".hqx", "application/x-binhex40"},
// { ".hqx", "application/x-mac-binhex40"},
{ ".hta", "application/hta"},
{ ".htc", "text/x-component"},
{ ".htm", "text/html"},
{ ".html", "text/html"},
{ ".htmls", "text/html"},
{ ".htt", "text/webviewhtml"},
{ ".htx", "text/html"},
{ ".ice", "x-conference/x-cooltalk"},
{ ".ico", "image/x-icon"},
{ ".idc", "text/plain"},
{ ".ief", "image/ief"},
{ ".iefs", "image/ief"},
{ ".iges", "application/iges"},
// { ".iges", "model/iges"},
{ ".igs", "application/iges"},
// { ".igs", "model/iges"},
{ ".ima", "application/x-ima"},
{ ".imap", "application/x-httpd-imap"},
{ ".inf", "application/inf"},
{ ".ins", "application/x-internett-signup"},
{ ".ip", "application/x-ip2"},
{ ".isu", "video/x-isvideo"},
{ ".it", "audio/it"},
{ ".iv", "application/x-inventor"},
{ ".ivr", "i-world/i-vrml"},
{ ".ivy", "application/x-livescreen"},
{ ".jam", "audio/x-jam"},
// { ".jav", "text/plain"},
{ ".jav", "text/x-java-source"},
// { ".java", "text/plain"},
{ ".java", "text/x-java-source"},
{ ".jar", "application/java-archive"},
{ ".jcm", "application/x-java-commerce"},
{ ".jfif", "image/jpeg"},
// { ".jfif", "image/pjpeg"},
{ ".jfif-tbnl", "image/jpeg"},
{ ".jpe", "image/jpeg"},
// { ".jpe", "image/pjpeg"},
{ ".jpeg", "image/jpeg"},
// { ".jpeg", "image/pjpeg"},
{ ".jpg", "image/jpeg"},
// { ".jpg", "image/pjpeg"},
{ ".jps", "image/x-jps"},
{ ".js", "application/x-javascript"},
{ ".jut", "image/jutvision"},
{ ".kar", "audio/midi"},
{ ".kar", "music/x-karaoke"},
// { ".ksh", "application/x-ksh"},
{ ".ksh", "text/x-script.ksh"},
{ ".la", "audio/nspaudio"},
{ ".la", "audio/x-nspaudio"},
{ ".lam", "audio/x-liveaudio"},
{ ".latex", "application/x-latex"},
{ ".lha", "application/lha"},
// { ".lha", "application/x-lha"},
{ ".lhx", "application/octet-stream"},
{ ".list", "text/plain"},
{ ".lma", "audio/nspaudio"},
{ ".lma", "audio/x-nspaudio"},
{ ".log", "text/plain"},
{ ".lsp", "application/x-lisp"},
{ ".lsp", "text/x-script.lisp"},
{ ".lst", "text/plain"},
{ ".lsx", "text/x-la-asf"},
{ ".ltx", "application/x-latex"},
{ ".lzh", "application/octet-stream"},
{ ".lzh", "application/x-lzh"},
{ ".lzx", "application/lzx"},
{ ".lzx", "application/octet-stream"},
{ ".lzx", "application/x-lzx"},
{ ".m", "text/plain"},
{ ".m", "text/x-m"},
{ ".m1v", "video/mpeg"},
{ ".m2a", "audio/mpeg"},
{ ".m2v", "video/mpeg"},
{ ".m3u", "audio/x-mpequrl"},
{ ".man", "application/x-troff-man"},
{ ".map", "application/x-navimap"},
{ ".mar", "text/plain"},
{ ".mbd", "application/mbedlet"},
{ ".mc$", "application/x-magic-cap-package-1.0"},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -