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 StringgetCompatibleJsonTypeString(org.springframework.http.MediaType contentType) Get compatible JSON media typestatic org.springframework.http.MediaTypegetCompatibleXmlType(org.springframework.http.MediaType contentType) Get compatible XML media typestatic StringgetCompatibleXmlTypeString(org.springframework.http.MediaType contentType) Get compatible XML media type stringstatic booleanisCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType other) Check whether this givenMediaTypeis compatible with the other media type.static booleanisCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType[] others) Check whether this givenMediaTypeis compatible with any other media types.static booleanisCompatibleWithAny(String given, Collection<String> others) Check whether the given media type in string format is compatible with any other media typesstatic booleanisHal(org.springframework.http.MediaType mediaType) Check whether the media type is the supported HAL media type.static booleanisJson(org.springframework.http.MediaType mediaType) Check whether the media type is the supported JSON media type.static booleanisReadableMediaType(org.springframework.http.MediaType mediaType) Check whether the media type is readable.static booleanisXml(org.springframework.http.MediaType mediaType) Check whether the media type is the supported XML media type.static org.springframework.http.MediaTyperemoveCharset(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 givenMediaTypeis compatible with any other media types.- Parameters:
given- the given media typeothers- other reference media types with which to check- Returns:
trueif this media type is compatible with any other media type;falseif 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:
trueif this media type is compatible with any other media type;falseif 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 givenMediaTypeis 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:
trueif this media type is compatible with the given media type;falseotherwise
-