Package com.emc.documentum.rest.http
Class MediaTypeHelper
java.lang.Object
com.emc.documentum.rest.http.MediaTypeHelper
A helper class to check the information within a media type.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getCompatibleJsonTypeString
(org.springframework.http.MediaType contentType) Get compatible JSON media typestatic org.springframework.http.MediaType
getCompatibleXmlType
(org.springframework.http.MediaType contentType) Get compatible XML media typestatic String
getCompatibleXmlTypeString
(org.springframework.http.MediaType contentType) Get compatible XML media type stringstatic boolean
isCompatibleWith
(org.springframework.http.MediaType given, org.springframework.http.MediaType other) Check whether this givenMediaType
is compatible with the other media type.static boolean
isCompatibleWith
(org.springframework.http.MediaType given, org.springframework.http.MediaType[] others) Check whether this givenMediaType
is compatible with any other media types.static boolean
isCompatibleWithAny
(String given, Collection<String> others) Check whether the given media type in string format is compatible with any other media typesstatic boolean
isHal
(org.springframework.http.MediaType mediaType) Check whether the media type is the supported HAL media type.static boolean
isJson
(org.springframework.http.MediaType mediaType) Check whether the media type is the supported JSON media type.static boolean
isReadableMediaType
(org.springframework.http.MediaType mediaType) Check whether the media type is readable.static boolean
isXml
(org.springframework.http.MediaType mediaType) Check whether the media type is the supported XML media type.static org.springframework.http.MediaType
removeCharset
(org.springframework.http.MediaType contentType) Remove charset from the media type.
-
Method Details
-
isReadableMediaType
public static boolean isReadableMediaType(org.springframework.http.MediaType mediaType) Check whether the media type is readable. The readable media types includes:- application/vnd.emc.documentum+xml
- application/vnd.emc.documentum+json
- Parameters:
mediaType
- the media type- Returns:
- true if the media type is readable; false otherwise.
-
isXml
public static boolean isXml(org.springframework.http.MediaType mediaType) Check whether the media type is the supported XML media type. The supported media type must be compatible with one of below media types:- application/vnd.emc.documentum+xml
- application/atom+xml
- application/xml
- Parameters:
mediaType
- the media type- Returns:
- true if the media type is the supported XML media type; false otherwise.
-
isJson
public static boolean isJson(org.springframework.http.MediaType mediaType) Check whether the media type is the supported JSON media type. The supported media type must be compatible with one of below media types:- application/vnd.emc.documentum+json
- application/json
- Parameters:
mediaType
- the media type- Returns:
- true if the media type is the supported JSON media type; false otherwise.
-
isHal
public static boolean isHal(org.springframework.http.MediaType mediaType) Check whether the media type is the supported HAL media type. The supported media type must be compatible with one of below media types:- application/hal+json
- application/json
- Parameters:
mediaType
- the media type- Returns:
- true if the media type is the supported HAL media type; false otherwise.
-
removeCharset
public static org.springframework.http.MediaType removeCharset(org.springframework.http.MediaType contentType) Remove charset from the media type. For example, an input media type 'application/json;charset=UTF-8' will be returned as 'application/json'.- Parameters:
contentType
- the content type which contains charset- Returns:
- content type without charset info
-
getCompatibleXmlTypeString
Get compatible XML media type string- Parameters:
contentType
- the input media type- Returns:
- the string value of the compatible XML media type
-
getCompatibleXmlType
public static org.springframework.http.MediaType getCompatibleXmlType(org.springframework.http.MediaType contentType) Get compatible XML media type- Parameters:
contentType
- the input media type- Returns:
- the string value of the compatible XML media type
-
getCompatibleJsonTypeString
Get compatible JSON media type- Parameters:
contentType
- the input media type- Returns:
- the string value of the compatible JSON media type
-
isCompatibleWith
public static boolean isCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType[] others) Check whether this givenMediaType
is compatible with any other media types.- Parameters:
given
- the given media typeothers
- other reference media types with which to check- Returns:
true
if this media type is compatible with any other media type;false
if the given media type is not compatible with any other media types.
-
isCompatibleWithAny
Check whether the given media type in string format is compatible with any other media types- Parameters:
given
- the given media type in string formatothers
- other reference media types with which to check- Returns:
true
if this media type is compatible with any other media type;false
if the given media type is not compatible with any other media types.
-
isCompatibleWith
public static boolean isCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType other) Check whether this givenMediaType
is compatible with the other media type.For instance,
text/*
is compatible withtext/plain
,text/html
, and vice versa.- Parameters:
given
- the media typeother
- the reference media type with which to compare- Returns:
true
if this media type is compatible with the given media type;false
otherwise
-