Package org.apache.tomcat.util.http.parser

# Class MediaType

java.lang.Object
org.apache.tomcat.util.http.parser.MediaType

public class MediaType extends Object

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `MediaType(String type, String subtype, LinkedHashMap<String,String> parameters)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getCharset()`
  `int`
  `getParameterCount()`
  `String`
  `getParameterValue(String parameter)`
  `String`
  `getSubtype()`
  `String`
  `getType()`
  `static MediaType`
  `parseMediaType(StringReader input)`
  Parses a MediaType value, either from an HTTP header or from an application.
  `static String`
  `parseMediaTypeOnly(String input)`
  A simplified media type parser that removes any parameters and just returns the media type and the subtype.
  `String`
  `toString()`
  `String`
  `toStringNoCharset()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### MediaType

    protected MediaType(String type, String subtype, LinkedHashMap<String,String> parameters)

- ## Method Details

  - ### getType

    public String getType()

  - ### getSubtype

    public String getSubtype()

  - ### getCharset

    public String getCharset()

  - ### getParameterCount

    public int getParameterCount()

  - ### getParameterValue

    public String getParameterValue(String parameter)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### toStringNoCharset

    public String toStringNoCharset()

  - ### parseMediaType

    public static MediaType parseMediaType(StringReader input) throws 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:
      `IOException` - if there was a problem reading the input

  - ### parseMediaTypeOnly

    public static String parseMediaTypeOnly(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