public class ResourceType extends Object
Used by the ResourceHandler
to specify a mapping between file name extensions and mime types, and whether they should be gzipped or not.
A number of common mappings are provided by default. To specify your custom settings, use ResourceHandlerBuilder.withExtensionToResourceType(Map)
Modifier and Type | Field and Description |
---|---|
static ResourceType |
APPLICATION_EPUB_ZIP
application/epub-zip |
static ResourceType |
APPLICATION_GZIP
application/gzip |
static ResourceType |
APPLICATION_JAVA_ARCHIVE
application/java-archive |
static ResourceType |
APPLICATION_JAVASCRIPT
application/javascript |
static ResourceType |
APPLICATION_JSON
application/json |
static ResourceType |
APPLICATION_MSWORD
application/msword |
static ResourceType |
APPLICATION_OCTET_STREAM
application/octet-stream |
static ResourceType |
APPLICATION_OGG
application/ogg |
static ResourceType |
APPLICATION_PDF
application/pdf |
static ResourceType |
APPLICATION_RTF
application/rtf |
static ResourceType |
APPLICATION_TYPESCRIPT
application/typescript |
static ResourceType |
APPLICATION_VND_AMAZON_EBOOK
application/vnd-amazon-ebook |
static ResourceType |
APPLICATION_VND_APPLE_INSTALLER_XML
application/vnd-apple-installer-xml |
static ResourceType |
APPLICATION_VND_MOZILLA_XUL_XML
application/vnd-mozilla-xul-xml |
static ResourceType |
APPLICATION_VND_MS_EXCEL
application/vnd-ms-excel |
static ResourceType |
APPLICATION_VND_MS_FONTOBJECT
application/vnd-ms-fontobject |
static ResourceType |
APPLICATION_VND_MS_POWERPOINT
application/vnd-ms-powerpoint |
static ResourceType |
APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION
application/vnd-oasis-opendocument-presentation |
static ResourceType |
APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET
application/vnd-oasis-opendocument-spreadsheet |
static ResourceType |
APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT
application/vnd-oasis-opendocument-text |
static ResourceType |
APPLICATION_VND_VISIO
application/vnd-visio |
static ResourceType |
APPLICATION_X_7Z_COMPRESSED
application/x-7z-compressed |
static ResourceType |
APPLICATION_X_ABIWORD
application/x-abiword |
static ResourceType |
APPLICATION_X_BZIP
application/x-bzip |
static ResourceType |
APPLICATION_X_BZIP2
application/x-bzip2 |
static ResourceType |
APPLICATION_X_CSH
application/x-csh |
static ResourceType |
APPLICATION_X_RAR_COMPRESSED
application/x-rar-compressed |
static ResourceType |
APPLICATION_X_SH
application/x-sh |
static ResourceType |
APPLICATION_X_SHOCKWAVE_FLASH
application/x-shockwave-flash |
static ResourceType |
APPLICATION_X_TAR
application/x-tar |
static ResourceType |
APPLICATION_XHTML_XML
application/xhtml-xml |
static ResourceType |
APPLICATION_XML
application/xml |
static ResourceType |
APPLICATION_ZIP
application/zip |
static ResourceType |
AUDIO_AAC
audio/aac |
static ResourceType |
AUDIO_MIDI
audio/midi |
static ResourceType |
AUDIO_OGG
audio/ogg |
static ResourceType |
AUDIO_WEBM
audio/webm |
static ResourceType |
AUDIO_X_WAV
audio/x-wav |
static ResourceType |
DEFAULT
The resource type used when no others match.
|
static Map<String,ResourceType> |
DEFAULT_EXTENSION_MAPPINGS
The mapping of file extensions (such as "jpg") to resource types (such as
IMAGE_JPEG that mu-server uses by default when serving static content. |
List<String> |
extensions
Deprecated.
use
extensions() instead |
static ResourceType |
FONT_OTF
font/otf |
static ResourceType |
FONT_TTF
font/ttf |
static ResourceType |
FONT_WOFF
font/woff |
static ResourceType |
FONT_WOFF2
font/woff2 |
boolean |
gzip
Deprecated.
use
gzip() instead |
Headers |
headers
Deprecated.
use
headers() instead |
static ResourceType |
IMAGE_AVIF
image/avif |
static ResourceType |
IMAGE_GIF
image/gif |
static ResourceType |
IMAGE_JPEG
image/jpeg |
static ResourceType |
IMAGE_PNG
image/png |
static ResourceType |
IMAGE_SVG_XML
image/svg-xml |
static ResourceType |
IMAGE_TIFF
image/tiff |
static ResourceType |
IMAGE_WEBP
image/webp |
static ResourceType |
IMAGE_X_ICON
image/x-icon |
CharSequence |
mimeType
Deprecated.
use
mimeType() instead |
static ResourceType |
TEXT_CALENDAR
text/calendar;charset=utf-8 |
static ResourceType |
TEXT_CSS
text/css |
static ResourceType |
TEXT_CSV
text/csv;charset=utf-8 |
static ResourceType |
TEXT_HTML
text/html;charset=utf-8 |
static ResourceType |
TEXT_JAVASCRIPT
Deprecated.
use
APPLICATION_JAVASCRIPT instead |
static ResourceType |
TEXT_MARKDOWN
text/markdown;charset=utf-8 |
static ResourceType |
TEXT_PLAIN
text/plain;charset=utf-8 |
static ResourceType |
VIDEO_3GPP
video/3gpp |
static ResourceType |
VIDEO_3GPP2
video/3gpp2 |
static ResourceType |
VIDEO_MPEG
video/mpeg |
static ResourceType |
VIDEO_OGG
video/ogg |
static ResourceType |
VIDEO_WEBM
video/webm |
static ResourceType |
VIDEO_X_MATROSKA
video/x-matroska |
static ResourceType |
VIDEO_X_MSVIDEO
video/x-msvideo |
static ResourceType |
WEB_APP_MANIFEST
web/app-manifest |
Constructor and Description |
---|
ResourceType(CharSequence mimeType,
Headers headers,
boolean gzip,
List<String> extensions)
Creates a new resource type.
|
Modifier and Type | Method and Description |
---|---|
List<String> |
extensions() |
static HashMap<String,ResourceType> |
getDefaultMapping()
Can be used as a base to customise mime types via
ResourceHandlerBuilder.withExtensionToResourceType(Map) |
static List<ResourceType> |
getResourceTypes() |
boolean |
gzip() |
static Set<String> |
gzippableMimeTypes(Collection<ResourceType> resourceTypes)
Given a list of resources, returns the ones that are gzippable
|
Headers |
headers() |
CharSequence |
mimeType() |
static Headers |
noCache() |
static Headers |
shortCache() |
String |
toString() |
public static final Map<String,ResourceType> DEFAULT_EXTENSION_MAPPINGS
IMAGE_JPEG
that mu-server uses by default when serving static content.@Deprecated public final CharSequence mimeType
mimeType()
instead@Deprecated public final Headers headers
headers()
instead@Deprecated public final List<String> extensions
extensions()
instead@Deprecated public final boolean gzip
gzip()
insteadpublic static final ResourceType DEFAULT
ContentTypes.APPLICATION_OCTET_STREAM
is used.public static final ResourceType AUDIO_AAC
audio/aac
public static final ResourceType APPLICATION_X_ABIWORD
application/x-abiword
public static final ResourceType VIDEO_X_MSVIDEO
video/x-msvideo
public static final ResourceType APPLICATION_VND_AMAZON_EBOOK
application/vnd-amazon-ebook
public static final ResourceType APPLICATION_OCTET_STREAM
application/octet-stream
public static final ResourceType APPLICATION_X_BZIP
application/x-bzip
public static final ResourceType APPLICATION_X_BZIP2
application/x-bzip2
public static final ResourceType APPLICATION_X_CSH
application/x-csh
public static final ResourceType TEXT_CSS
text/css
public static final ResourceType TEXT_PLAIN
text/plain;charset=utf-8
public static final ResourceType TEXT_MARKDOWN
text/markdown;charset=utf-8
public static final ResourceType TEXT_CSV
text/csv;charset=utf-8
public static final ResourceType APPLICATION_MSWORD
application/msword
public static final ResourceType APPLICATION_VND_MS_FONTOBJECT
application/vnd-ms-fontobject
public static final ResourceType APPLICATION_EPUB_ZIP
application/epub-zip
public static final ResourceType APPLICATION_GZIP
application/gzip
public static final ResourceType IMAGE_GIF
image/gif
public static final ResourceType TEXT_HTML
text/html;charset=utf-8
public static final ResourceType IMAGE_X_ICON
image/x-icon
public static final ResourceType TEXT_CALENDAR
text/calendar;charset=utf-8
public static final ResourceType APPLICATION_JAVA_ARCHIVE
application/java-archive
public static final ResourceType IMAGE_JPEG
image/jpeg
@Deprecated public static final ResourceType TEXT_JAVASCRIPT
APPLICATION_JAVASCRIPT
insteadpublic static final ResourceType APPLICATION_JAVASCRIPT
application/javascript
public static final ResourceType APPLICATION_JSON
application/json
public static final ResourceType WEB_APP_MANIFEST
web/app-manifest
public static final ResourceType AUDIO_MIDI
audio/midi
public static final ResourceType VIDEO_MPEG
video/mpeg
public static final ResourceType APPLICATION_VND_APPLE_INSTALLER_XML
application/vnd-apple-installer-xml
public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_PRESENTATION
application/vnd-oasis-opendocument-presentation
public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET
application/vnd-oasis-opendocument-spreadsheet
public static final ResourceType APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT
application/vnd-oasis-opendocument-text
public static final ResourceType AUDIO_OGG
audio/ogg
public static final ResourceType VIDEO_X_MATROSKA
video/x-matroska
public static final ResourceType VIDEO_OGG
video/ogg
public static final ResourceType APPLICATION_OGG
application/ogg
public static final ResourceType FONT_OTF
font/otf
public static final ResourceType IMAGE_PNG
image/png
public static final ResourceType APPLICATION_PDF
application/pdf
public static final ResourceType APPLICATION_VND_MS_POWERPOINT
application/vnd-ms-powerpoint
public static final ResourceType APPLICATION_X_RAR_COMPRESSED
application/x-rar-compressed
public static final ResourceType APPLICATION_RTF
application/rtf
public static final ResourceType APPLICATION_X_SH
application/x-sh
public static final ResourceType IMAGE_SVG_XML
image/svg-xml
public static final ResourceType APPLICATION_X_SHOCKWAVE_FLASH
application/x-shockwave-flash
public static final ResourceType APPLICATION_X_TAR
application/x-tar
public static final ResourceType IMAGE_TIFF
image/tiff
public static final ResourceType APPLICATION_TYPESCRIPT
application/typescript
public static final ResourceType FONT_TTF
font/ttf
public static final ResourceType APPLICATION_VND_VISIO
application/vnd-visio
public static final ResourceType AUDIO_X_WAV
audio/x-wav
public static final ResourceType AUDIO_WEBM
audio/webm
public static final ResourceType VIDEO_WEBM
video/webm
public static final ResourceType IMAGE_AVIF
image/avif
public static final ResourceType IMAGE_WEBP
image/webp
public static final ResourceType FONT_WOFF
font/woff
public static final ResourceType FONT_WOFF2
font/woff2
public static final ResourceType APPLICATION_XHTML_XML
application/xhtml-xml
public static final ResourceType APPLICATION_VND_MS_EXCEL
application/vnd-ms-excel
public static final ResourceType APPLICATION_XML
application/xml
public static final ResourceType APPLICATION_VND_MOZILLA_XUL_XML
application/vnd-mozilla-xul-xml
public static final ResourceType APPLICATION_ZIP
application/zip
public static final ResourceType VIDEO_3GPP
video/3gpp
public static final ResourceType VIDEO_3GPP2
video/3gpp2
public static final ResourceType APPLICATION_X_7Z_COMPRESSED
application/x-7z-compressed
public ResourceType(CharSequence mimeType, Headers headers, boolean gzip, List<String> extensions)
DEFAULT_EXTENSION_MAPPINGS
mimeType
- The mime typeheaders
- The headers to respond withgzip
- Whether or not to gzip when servingextensions
- The file extensions for this resourcepublic CharSequence mimeType()
image/jpeg
public Headers headers()
public List<String> extensions()
jpg
and jpeg
public boolean gzip()
public static Headers shortCache()
public static Headers noCache()
public static HashMap<String,ResourceType> getDefaultMapping()
ResourceHandlerBuilder.withExtensionToResourceType(Map)
public static Set<String> gzippableMimeTypes(Collection<ResourceType> resourceTypes)
resourceTypes
- Types to checkgzip()
returning true
public static List<ResourceType> getResourceTypes()
Copyright © 2017–2021. All rights reserved.