# Class MediaType

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

public class MediaType extends Object
Represents a parsed media type.

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`String`
`getCharset()`
Get the charset.
`int`
`getParameterCount()`
Get the number of parameters.
`String`
`getParameterValue(String parameter)`
Get the value of a parameter.
`String`
`getSubtype()`
Get the media subtype.
`String`
`getType()`
Get the media type.
`static MediaType`
`parseMediaType(Reader 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()`
Get the string representation without charset.

### Methods inherited from class Object

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

## Constructor Details

### MediaType

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

Parameters:
  `type` - the media type
  `subtype` - the media subtype
  `parameters` - the parameters

## Method Details

### getType

public String getType()
Get the media type.

Returns:
  the type

### getSubtype

public String getSubtype()
Get the media subtype.

Returns:
  the subtype

### getCharset

public String getCharset()
Get the charset.

Returns:
  the charset

### getParameterCount

public int getParameterCount()
Get the number of parameters.

Returns:
  the parameter count

### getParameterValue

public String getParameterValue(String parameter)
Get the value of a parameter.

Parameters:
  `parameter` - the parameter name
Returns:
  the parameter value

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### toStringNoCharset

public String toStringNoCharset()
Get the string representation without charset.

Returns:
  the string representation

### parseMediaType

public static MediaType parseMediaType(Reader 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