Class MimeTypes
java.lang.Object
org.eclipse.jetty.http.MimeTypes
- Direct Known Subclasses:
 MimeTypes.Mutable
MIME Type enum and utilities
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumEnumeration of predefined MimeTypes. - 
Field Summary
Fields - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptiongetAssumedCharset(String contentType) getAssumedCharsetName(String contentType) static StringGet the base value, stripped of any parametersstatic MimeTypes.TypegetBaseType(String contentType) Get the base type of this type, which is the type without a charset specifiedgetCharset(String mimeType) Get the explicit, assumed, or inferred Charset for a mime typegetCharset(HttpField field) Get the explicit, assumed, or inferred Charset for a HttpField containing a mime type valuestatic StringgetCharsetFromContentType(String value) Efficiently extract the charset value from aContent-Typestringstatic CharsetEfficiently extract the charset value from aContent-TypeHttpField.static StringEfficiently extract the base mime-type from a content-type valuegetInferredCharset(String contentType) getInferredCharsetName(String contentType) static CharsetgetKnownCharset(String charsetName) getMimeByExtension(String filename) Get the MIME type by filename extension.getMimeForExtension(String extension) static Stringstatic MimeTypes.TypebooleanisCharsetAssumed(String contentType) static booleanisKnownLocale(Locale locale) protected voidloadEncodings(InputStream stream, String resourceName) protected voidloadMimeProperties(InputStream stream, String resourceName) static StringnormalizeCharset(String charsetName) Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).static StringnormalizeCharset(String charsetName, int offset, int length) Convert alternate charset names (eg utf8) to normalized name (eg UTF-8). 
- 
Field Details
- 
ISO_8859_1
 - 
UTF8
 - 
UTF16
 - 
CACHE
 - 
_mimeMap
 - 
_inferredEncodings
 - 
_assumedEncodings
 - 
_assumedNoEncodings
 - 
DEFAULTS
 
 - 
 - 
Constructor Details
- 
MimeTypes
public MimeTypes() - 
MimeTypes
 
 - 
 - 
Method Details
- 
getBase
 - 
getBaseType
Get the base type of this type, which is the type without a charset specified- Parameters:
 contentType- The mimetype as a string- Returns:
 - The base type or this type if it is a base type
 
 - 
isKnownLocale
 - 
normalizeCharset
 - 
normalizeCharset
Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).- Parameters:
 charsetName- the charset to normalizeoffset- the offset in the charsetlength- the length of the charset in the input param- Returns:
 - the normalized charset (or null if not found)
 
 - 
getKnownCharset
- Parameters:
 charsetName- The name of the charset- Returns:
 - The 
Charsetfor the normalized name - Throws:
 UnsupportedEncodingException- Thrown if the charset is not known to the JVM.
 - 
loadMimeProperties
- Throws:
 IOException
 - 
loadEncodings
- Throws:
 IOException
 - 
getCharset
public Charset getCharset(HttpField field) throws IllegalCharsetNameException, UnsupportedCharsetException Get the explicit, assumed, or inferred Charset for a HttpField containing a mime type value- Parameters:
 field- HttpField with a mime type value (e.g. Content-Type)- Returns:
 - A 
Charsetor null; - Throws:
 IllegalCharsetNameException- If the given charset name is illegalUnsupportedCharsetException- If no support for the named charset is available in this instance of the Java virtual machine
 - 
getCharset
public Charset getCharset(String mimeType) throws IllegalCharsetNameException, UnsupportedCharsetException Get the explicit, assumed, or inferred Charset for a mime type- Parameters:
 mimeType- String form or a mimeType- Returns:
 - A 
Charsetor null; - Throws:
 IllegalCharsetNameException- If the given charset name is illegalUnsupportedCharsetException- If no support for the named charset is available in this instance of the Java virtual machine
 - 
getMimeByExtension
 - 
getMimeForExtension
 - 
getInferredCharset
- Parameters:
 contentType- The content type to obtain a charset for.- Returns:
 - A Charset is returned if it can be inferred from content-type. This is essentially a default charset determined for the contentType. For example, the content-type "text/html" may be configured to have an inferred charset of "utf-8", in which case setting that content-type should result in a value of "text/html;charset=utf8".
 - See Also:
 
 - 
getAssumedCharset
- Parameters:
 contentType- The content type to obtain a charset for.- Returns:
 - A Charset is returned if it can be assumed from content-type.  This is essentially a known charset
        for the specific contentType.  For example, the content-type "application/json" is specified to use utf-8, 
        so it has an assumed charset of "utf-8". As this is universally known, there is no need to modify the 
        the content-type which will just have a value of "application/json".   Note that some content-types may be
        assumed to have no charset, in which case 
isCharsetAssumed(String)must be used. - See Also:
 
 - 
isCharsetAssumed
- Parameters:
 contentType- The content-type to obtain a charset for- Returns:
 Trueif the content-type is assumed to have a specific charset (include assumed to have no charset. For example "application/json" is assumed as it has a specified charset of "utf-8". Another example is "image/jpeg", which is assumed to have no charset, so it would also return true.
 - 
getInferredCharsetName
- Parameters:
 contentType- The content type to obtain a charset for.- Returns:
 - The string value of 
getInferredCharset(String) - See Also:
 
 - 
getAssumedCharsetName
- Parameters:
 contentType- The content type to obtain a charset for.- Returns:
 - The string value of 
getAssumedCharset(String); or the empty string if the type is assumed to not have a charset; ornullof the type has no assumed charset. - See Also:
 
 - 
getMimeMap
 - 
getMimeTypeFromContentType
 - 
getMimeTypeAsStringFromContentType
 - 
getCharsetFromContentType
 - 
getCharsetFromContentType
 - 
getContentTypeWithoutCharset
 
 -