public class Mime
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
BIN
The MIME types commonly used for binary files and data.
|
static javax.servlet.ServletContext |
context
The helper servlet context.
|
static java.lang.String[] |
CSS
The MIME types commonly used for CSS files.
|
static java.lang.String[] |
GIF
The MIME types commonly used for GIF images.
|
static java.lang.String[] |
HTML
The MIME types commonly used for HTML files.
|
static java.lang.String[] |
ICO
The MIME types commonly used for ICO images.
|
static java.lang.String[] |
JPEG
The MIME types commonly used for JPEG images.
|
static java.lang.String[] |
JS
The MIME types commonly used for JavaScript files.
|
static java.lang.String[] |
JSON
The MIME types commonly used for JSON files and data.
|
static java.lang.String[] |
PNG
The MIME types commonly used for PNG images.
|
static java.lang.String[] |
SVG
The MIME types commonly used for SVG images.
|
static java.lang.String[] |
TEXT
The MIME types commonly used for text files.
|
static java.lang.String[] |
XML
The MIME types commonly used for XML files.
|
Constructor and Description |
---|
Mime() |
Modifier and Type | Method and Description |
---|---|
static boolean |
isInputMatch(Request request,
java.lang.String[] mimes)
Checks if the request input matches one of the specified MIME
types.
|
static boolean |
isMatch(java.lang.String contentType,
java.lang.String[] mimes)
Checks if a specified content type matches one of the specified
MIME types.
|
static boolean |
isOutputMatch(Request request,
java.lang.String[] mimes)
Checks if the accepted request output matches one of the
specified MIME types.
|
static java.lang.String |
type(java.io.File file)
Attempts to guess the MIME type for a file, based on the file
name (extension).
|
static java.lang.String |
type(java.lang.String fileName)
Attempts to guess the MIME type for a file name (extension).
|
public static final java.lang.String[] TEXT
public static final java.lang.String[] HTML
public static final java.lang.String[] CSS
public static final java.lang.String[] JS
public static final java.lang.String[] JSON
public static final java.lang.String[] XML
public static final java.lang.String[] GIF
public static final java.lang.String[] JPEG
public static final java.lang.String[] PNG
public static final java.lang.String[] SVG
public static final java.lang.String[] ICO
public static final java.lang.String[] BIN
public static javax.servlet.ServletContext context
public static java.lang.String type(java.io.File file)
file
- the file to checkpublic static java.lang.String type(java.lang.String fileName)
fileName
- the file name to checkpublic static boolean isMatch(java.lang.String contentType, java.lang.String[] mimes)
contentType
- the content type to analyzemimes
- the MIME types to check forpublic static boolean isInputMatch(Request request, java.lang.String[] mimes)
request
- the request to analyzemimes
- the MIME types to check forpublic static boolean isOutputMatch(Request request, java.lang.String[] mimes)
request
- the request to analyzemimes
- the MIME types to check for