- All Implemented Interfaces:
AcceptPredicate<MediaType>,Predicate<MediaType>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent API builder to create instances ofMediaType. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MediaTypeAMediaTypeconstant representingapplication/atom+xmlmedia type.static final MediaTypeAMediaTypeconstant representingapplication/x-www-form-urlencodedmedia type.static final MediaTypeAMediaTypeconstant representingapplication/javascriptmedia type.static final MediaTypeAMediaTypeconstant representingapplication/jsonmedia type.static final MediaTypeAMediaTypeconstant representingapplication/octet-streammedia type.static final MediaTypeAMediaTypeconstant representing OpenAPI json.static final MediaTypeAMediaTypeconstant representing OpenAPI yaml.static final MediaTypeAMediaTypeconstant representing theapplication/openmetrics-textmedia type.static final MediaTypeAMediaTypeconstant representingapplication/stream+jsonmedia type.static final MediaTypeAMediaTypeconstant representingapplication/svg+xmlmedia type.static final MediaTypeAMediaTypeconstant representingapplication/x-ndjsonmedia type.static final MediaTypeAMediaTypeconstant representing "x" YAML as application.static final MediaTypeAMediaTypeconstant representingapplication/xhtml+xmlmedia type.static final MediaTypeAMediaTypeconstant representingapplication/xmlmedia type.static final MediaTypeAMediaTypeconstant representing pseudo-registered YAML.static final StringThe media type "charset" parameter name.Predicate to test ifMediaTypeistext/event-streamwithout any parameter or with parameter "element-type".static final MediaTypeAMediaTypeconstant representingmultipart/form-datamedia type.static final MediaTypeAMediaTypeconstant representingtext/event-streammedia type.static final MediaTypeAMediaTypeconstant representingtext/htmlmedia type.static final MediaTypeAMediaTypeconstant representingtext/plainmedia type.static final MediaTypeAMediaTypeconstant representing "x" YAML as text.static final MediaTypeAMediaTypeconstant representingtext/xmlmedia type.static final MediaTypeAMediaTypeconstant representing pseudo-registered YAML as text.static final MediaTypeAMediaTypeconstant representing wildcard media type.Fields inherited from interface io.helidon.common.http.AcceptPredicate
QUALITY_FACTOR_PARAMETER, WILDCARD_VALUE -
Method Summary
Modifier and TypeMethodDescriptionstatic MediaType.Builderbuilder()A fluent API builder for creating customized Media type instances.charset()GetsOptionalvalue of charset parameter.static MediaTypeCreates a new instance ofMediaTypewith the supplied type and subtype.booleanComparesobjto this media type to see if they are the same by comparing type, subtype and parameters.inthashCode()Generate a hash code from the type, subtype and parameters.booleanTests if this media type has provided Structured Syntaxsuffix(RFC 6839).booleanChecks if the subtype is a wildcard.booleanChecks if the primary type is a wildcard.Getter for a read-only parameter map.static MediaTypeParses a media type from its string representation.doubleGets quality factor parameter ("q") as a double value.subtype()Getter for subtype.booleanCheck if this media type is compatible with another media type.toString()Convert the media type to a string suitable for use as the value of a corresponding HTTP header.type()Getter for primary type.withCharset(String charset) Create a newMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter.Deprecated, for removal: This API element is subject to removal in a future version.will be removed in 4.x version.
-
Field Details
-
CHARSET_PARAMETER
The media type "charset" parameter name.- See Also:
-
WILDCARD
AMediaTypeconstant representing wildcard media type. -
APPLICATION_XML
AMediaTypeconstant representingapplication/xmlmedia type. -
APPLICATION_ATOM_XML
AMediaTypeconstant representingapplication/atom+xmlmedia type. -
APPLICATION_XHTML_XML
AMediaTypeconstant representingapplication/xhtml+xmlmedia type. -
APPLICATION_SVG_XML
AMediaTypeconstant representingapplication/svg+xmlmedia type. -
APPLICATION_JSON
AMediaTypeconstant representingapplication/jsonmedia type. -
APPLICATION_STREAM_JSON
AMediaTypeconstant representingapplication/stream+jsonmedia type. -
APPLICATION_FORM_URLENCODED
AMediaTypeconstant representingapplication/x-www-form-urlencodedmedia type. -
MULTIPART_FORM_DATA
AMediaTypeconstant representingmultipart/form-datamedia type. -
APPLICATION_OCTET_STREAM
AMediaTypeconstant representingapplication/octet-streammedia type. -
TEXT_PLAIN
AMediaTypeconstant representingtext/plainmedia type. -
TEXT_XML
AMediaTypeconstant representingtext/xmlmedia type. -
TEXT_HTML
AMediaTypeconstant representingtext/htmlmedia type. -
APPLICATION_OPENAPI_YAML
AMediaTypeconstant representing OpenAPI yaml.See https://github.com/opengeospatial/WFS_FES/issues/117#issuecomment-402188280
-
APPLICATION_OPENAPI_JSON
AMediaTypeconstant representing OpenAPI json. -
APPLICATION_X_YAML
AMediaTypeconstant representing "x" YAML as application. -
APPLICATION_YAML
AMediaTypeconstant representing pseudo-registered YAML. (It is not actually registered.) -
TEXT_X_YAML
AMediaTypeconstant representing "x" YAML as text. -
TEXT_YAML
AMediaTypeconstant representing pseudo-registered YAML as text. -
APPLICATION_JAVASCRIPT
AMediaTypeconstant representingapplication/javascriptmedia type. -
TEXT_EVENT_STREAM
AMediaTypeconstant representingtext/event-streammedia type. -
APPLICATION_X_NDJSON
AMediaTypeconstant representingapplication/x-ndjsonmedia type. -
APPLICATION_OPENMETRICS
AMediaTypeconstant representing theapplication/openmetrics-textmedia type. -
XML_PREDICATE
-
JSON_PREDICATE
-
JSON_EVENT_STREAM_PREDICATE
Predicate to test ifMediaTypeistext/event-streamwithout any parameter or with parameter "element-type". This "element-type" has to be equal to "application/json".
-
-
Method Details
-
create
Creates a new instance ofMediaTypewith the supplied type and subtype.- Parameters:
type- the primary type,nullis equivalent toAcceptPredicate.WILDCARD_VALUEsubtype- the subtype,nullis equivalent toAcceptPredicate.WILDCARD_VALUE- Returns:
- a new media type for the specified type and subtype
-
parse
Parses a media type from its string representation.- Parameters:
input- the input string representing a media type- Returns:
- parsed
MediaTypeinstance - Throws:
IllegalArgumentException- if the input is not parsableNullPointerException- if the input isnull
-
builder
A fluent API builder for creating customized Media type instances.- Returns:
- a new builder
-
type
Getter for primary type.- Returns:
- value of primary type.
-
isWildcardType
public boolean isWildcardType()Checks if the primary type is a wildcard.- Returns:
- true if the primary type is a wildcard.
-
subtype
Getter for subtype.- Returns:
- value of subtype.
-
isWildcardSubtype
public boolean isWildcardSubtype()Checks if the subtype is a wildcard.- Returns:
- true if the subtype is a wildcard.
-
parameters
Getter for a read-only parameter map. Keys are case-insensitive.- Returns:
- an immutable map of parameters.
-
withCharset
Create a newMediaTypeinstance with the same type, subtype and parameters copied from the original instance and the supplied "charset" parameter. -
withoutParameters
Deprecated, for removal: This API element is subject to removal in a future version.will be removed in 4.x version.Create a newMediaTypeinstance with the same type and subtype. All parameters are trimmed. If currentMediaTypeinstance does not contain parameters, the same instance is returned.- Returns:
MediaTypeinstance without parameters.
-
charset
GetsOptionalvalue of charset parameter.- Returns:
- Charset parameter.
-
qualityFactor
public double qualityFactor()Description copied from interface:AcceptPredicateGets quality factor parameter ("q") as a double value. If missing, then returns1.0- Specified by:
qualityFactorin interfaceAcceptPredicate<MediaType>- Returns:
- Quality factor parameter.
-
test
Check if this media type is compatible with another media type. E.g. image/* is compatible with image/jpeg, image/png, etc. Media type parameters are ignored. The function is commutative. -
equals
Comparesobjto this media type to see if they are the same by comparing type, subtype and parameters. Note that the case-sensitivity of parameter values is dependent on the semantics of the parameter name, see HTTP/1.1. This method assumes that values are case-sensitive.Note that the
equals(...)implementation does not perform a class equality check (this.getClass() == obj.getClass()). Therefore any class that extends fromMediaTypeclass and needs to override one of theequals(...)andhashCode()methods must always override both methods to ensure the contract betweenObject.equals(java.lang.Object)andObject.hashCode()does not break. -
hashCode
public int hashCode()Generate a hash code from the type, subtype and parameters.Note that the
equals(java.lang.Object)implementation does not perform a class equality check (this.getClass() == obj.getClass()). Therefore any class that extends fromMediaTypeclass and needs to override one of theequals(Object)andhashCode()methods must always override both methods to ensure the contract betweenObject.equals(java.lang.Object)andObject.hashCode()does not break. -
toString
Convert the media type to a string suitable for use as the value of a corresponding HTTP header. -
hasSuffix
Tests if this media type has provided Structured Syntaxsuffix(RFC 6839).- Parameters:
suffix- Suffix with or without '+' prefix. If null or empty then returnstrueif this media type has ANY suffix.- Returns:
trueif media type has specifiedsuffixor has any suffix if parameter isnullor empty.
-