Class MediaType
- java.lang.Object
-
- org.apache.tomcat.util.http.parser.MediaType
-
public class MediaType extends java.lang.ObjectRepresents a parsed media type.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMediaType(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.StringgetCharset()Get the charset.intgetParameterCount()Get the number of parameters.java.lang.StringgetParameterValue(java.lang.String parameter)Get the value of a parameter.java.lang.StringgetSubtype()Get the media subtype.java.lang.StringgetType()Get the media type.static MediaTypeparseMediaType(java.io.Reader input)Parses a MediaType value, either from an HTTP header or from an application.static java.lang.StringparseMediaTypeOnly(java.lang.String input)A simplified media type parser that removes any parameters and just returns the media type and the subtype.java.lang.StringtoString()java.lang.StringtoStringNoCharset()Get the string representation without charset.
-
-
-
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:
toStringin classjava.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
-
-