Class MediaTypeHelper

java.lang.Object
com.emc.documentum.rest.http.MediaTypeHelper

public final class MediaTypeHelper extends Object
A helper class to check the information within a media type.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getCompatibleJsonTypeString(org.springframework.http.MediaType contentType)
    Get compatible JSON media type
    static org.springframework.http.MediaType
    getCompatibleXmlType(org.springframework.http.MediaType contentType)
    Get compatible XML media type
    static String
    getCompatibleXmlTypeString(org.springframework.http.MediaType contentType)
    Get compatible XML media type string
    static boolean
    isCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType other)
    Check whether this given MediaType is compatible with the other media type.
    static boolean
    isCompatibleWith(org.springframework.http.MediaType given, org.springframework.http.MediaType[] others)
    Check whether this given MediaType is compatible with any other media types.
    static boolean
    Check whether the given media type in string format is compatible with any other media types
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String getCompatibleXmlTypeString(org.springframework.http.MediaType contentType)
      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

      public static String getCompatibleJsonTypeString(org.springframework.http.MediaType contentType)
      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 given MediaType is compatible with any other media types.
      Parameters:
      given - the given media type
      others - 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

      public static boolean isCompatibleWithAny(String given, Collection<String> others)
      Check whether the given media type in string format is compatible with any other media types
      Parameters:
      given - the given media type in string format
      others - 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 given MediaType is compatible with the other media type.

      For instance, text/* is compatible with text/plain, text/html, and vice versa.

      Parameters:
      given - the media type
      other - the reference media type with which to compare
      Returns:
      true if this media type is compatible with the given media type; false otherwise