Class MimeTypes

java.lang.Object
org.eclipse.jetty.http.MimeTypes
Direct Known Subclasses:
MimeTypes.Mutable

public class MimeTypes extends Object
MIME Type enum and utilities
  • Field Details

  • Constructor Details

    • MimeTypes

      public MimeTypes()
    • MimeTypes

      public MimeTypes(MimeTypes defaults)
  • Method Details

    • getBaseType

      public static MimeTypes.Type getBaseType(String contentType)
    • isKnownLocale

      public static boolean isKnownLocale(Locale locale)
    • normalizeCharset

      public static String normalizeCharset(String charsetName)
      Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).
      Parameters:
      charsetName - the charset to normalize
      Returns:
      the normalized charset (or null if normalized version not found)
    • normalizeCharset

      public static String normalizeCharset(String charsetName, int offset, int length)
      Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).
      Parameters:
      charsetName - the charset to normalize
      offset - the offset in the charset
      length - the length of the charset in the input param
      Returns:
      the normalized charset (or null if not found)
    • getKnownCharset

      public static Charset getKnownCharset(String charsetName) throws UnsupportedEncodingException
      Parameters:
      charsetName - The name of the charset
      Returns:
      The Charset for the normalized name
      Throws:
      UnsupportedEncodingException - Thrown if the charset is not known to the JVM.
    • getCharset

      Get the explicit, assumed, or inferred Charset for a mime type
      Parameters:
      mimeType - String form or a mimeType
      Returns:
      A Charset or null;
      Throws:
      IllegalCharsetNameException - If the given charset name is illegal
      UnsupportedCharsetException - If no support for the named charset is available in this instance of the Java virtual machine
    • getMimeByExtension

      public String getMimeByExtension(String filename)
      Get the MIME type by filename extension.
      Parameters:
      filename - A file name
      Returns:
      MIME type matching the last dot extension of the file name, or matching "*" if none found.
    • getMimeForExtension

      public String getMimeForExtension(String extension)
    • getInferredCharset

      public Charset getInferredCharset(String contentType)
    • getAssumedCharset

      public Charset getAssumedCharset(String contentType)
    • getCharsetInferredFromContentType

      public String getCharsetInferredFromContentType(String contentType)
    • getCharsetAssumedFromContentType

      public String getCharsetAssumedFromContentType(String contentType)
    • getMimeMap

      public Map<String,String> getMimeMap()
    • getInferredMap

      public Map<String,String> getInferredMap()
    • getAssumedMap

      public Map<String,String> getAssumedMap()
    • getCharsetFromContentType

      public static String getCharsetFromContentType(String value)
    • getContentTypeWithoutCharset

      public static String getContentTypeWithoutCharset(String value)