public class BasicMediaTypeHeader extends BasicStringHeader
Content-Type: application/json;charset=utf-8
Constructor and Description |
---|
BasicMediaTypeHeader(String name,
Object value)
Constructor
|
Modifier and Type | Method and Description |
---|---|
MediaType |
asMediaType()
Returns this header as a
MediaType object. |
String |
getParameter(String name)
Returns a parameterized value of the header.
|
List<NameValuePair> |
getParameters()
Returns the additional parameters on this media type.
|
String |
getSubType()
Returns the
|
List<String> |
getSubTypes()
Returns the subtypes broken down by fragments delimited by
|
String |
getType()
Returns the
|
String |
getValue() |
boolean |
hasSubType(String st)
Returns
|
boolean |
isMetaSubtype()
Returns
|
int |
match(List<MediaType> mediaTypes)
Given a list of media types, returns the best match for this
|
int |
match(MediaType o,
boolean allowExtraSubTypes)
Returns a match metric against the specified media type where a larger number represents a better match.
|
static BasicMediaTypeHeader |
of(String name,
Object value)
Convenience creator.
|
static BasicMediaTypeHeader |
of(String name,
Supplier<?> value)
Convenience creator using supplier.
|
assertString
assertName, assertValue, canCast, cast, eqIC, equals, getElements, getName, getRawValue, hashCode, isSupplier, of, ofPair, toString, unwrap
public BasicMediaTypeHeader(String name, Object value)
public static BasicMediaTypeHeader of(String name, Object value)
name
- The header name.value
- The header value.
String
BasicMediaTypeHeader
object, or public static BasicMediaTypeHeader of(String name, Supplier<?> value)
Header value is re-evaluated on each call to getValue()
.
name
- The header name.value
- The header value supplier.
String
BasicMediaTypeHeader
object, or public MediaType asMediaType()
MediaType
object.MediaType
object.public int match(List<MediaType> mediaTypes)
Note that fuzzy matching is allowed on the media types where the
For example, given a
The purpose for this is to allow parsers to match when artifacts such as
mediaTypes
- The media types to match against.public final String getType()
public final String getSubType()
public final boolean hasSubType(String st)
st
- The subtype string.
Case is ignored.public final List<String> getSubTypes()
For example, the media type [
public final boolean isMetaSubtype()
public final int match(MediaType o, boolean allowExtraSubTypes)
This media type can contain
The comparison media type must not.
JsonSerializer
(SimpleJsonSerializer
(o
- The media type to compare with.allowExtraSubTypes
- If public List<NameValuePair> getParameters()
For example, given the media type string {level:[
.
public String getParameter(String name)
ContentType ct = ContentType.
name
- The header name.public String getValue()
getValue
in interface NameValuePair
getValue
in class BasicStringHeader
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.