类 MimeTypeUtils
java.lang.Object
cn.taketoday.util.MimeTypeUtils
Miscellaneous
MimeType utility methods.- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Dimitrios Liapis, Brian Clozel, Sam Brannen, TODAY
2019-12-08 19:24
-
字段概要
字段修饰符和类型字段说明static final MimeTypePublic constant mime type that includes all media ranges (i.estatic final StringA String equivalent ofALL.static final MimeTypePublic constant mime type forapplication/json.static final StringA String equivalent ofAPPLICATION_JSON.static final MimeTypePublic constant mime type forapplication/octet-stream.static final StringA String equivalent ofAPPLICATION_OCTET_STREAM.static final MimeTypePublic constant mime type forapplication/xml.static final StringA String equivalent ofAPPLICATION_XML.static final MimeTypePublic constant mime type forimage/gif.static final StringA String equivalent ofIMAGE_GIF.static final MimeTypePublic constant mime type forimage/jpeg.static final StringA String equivalent ofIMAGE_JPEG.static final MimeTypePublic constant mime type forimage/png.static final StringA String equivalent ofIMAGE_PNG.static final Comparator<MimeType>Comparator used bysortBySpecificity(List).static final MimeTypePublic constant mime type fortext/html.static final StringA String equivalent ofTEXT_HTML.static final MimeTypePublic constant mime type fortext/plain.static final StringA String equivalent ofTEXT_PLAIN.static final MimeTypePublic constant mime type fortext/xml.static final StringA String equivalent ofTEXT_XML. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static byte[]Generate a random MIME boundary as bytes, often used in multipart mime types.static StringGenerate a random MIME boundary as String, often used in multipart mime types.static MimeTypeparseMimeType(String mimeType) Parse the given String into a singleMimeType.parseMimeTypes(String mimeTypes) Parse the comma-separated string into a list ofMimeTypeobjects.static voidsortBySpecificity(List<? extends MimeType> mimeTypes) Sorts the given list ofMimeTypeobjects by specificity.Tokenize the given comma-separated string ofMimeTypeobjects into aList<String>.static StringtoString(Collection<? extends MimeType> mimeTypes) Return a string representation of the given list ofMimeTypeobjects.
-
字段详细资料
-
SPECIFICITY_COMPARATOR
Comparator used bysortBySpecificity(List). -
ALL
Public constant mime type that includes all media ranges (i.e. "*/*"). -
ALL_VALUE
A String equivalent ofALL.- 另请参阅:
-
APPLICATION_JSON
Public constant mime type forapplication/json. -
APPLICATION_JSON_VALUE
A String equivalent ofAPPLICATION_JSON.- 另请参阅:
-
APPLICATION_OCTET_STREAM
Public constant mime type forapplication/octet-stream. -
APPLICATION_OCTET_STREAM_VALUE
A String equivalent ofAPPLICATION_OCTET_STREAM.- 另请参阅:
-
APPLICATION_XML
Public constant mime type forapplication/xml. -
APPLICATION_XML_VALUE
A String equivalent ofAPPLICATION_XML.- 另请参阅:
-
IMAGE_GIF
Public constant mime type forimage/gif. -
IMAGE_GIF_VALUE
A String equivalent ofIMAGE_GIF.- 另请参阅:
-
IMAGE_JPEG
Public constant mime type forimage/jpeg. -
IMAGE_JPEG_VALUE
A String equivalent ofIMAGE_JPEG.- 另请参阅:
-
IMAGE_PNG
Public constant mime type forimage/png. -
IMAGE_PNG_VALUE
A String equivalent ofIMAGE_PNG.- 另请参阅:
-
TEXT_HTML
Public constant mime type fortext/html. -
TEXT_HTML_VALUE
A String equivalent ofTEXT_HTML.- 另请参阅:
-
TEXT_PLAIN
Public constant mime type fortext/plain. -
TEXT_PLAIN_VALUE
A String equivalent ofTEXT_PLAIN.- 另请参阅:
-
TEXT_XML
Public constant mime type fortext/xml. -
TEXT_XML_VALUE
A String equivalent ofTEXT_XML.- 另请参阅:
-
-
构造器详细资料
-
MimeTypeUtils
public MimeTypeUtils()
-
-
方法详细资料
-
parseMimeType
Parse the given String into a singleMimeType. Recently parsedMimeTypeare cached for further retrieval.- 参数:
mimeType- the string to parse- 返回:
- the mime type
- 抛出:
InvalidMimeTypeException- if the string cannot be parsed
-
parseMimeTypes
Parse the comma-separated string into a list ofMimeTypeobjects.- 参数:
mimeTypes- the string to parse- 返回:
- the list of mime types
- 抛出:
InvalidMimeTypeException- if the string cannot be parsed
-
tokenize
Tokenize the given comma-separated string ofMimeTypeobjects into aList<String>. Unlike simple tokenization by ",", this method takes into account quoted parameters.- 参数:
mimeTypes- the string to tokenize- 返回:
- the list of tokens
-
toString
Return a string representation of the given list ofMimeTypeobjects.- 参数:
mimeTypes- the string to parse- 返回:
- the list of mime types
- 抛出:
IllegalArgumentException- if the String cannot be parsed
-
sortBySpecificity
Sorts the given list ofMimeTypeobjects by specificity.Because of the computational cost, this method throws an exception when the given list contains too many elements.
- 参数:
mimeTypes- the list of mime types to be sorted- 抛出:
IllegalArgumentException- ifmimeTypescontains more than 50 elements- 另请参阅:
-
generateMultipartBoundary
public static byte[] generateMultipartBoundary()Generate a random MIME boundary as bytes, often used in multipart mime types. -
generateMultipartBoundaryString
Generate a random MIME boundary as String, often used in multipart mime types.
-