java.lang.Object
io.helidon.common.media.type.MediaTypes
Media type detection based on a resource.
The media type detection uses the following algorithm:
- Queries
MediaTypeDetector
services in priority order - Checks all
META-INF/media-types.properties
files on classpath for a mapping (suffix=media type) - Checks built-in mapping provided by Helidon (with the usual the web relevant media types)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MediaType
application/atom+xml
media type.static final MediaType
application/x-www-form-urlencoded
media type.static final MediaType
application/hocon
media type.static final MediaType
application/javascript
media type.static final MediaType
application/json
media type.static final MediaType
application/octet-stream
media type.static final MediaType
application/vnd.oai.openapi+json
media type.static final MediaType
application/vnd.oai.openapi
media type.static final MediaType
application/openmetrics-text
media type.static final MediaType
application/stream+json
media type.static final MediaType
application/svg+xml
media type.static final MediaType
application/x-ndjson
media type.static final MediaType
application/x-yaml
media type.static final MediaType
application/xhtml+xml
media type.static final MediaType
application/xml
media type.static final MediaType
application/yaml
media type.static final MediaType
multipart/byte-ranges
media type.static final MediaType
multipart/form-data
media type.static final MediaType
text/event-stream
media type.static final MediaType
text/html
media type.static final MediaType
tet/plain
media type.static final MediaType
text/x-yaml
media type.static final MediaType
text/xml
media type.static final MediaType
text/yaml
media type.static final MediaType
Wildcard media type. -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaType
Create a new media type from the full media type string.static MediaType
create
(String fullType, ParserMode parserMode) Create a new media type from the full media type string.static MediaType
Create media type from the type and subtype.detectExtensionType
(String fileSuffix) Detecd media type for a specific file extension.detectType
(String fileName) Detect media type for a path (may be URL, URI, path on a file system).detectType
(URI uri) Detect media type based on URI.detectType
(URL url) Detect media type based on URL.detectType
(Path file) Detect media type for a file on file system.
-
Field Details
-
WILDCARD
Wildcard media type. -
APPLICATION_XML
application/xml
media type. -
APPLICATION_ATOM_XML
application/atom+xml
media type. -
APPLICATION_XHTML_XML
application/xhtml+xml
media type. -
APPLICATION_SVG_XML
application/svg+xml
media type. -
APPLICATION_JSON
application/json
media type. -
APPLICATION_STREAM_JSON
application/stream+json
media type. -
APPLICATION_FORM_URLENCODED
application/x-www-form-urlencoded
media type. -
MULTIPART_FORM_DATA
multipart/form-data
media type. -
MULTIPART_BYTERANGES
multipart/byte-ranges
media type. -
APPLICATION_OCTET_STREAM
application/octet-stream
media type. -
TEXT_PLAIN
tet/plain
media type. -
TEXT_XML
text/xml
media type. -
TEXT_HTML
text/html
media type. -
APPLICATION_OPENAPI_YAML
application/vnd.oai.openapi
media type. -
APPLICATION_OPENAPI_JSON
application/vnd.oai.openapi+json
media type. -
APPLICATION_OPENMETRICS_TEXT
application/openmetrics-text
media type. -
APPLICATION_X_YAML
application/x-yaml
media type. -
APPLICATION_YAML
application/yaml
media type. -
TEXT_X_YAML
text/x-yaml
media type. -
TEXT_YAML
text/yaml
media type. -
APPLICATION_JAVASCRIPT
application/javascript
media type. -
TEXT_EVENT_STREAM
text/event-stream
media type. -
APPLICATION_X_NDJSON
application/x-ndjson
media type. -
APPLICATION_HOCON
application/hocon
media type.
-
-
Method Details
-
create
Create media type from the type and subtype.- Parameters:
type
- typesubtype
- subtype- Returns:
- media type for the instance
-
create
Create a new media type from the full media type string. Strict media type parsing mode is used.- Parameters:
fullType
- media type string, such asapplication/json
- Returns:
- media type for the string
-
create
Create a new media type from the full media type string.- Parameters:
fullType
- media type string, such asapplication/json
parserMode
- media type parsing mode- Returns:
- media type for the string
-
detectType
Detect media type based on URL. As there may be an infinite number of urls used in a system, the results are NOT cached.- Parameters:
url
- to determine media type for- Returns:
- media type or empty if none found
-
detectType
Detect media type based on URI. Results may not be cached.- Parameters:
uri
- to determine media type for- Returns:
- media type or empty if none found
-
detectType
Detect media type for a file on file system. Results may not be cached.- Parameters:
file
- file on a file system- Returns:
- media type or empty if none found
-
detectType
Detect media type for a path (may be URL, URI, path on a file system). Results may not be cached. If you haveURL
,URI
, orPath
please use the other methods on this class.- Parameters:
fileName
- any string that has a file name as its last element- Returns:
- media type or empty if none found
- See Also:
-
detectExtensionType
Detecd media type for a specific file extension. Results are cached.- Parameters:
fileSuffix
- suffix of a file, such astxt
,properties
, orjpeg
. Without the leading dot.- Returns:
- media type for the file suffix or empty if none found
-