Class MediaType


  • public class MediaType
    extends java.lang.Object
    Represents a parsed media type.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected MediaType​(java.lang.String type, java.lang.String subtype, java.util.LinkedHashMap<java.lang.String,​java.lang.String> parameters)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getCharset()
      Get the charset.
      int getParameterCount()
      Get the number of parameters.
      java.lang.String getParameterValue​(java.lang.String parameter)
      Get the value of a parameter.
      java.lang.String getSubtype()
      Get the media subtype.
      java.lang.String getType()
      Get the media type.
      static MediaType parseMediaType​(java.io.Reader input)
      Parses a MediaType value, either from an HTTP header or from an application.
      static java.lang.String parseMediaTypeOnly​(java.lang.String input)
      A simplified media type parser that removes any parameters and just returns the media type and the subtype.
      java.lang.String toString()  
      java.lang.String toStringNoCharset()
      Get the string representation without charset.
      • Methods inherited from class java.lang.Object

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

      • MediaType

        protected MediaType​(java.lang.String type,
                            java.lang.String subtype,
                            java.util.LinkedHashMap<java.lang.String,​java.lang.String> parameters)
        Constructor.
        Parameters:
        type - the media type
        subtype - the media subtype
        parameters - the parameters
    • Method Detail

      • getType

        public java.lang.String getType()
        Get the media type.
        Returns:
        the type
      • getSubtype

        public java.lang.String getSubtype()
        Get the media subtype.
        Returns:
        the subtype
      • getCharset

        public java.lang.String getCharset()
        Get the charset.
        Returns:
        the charset
      • getParameterCount

        public int getParameterCount()
        Get the number of parameters.
        Returns:
        the parameter count
      • getParameterValue

        public java.lang.String getParameterValue​(java.lang.String parameter)
        Get the value of a parameter.
        Parameters:
        parameter - the parameter name
        Returns:
        the parameter value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toStringNoCharset

        public java.lang.String toStringNoCharset()
        Get the string representation without charset.
        Returns:
        the string representation
      • parseMediaType

        public static MediaType parseMediaType​(java.io.Reader input)
                                        throws java.io.IOException
        Parses a MediaType value, either from an HTTP header or from an application.
        Parameters:
        input - a reader over the header text
        Returns:
        a MediaType parsed from the input, or null if not valid
        Throws:
        java.io.IOException - if there was a problem reading the input
      • parseMediaTypeOnly

        public static java.lang.String parseMediaTypeOnly​(java.lang.String input)
        A simplified media type parser that removes any parameters and just returns the media type and the subtype.
        Parameters:
        input - The input string to parse
        Returns:
        The media type and subtype from the input trimmed and converted to lower case