Package javax.mail.internet
Class ContentType
java.lang.Object
javax.mail.internet.ContentType
This class represents a MIME Content-Type value. It provides
methods to parse a Content-Type string into individual components
and to generate a MIME style Content-Type string.
-
Constructor Summary
ConstructorDescriptionNo-arg Constructor.Constructor that takes a Content-Type string.ContentType
(String primaryType, String subType, ParameterList list) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturn the MIME type string, without the parameters.getParameter
(String name) Return the specified parameter value.Return a ParameterList object that holds all the available parameters.Return the primary type.Return the subType.boolean
Match with the specified content-type string.boolean
match
(ContentType cType) Match with the specified ContentType object.void
setParameter
(String name, String value) Set the specified parameter.void
Set a new ParameterList.void
setPrimaryType
(String primaryType) Set the primary type.void
setSubType
(String subType) Set the subType.toString()
Retrieve a RFC2045 style string representation of this Content-Type.
-
Constructor Details
-
ContentType
public ContentType()No-arg Constructor. -
ContentType
Constructor.- Parameters:
primaryType
- primary typesubType
- subTypelist
- ParameterList
-
ContentType
Constructor that takes a Content-Type string. The String is parsed into its constituents: primaryType, subType and parameters. A ParseException is thrown if the parse fails.- Parameters:
s
- the Content-Type string.- Throws:
ParseException
- if the parse fails.
-
-
Method Details
-
getPrimaryType
Return the primary type.- Returns:
- the primary type
-
getSubType
Return the subType.- Returns:
- the subType
-
getBaseType
Return the MIME type string, without the parameters. The returned value is basically the concatenation of the primaryType, the '/' character and the secondaryType.- Returns:
- the type
-
getParameter
Return the specified parameter value. Returnsnull
if this parameter is absent.- Returns:
- parameter value
-
getParameterList
Return a ParameterList object that holds all the available parameters. Returns null if no parameters are available.- Returns:
- ParameterList
-
setPrimaryType
Set the primary type. Overrides existing primary type.- Parameters:
primaryType
- primary type
-
setSubType
Set the subType. Replaces the existing subType.- Parameters:
subType
- the subType
-
setParameter
Set the specified parameter. If this parameter already exists, it is replaced by this new value.- Parameters:
name
- parameter namevalue
- parameter value
-
setParameterList
Set a new ParameterList.- Parameters:
list
- ParameterList
-
toString
Retrieve a RFC2045 style string representation of this Content-Type. Returns an empty string if the conversion failed. -
match
Match with the specified ContentType object. This method compares only theprimaryType
andsubType
. The parameters of both operands are ignored.For example, this method will return
true
when comparing the ContentTypes for "text/plain" and "text/plain; charset=foobar". If thesubType
of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will returntrue
when comparing the ContentTypes for "text/plain" and "text/*"- Parameters:
cType
- ContentType to compare this against
-
match
Match with the specified content-type string. This method compares only theprimaryType
andsubType
. The parameters of both operands are ignored.For example, this method will return
true
when comparing the ContentType for "text/plain" with "text/plain; charset=foobar". If thesubType
of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will returntrue
when comparing the ContentType for "text/plain" with "text/*"
-