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
MediaTypeDetectorservices in priority order - Checks all
META-INF/media-types.propertiesfiles 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
FieldsModifier and TypeFieldDescriptionstatic final MediaTypeapplication/atom+xmlmedia type.static final MediaTypeapplication/x-www-form-urlencodedmedia type.static final MediaTypeapplication/hoconmedia type.static final MediaTypeapplication/javascriptmedia type.static final MediaTypeapplication/jsonmedia type.static final MediaTypeapplication/octet-streammedia type.static final MediaTypeapplication/vnd.oai.openapi+jsonmedia type.static final MediaTypeapplication/vnd.oai.openapimedia type.static final MediaTypeapplication/openmetrics-textmedia type.static final MediaTypeapplication/stream+jsonmedia type.static final MediaTypeapplication/svg+xmlmedia type.static final MediaTypeapplication/x-ndjsonmedia type.static final MediaTypeapplication/x-yamlmedia type.static final MediaTypeapplication/xhtml+xmlmedia type.static final MediaTypeapplication/xmlmedia type.static final MediaTypeapplication/yamlmedia type.static final MediaTypemultipart/byte-rangesmedia type.static final MediaTypemultipart/form-datamedia type.static final MediaTypetext/event-streammedia type.static final MediaTypetext/htmlmedia type.static final MediaTypetet/plainmedia type.static final MediaTypetext/x-yamlmedia type.static final MediaTypetext/xmlmedia type.static final MediaTypetext/yamlmedia type.static final MediaTypeWildcard media type. -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaTypeCreate a new media type from the full media type string.static MediaTypecreate(String fullType, ParserMode parserMode) Create a new media type from the full media type string.static MediaTypeCreate 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/xmlmedia type. -
APPLICATION_ATOM_XML
application/atom+xmlmedia type. -
APPLICATION_XHTML_XML
application/xhtml+xmlmedia type. -
APPLICATION_SVG_XML
application/svg+xmlmedia type. -
APPLICATION_JSON
application/jsonmedia type. -
APPLICATION_STREAM_JSON
application/stream+jsonmedia type. -
APPLICATION_FORM_URLENCODED
application/x-www-form-urlencodedmedia type. -
MULTIPART_FORM_DATA
multipart/form-datamedia type. -
MULTIPART_BYTERANGES
multipart/byte-rangesmedia type. -
APPLICATION_OCTET_STREAM
application/octet-streammedia type. -
TEXT_PLAIN
tet/plainmedia type. -
TEXT_XML
text/xmlmedia type. -
TEXT_HTML
text/htmlmedia type. -
APPLICATION_OPENAPI_YAML
application/vnd.oai.openapimedia type. -
APPLICATION_OPENAPI_JSON
application/vnd.oai.openapi+jsonmedia type. -
APPLICATION_OPENMETRICS_TEXT
application/openmetrics-textmedia type. -
APPLICATION_X_YAML
application/x-yamlmedia type. -
APPLICATION_YAML
application/yamlmedia type. -
TEXT_X_YAML
text/x-yamlmedia type. -
TEXT_YAML
text/yamlmedia type. -
APPLICATION_JAVASCRIPT
application/javascriptmedia type. -
TEXT_EVENT_STREAM
text/event-streammedia type. -
APPLICATION_X_NDJSON
application/x-ndjsonmedia type. -
APPLICATION_HOCON
application/hoconmedia 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/jsonparserMode- 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, orPathplease 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
-