java.lang.Object
io.jooby.MediaType
- All Implemented Interfaces:
Comparable<MediaType>
Implementation of media/content type.
- Since:
- 2.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MediaTypeALL.static final StringALL.static final MediaTypeTEXT_CSS.static final StringTEXT_CSS.static final MediaTypeFORM_URLENCODED.static final StringFORM_URLENCODED.static final MediaTypeTEXT_HTML.static final StringTEXT_HTML.static final MediaTypeAPPLICATION_JSON.static final StringAPPLICATION_JAVASCRIPT.static final MediaTypeAPPLICATION_JSON.static final StringAPPLICATION_JSON.static final BinaryOperator<MediaType>Computes and returns the most specific media type of both.static final MediaTypeMULTIPART_FORM_DATA.static final StringMULTIPART_FORM_DATA.static final StringAPPLICATION_OCTET_STREAM.static final MediaTypeAPPLICATION_OCTET_STREAM.static final MediaTypeTEXT_PLAIN.static final StringTEXT_PLAIN.static final MediaTypeAPPLICATION_XML.static final StringAPPLICATION_XML.static final MediaTypeYAML.static final StringYAML. -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaTypeMediatype by file extension.static MediaTypeMediatype by file extension.static MediaTypeMediatype by file extension.static MediaTypebyFileExtension(String ext) Mediatype by file extension.intbooleanCharset ornull.getParameter(String name) Get a parameter that matches the given name ornull.floatValue ofqparameter.Subtype segment of mediatype (trailing type).getType()Type segment of mediatype (leading type).getValue()Media type value without parameters.inthashCode()booleanisJson()Indicates whenever this is a json mediatype.booleanIndicates whenever this is a textual mediatype.booleanTrue if this mediatype is compatible with the given content type.booleanTrue if this mediatype is compatible with the given content type.Parse one or more mediatype values.toContentTypeHeader(Charset charset) Render a content type header and add the charset parameter (when present).toString()static MediaTypeParse a string value into a media-type.
-
Field Details
-
MOST_SPECIFIC
Computes and returns the most specific media type of both. -
JSON
APPLICATION_JSON.- See Also:
-
XML
APPLICATION_XML.- See Also:
-
TEXT
TEXT_PLAIN.- See Also:
-
HTML
TEXT_HTML.- See Also:
-
JS
APPLICATION_JAVASCRIPT.- See Also:
-
CSS
TEXT_CSS.- See Also:
-
OCTET_STREAM
APPLICATION_OCTET_STREAM.- See Also:
-
FORM_URLENCODED
FORM_URLENCODED.- See Also:
-
MULTIPART_FORMDATA
MULTIPART_FORM_DATA.- See Also:
-
YAML
YAML.- See Also:
-
ALL
ALL.- See Also:
-
json
APPLICATION_JSON. -
yaml
YAML. -
xml
APPLICATION_XML. -
text
TEXT_PLAIN. -
html
TEXT_HTML. -
js
APPLICATION_JSON. -
css
TEXT_CSS. -
octetStream
APPLICATION_OCTET_STREAM. -
form
FORM_URLENCODED. -
multipart
MULTIPART_FORM_DATA. -
all
ALL.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getParameter
Get a parameter that matches the given name ornull.- Parameters:
name- Parameter name.- Returns:
- Parameter value or
null.
-
getValue
Media type value without parameters.- Returns:
- Media type value.
-
toContentTypeHeader
Render a content type header and add the charset parameter (when present).- Parameters:
charset- Charset.- Returns:
- Content type header.
-
getQuality
@NonNull public float getQuality()Value ofqparameter.- Returns:
- Value of
qparameter.
-
compareTo
- Specified by:
compareToin interfaceComparable<MediaType>
-
isTextual
public boolean isTextual()Indicates whenever this is a textual mediatype.- Returns:
- True for textual mediatype.
-
isJson
public boolean isJson()Indicates whenever this is a json mediatype.- Returns:
- True for json mediatype.
-
getCharset
Charset ornull.- Returns:
- Charset or
null.
-
getType
Type segment of mediatype (leading type).- Returns:
- Type segment of mediatype (leading type).
-
getSubtype
Subtype segment of mediatype (trailing type).- Returns:
- Subtype segment of mediatype (trailing type).
-
matches
True if this mediatype is compatible with the given content type.- Parameters:
mediaType- Media type to test.- Returns:
- True if this mediatype is compatible with the given content type.
-
matches
True if this mediatype is compatible with the given content type.- Parameters:
type- Media type to test.- Returns:
- True if this mediatype is compatible with the given content type.
-
valueOf
Parse a string value into a media-type.- Parameters:
value- String media-type.- Returns:
- Media type.
-
parse
Parse one or more mediatype values. Mediatype must be separated by comma,.- Parameters:
value- Mediatype comma separated value.- Returns:
- One or more mediatypes.
-
byFile
Mediatype by file extension.- Parameters:
file- File.- Returns:
- Mediatype.
-
byFile
Mediatype by file extension.- Parameters:
file- File.- Returns:
- Mediatype.
-
byFile
Mediatype by file extension.- Parameters:
filename- File.- Returns:
- Mediatype.
-
byFileExtension
Mediatype by file extension.- Parameters:
ext- File extension.- Returns:
- Mediatype.
-
toString
-