Class ContentType
java.lang.Object
org.apache.olingo.commons.api.format.ContentType
Internally used
ContentType for OData library.
For more details on format and content of a ContentType see
Media Type format as defined in
RFC 7231, chapter 3.1.1.1.
media-type = type "/" subtype *( OWS ";" OWS parameter ) type = token subtype = token OWS = *( SP / HTAB ) ; optional whitespace parameter = token "=" ( token / quoted-string )Once created a
ContentType is IMMUTABLE.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final Stringstatic final Stringstatic final Stringstatic final ContentTypestatic final ContentTypestatic final ContentTypestatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionstatic ContentTypeCreates aContentTypebased on given input string (format).static ContentTypecreate(ContentType contentType, String parameterName, String parameterValue) Creates a content type from an existing content type and an additional parameter as key-value pair.booleanstatic ContentTypefromAcceptHeader(String accept) Uses the first MIME type from the accept header to determine the content type.getParameter(String name) Returns the value of a given parameter.Gets the parameters of this content type.Gets the subtype of this content type.getType()Gets the type of this content type.inthashCode()booleanisCompatible(ContentType other) static ContentTypeParses the given input string (format) and returns createdContentTypeif input was valid or returnNULLif input was not parseable.GetsContentTypeas string as defined in RFC 7231, chapter 3.1.1.1: Media Type.toString()
-
Field Details
-
PARAMETER_CHARSET
- See Also:
-
PARAMETER_IEEE754_COMPATIBLE
- See Also:
-
PARAMETER_ODATA_METADATA
- See Also:
-
VALUE_ODATA_METADATA_NONE
- See Also:
-
VALUE_ODATA_METADATA_MINIMAL
- See Also:
-
VALUE_ODATA_METADATA_FULL
- See Also:
-
APPLICATION_JSON
-
JSON
-
JSON_NO_METADATA
-
JSON_FULL_METADATA
-
APPLICATION_XML
-
APPLICATION_ATOM_XML
-
APPLICATION_ATOM_XML_ENTRY
-
APPLICATION_ATOM_XML_ENTRY_UTF8
-
APPLICATION_ATOM_XML_FEED
-
APPLICATION_ATOM_XML_FEED_UTF8
-
APPLICATION_ATOM_SVC
-
APPLICATION_OCTET_STREAM
-
APPLICATION_XHTML_XML
-
TEXT_HTML
-
TEXT_XML
-
TEXT_PLAIN
-
APPLICATION_SVG_XML
-
APPLICATION_FORM_URLENCODED
-
APPLICATION_HTTP
-
MULTIPART_MIXED
-
MULTIPART_FORM_DATA
-
-
Method Details
-
create
public static ContentType create(ContentType contentType, String parameterName, String parameterValue) throws IllegalArgumentException Creates a content type from an existing content type and an additional parameter as key-value pair.- Parameters:
contentType- an existing content typeparameterName- the name of the additional parameterparameterValue- the value of the additional parameter- Returns:
- a new
ContentTypeobject - Throws:
IllegalArgumentException
-
create
Creates aContentTypebased on given input string (format). Supported format isMedia Typeformat as defined in RFC 7231, chapter 3.1.1.1.- Parameters:
format- a string in format as defined in RFC 7231, chapter 3.1.1.1- Returns:
- a new
ContentTypeobject - Throws:
IllegalArgumentException- if input string is not parseable
-
parse
Parses the given input string (format) and returns createdContentTypeif input was valid or returnNULLif input was not parseable. For the definition of the supported format seecreate(String).- Parameters:
format- a string in format as defined in RFC 7231, chapter 3.1.1.1- Returns:
- a new
ContentTypeobject
-
fromAcceptHeader
Uses the first MIME type from the accept header to determine the content type.- Parameters:
accept- The accept header content, e.g. text/html,application/xhtml+xml,application/xml, may be null- Returns:
- The content type according to the accept header's first MIME type. Defaults to application/json if the accept header does not contain valid information. Never null.
-
getType
Gets the type of this content type. -
getSubtype
Gets the subtype of this content type. -
getParameters
Gets the parameters of this content type.- Returns:
- parameters of this
ContentTypeas unmodifiable map
-
getParameter
Returns the value of a given parameter. If the parameter does not exist the method returns null.- Parameters:
name- the name of the parameter to get (case-insensitive)- Returns:
- the value of the parameter or
nullif the parameter is not present
-
hashCode
public int hashCode() -
equals
-
isCompatible
ContentTypes are compatible iftypeandsubtypehave the same value.The set
parametersare always ignored (for compare with parameters seeequals(Object)).- Returns:
trueif both instances are compatible (see definition above), otherwisefalse.
-
toContentTypeString
GetsContentTypeas string as defined in RFC 7231, chapter 3.1.1.1: Media Type.- Returns:
- string representation of
ContentTypeobject
-
toString
-