public final class ContentType extends Object
The relevant productions from RFC 2045 and RFC 822 are:
content := "Content-Type" ":" type "/" subtype *(";" parameter) parameter := attribute "=" value attribute := token value := token / quoted-string token := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials> tspecials := "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "=" quoted-string := <"> *(qtext/quoted-pair) <"> qtext := <any CHAR excepting <">, "\" & CR, and including linear-white-space> quoted-pair := "\" CHAR
This class is similar to
MimeType and JavaMail's
ContentType class, but the
following differences exist:
MimeType. It will accept content types that are not strictly valid, but that are commonly found. E.g. it will accept content types with an extra semicolon at the end.
MediaTypeobject) and a content type, which is defined by a media type and a set of parameters.
Another reason for the existence of this class is to avoid a dependency on JavaMail.
Note that this class doesn't override
Object.equals(Object) because there is no
meaningful way to compare content types with parameters.
|Constructor and Description|
Constructor that parses a Content-Type header value.
|Modifier and Type||Method and Description|
Get the media type this content type refers to.
Get the specified parameter value.
Create a string representation of this content type suitable as the value for a Content-Type header as specified by RFC 2045.
mediaType- the media type
parameters- an array specifying the parameters as name/value pairs (with even entries representing the parameter names, and odd entries the corresponding values)
public MediaType getMediaType()
name- the parameter name
nullif no parameter with the given name was found
public String toString()
Copyright © The Apache Software Foundation. All Rights Reserved.