public class ContentType extends java.lang.Object implements Compatible<ContentType>
| Modifier and Type | Field and Description |
|---|---|
static ContentType |
ANY_ANY |
static ContentType |
ANY_UTF8 |
static ContentType |
APPLICATION_ANY_UTF8 |
static ContentType |
APPLICATION_JSON_UTF8 |
static ContentType |
APPLICATION_XML_UTF8 |
static ContentType |
HAL_JSON_UTF8 |
static ContentType |
HAL_XML_UTF8 |
| Constructor and Description |
|---|
ContentType(MediaType mediaType,
Charset encoding) |
| Modifier and Type | Method and Description |
|---|---|
Charset |
charset() |
boolean |
compatible(ContentType other)
Return true if this
Compatible instance
could be safely replaced
with the supplied other
Compatible
Note compatibility is not symmetric
x.compatible(y) does NOT mean
y.compatible(x). |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
MediaType |
mediaType() |
static ContentType |
parse(java.lang.String contentType)
Parse a Content-Type header
with the form type/subtype;charset=encoding
ignoring any spaces
|
java.lang.String |
toString() |
public static final ContentType APPLICATION_JSON_UTF8
public static final ContentType APPLICATION_XML_UTF8
public static final ContentType HAL_JSON_UTF8
public static final ContentType HAL_XML_UTF8
public static final ContentType APPLICATION_ANY_UTF8
public static final ContentType ANY_UTF8
public static final ContentType ANY_ANY
public MediaType mediaType()
public Charset charset()
public boolean compatible(ContentType other)
CompatibleCompatible instance
could be safely replaced
with the supplied other
Compatible
Note compatibility is not symmetric
x.compatible(y) does NOT mean
y.compatible(x). Example:
application/json is compatible with (can replace) application/*
application/* is not compatible with (cannot replace) application/json
wildcard.compatible(json) = true
json.compatible(wildcard) = false
Neither is it transitive.
x.compatible(y) and z.compatible(y)
does not imply z.compatible(z). Example:
application/json is compatible with application/*
application/xml is compatible with application/*
application/xml is not compatible with application/jsoncompatible in interface Compatible<ContentType>other - another Compatible instanceCompatible could be replaced by the otherpublic static ContentType parse(java.lang.String contentType)
contentType - public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object