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 StringString value of media type: "application/atom+xml".static final MediaTypeapplication/x-www-form-urlencodedmedia type.static final StringString value of media type: "application/x-www-form-urlencoded".static final MediaTypeapplication/hoconmedia type.static final StringString value of media type: "application/hocon".static final MediaTypeapplication/javascriptmedia type.static final StringString value of media type: "application/javascript".static final MediaTypeapplication/jsonmedia type.static final MediaTypeapplication/json-patch+jsonmedia type.static final StringString value of media type: "application/json-patch+json".static final StringString value of media type: "application/json".static final MediaTypeapplication/octet-streammedia type.static final StringString value of media type: "application/octet-stream".static final MediaTypeapplication/vnd.oai.openapi+jsonmedia type.static final StringString value of media type: "application/vnd.oai.openapi+json".static final MediaTypeapplication/vnd.oai.openapimedia type.static final StringString value of media type: "application/vnd.oai.openapi".static final MediaTypeapplication/openmetrics-textmedia type.static final StringString value of media type: "application/openmetrics-text".static final MediaTypeapplication/stream+jsonmedia type.static final StringString value of media type: "application/stream+json".static final MediaTypeapplication/svg+xmlmedia type.static final StringString value of media type: "application/svg+xml".static final MediaTypeapplication/x-ndjsonmedia type.static final StringString value of media type: "application/x-ndjson".static final MediaTypeapplication/x-yamlmedia type.static final StringString value of media type: "application/x-yaml".static final MediaTypeapplication/xhtml+xmlmedia type.static final StringString value of media type: "application/xhtml+xml".static final MediaTypeapplication/xmlmedia type.static final StringString value of media type: "application/xml".static final MediaTypeapplication/yamlmedia type.static final StringString value of media type: "application/yaml".static final MediaTypemultipart/byte-rangesmedia type.static final StringString value of media type: "multipart/byteranges".static final MediaTypemultipart/form-datamedia type.static final StringString value of media type: "multipart/form-data".static final MediaTypetext/event-streammedia type.static final StringString value of media type: "text/event-stream".static final MediaTypetext/htmlmedia type.static final StringString value of media type: "text/html".static final MediaTypetet/plainmedia type.static final StringString value of media type: "text/plain".static final MediaTypetext/x-yamlmedia type.static final StringString value of media type: "text/x-yaml".static final MediaTypetext/xmlmedia type.static final StringString value of media type: "text/xml".static final MediaTypetext/yamlmedia type.static final StringString value of media type: "text/yaml".static final MediaTypeWildcard media type.static final StringString value of 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_JSON_PATCH_JSON
application/json-patch+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. -
WILDCARD_VALUE
String value of media type: "*/*".- See Also:
-
APPLICATION_XML_VALUE
String value of media type: "application/xml".- See Also:
-
APPLICATION_ATOM_XML_VALUE
String value of media type: "application/atom+xml".- See Also:
-
APPLICATION_XHTML_XML_VALUE
String value of media type: "application/xhtml+xml".- See Also:
-
APPLICATION_SVG_XML_VALUE
String value of media type: "application/svg+xml".- See Also:
-
APPLICATION_JSON_VALUE
String value of media type: "application/json".- See Also:
-
APPLICATION_JSON_PATCH_JSON_VALUE
String value of media type: "application/json-patch+json".- See Also:
-
APPLICATION_STREAM_JSON_VALUE
String value of media type: "application/stream+json".- See Also:
-
APPLICATION_FORM_URLENCODED_VALUE
String value of media type: "application/x-www-form-urlencoded".- See Also:
-
MULTIPART_FORM_DATA_VALUE
String value of media type: "multipart/form-data".- See Also:
-
MULTIPART_BYTERANGES_VALUE
String value of media type: "multipart/byteranges".- See Also:
-
APPLICATION_OCTET_STREAM_VALUE
String value of media type: "application/octet-stream".- See Also:
-
TEXT_PLAIN_VALUE
String value of media type: "text/plain".- See Also:
-
TEXT_XML_VALUE
String value of media type: "text/xml".- See Also:
-
TEXT_HTML_VALUE
String value of media type: "text/html".- See Also:
-
APPLICATION_OPENMETRICS_TEXT_VALUE
String value of media type: "application/openmetrics-text".- See Also:
-
APPLICATION_OPENAPI_YAML_VALUE
String value of media type: "application/vnd.oai.openapi".- See Also:
-
APPLICATION_OPENAPI_JSON_VALUE
String value of media type: "application/vnd.oai.openapi+json".- See Also:
-
APPLICATION_X_YAML_VALUE
String value of media type: "application/x-yaml".- See Also:
-
APPLICATION_YAML_VALUE
String value of media type: "application/yaml".- See Also:
-
TEXT_X_YAML_VALUE
String value of media type: "text/x-yaml".- See Also:
-
TEXT_YAML_VALUE
String value of media type: "text/yaml".- See Also:
-
APPLICATION_JAVASCRIPT_VALUE
String value of media type: "application/javascript".- See Also:
-
TEXT_EVENT_STREAM_VALUE
String value of media type: "text/event-stream".- See Also:
-
APPLICATION_X_NDJSON_VALUE
String value of media type: "application/x-ndjson".- See Also:
-
APPLICATION_HOCON_VALUE
String value of media type: "application/hocon".- See Also:
-
-
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
-