Class MediaTypeUtils


  • public abstract class MediaTypeUtils
    extends java.lang.Object

    This class is a clone of org.springframework.util.MimeTypeUtils

    Miscellaneous MediaType utility methods.
    Author:
    Arjen Poutsma, Rossen Stoyanchev, Dimitrios Liapis, Brian Clozel
    • Constructor Summary

      Constructors 
      Constructor Description
      MediaTypeUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static MediaType parseMediaType​(java.lang.String mediaType)
      Parse the given String into a single MediaType.
      static java.util.List<java.lang.String> tokenize​(java.lang.String mediaTypes)
      Tokenize the given comma-separated string of MediaType objects into a List<String>.
      static java.lang.String toString​(java.util.Collection<MediaType> mediaTypes)
      Return a string representation of the given list of MediaType objects.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MediaTypeUtils

        public MediaTypeUtils()
    • Method Detail

      • parseMediaType

        protected static MediaType parseMediaType​(java.lang.String mediaType)
        Parse the given String into a single MediaType. Recently parsed MediaType are cached for further retrieval.
        Parameters:
        mediaType - the string to parse
        Returns:
        the media type
        Throws:
        InvalidMediaTypeException - if the string cannot be parsed
      • tokenize

        public static java.util.List<java.lang.String> tokenize​(java.lang.String mediaTypes)
        Tokenize the given comma-separated string of MediaType objects into a List<String>. Unlike simple tokenization by ",", this method takes into account quoted parameters.
        Parameters:
        mediaTypes - the string to tokenize
        Returns:
        the list of tokens
      • toString

        public static java.lang.String toString​(java.util.Collection<MediaType> mediaTypes)
        Return a string representation of the given list of MediaType objects.
        Parameters:
        mediaTypes - the string to parse
        Returns:
        the list of media types
        Throws:
        java.lang.IllegalArgumentException - if the String cannot be parsed