- java.lang.Object
- 
- jakarta.mail.internet.ContentType
 
- 
 public class ContentType extends java.lang.ObjectThis 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.- Author:
- John Mani
 
- 
- 
Constructor SummaryConstructors Constructor Description ContentType()No-arg Constructor.ContentType(java.lang.String s)Constructor that takes a Content-Type string.ContentType(java.lang.String primaryType, java.lang.String subType, ParameterList list)Constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBaseType()Return the MIME type string, without the parameters.java.lang.StringgetParameter(java.lang.String name)Return the specified parameter value.ParameterListgetParameterList()Return a ParameterList object that holds all the available parameters.java.lang.StringgetPrimaryType()Return the primary type.java.lang.StringgetSubType()Return the subType.booleanmatch(ContentType cType)Match with the specified ContentType object.booleanmatch(java.lang.String s)Match with the specified content-type string.voidsetParameter(java.lang.String name, java.lang.String value)Set the specified parameter.voidsetParameterList(ParameterList list)Set a new ParameterList.voidsetPrimaryType(java.lang.String primaryType)Set the primary type.voidsetSubType(java.lang.String subType)Set the subType.java.lang.StringtoString()Retrieve a RFC2045 style string representation of this Content-Type.
 
- 
- 
- 
Constructor Detail- 
ContentTypepublic ContentType() No-arg Constructor.
 - 
ContentTypepublic ContentType(java.lang.String primaryType, java.lang.String subType, ParameterList list)Constructor.- Parameters:
- primaryType- primary type
- subType- subType
- list- ParameterList
 
 - 
ContentTypepublic ContentType(java.lang.String s) throws ParseExceptionConstructor 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 Detail- 
getPrimaryTypepublic java.lang.String getPrimaryType() Return the primary type.- Returns:
- the primary type
 
 - 
getSubTypepublic java.lang.String getSubType() Return the subType.- Returns:
- the subType
 
 - 
getBaseTypepublic java.lang.String 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
 
 - 
getParameterpublic java.lang.String getParameter(java.lang.String name) Return the specified parameter value. Returnsnullif this parameter is absent.- Parameters:
- name- the parameter name
- Returns:
- parameter value
 
 - 
getParameterListpublic ParameterList getParameterList() Return a ParameterList object that holds all the available parameters. Returns null if no parameters are available.- Returns:
- ParameterList
 
 - 
setPrimaryTypepublic void setPrimaryType(java.lang.String primaryType) Set the primary type. Overrides existing primary type.- Parameters:
- primaryType- primary type
 
 - 
setSubTypepublic void setSubType(java.lang.String subType) Set the subType. Replaces the existing subType.- Parameters:
- subType- the subType
 
 - 
setParameterpublic void setParameter(java.lang.String name, java.lang.String value)Set the specified parameter. If this parameter already exists, it is replaced by this new value.- Parameters:
- name- parameter name
- value- parameter value
 
 - 
setParameterListpublic void setParameterList(ParameterList list) Set a new ParameterList.- Parameters:
- list- ParameterList
 
 - 
toStringpublic java.lang.String toString() Retrieve a RFC2045 style string representation of this Content-Type. Returns an empty string if the conversion failed.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- RFC2045 style string
 
 - 
matchpublic boolean match(ContentType cType) Match with the specified ContentType object. This method compares only theprimaryTypeandsubType. The parameters of both operands are ignored.For example, this method will return truewhen comparing the ContentTypes for "text/plain" and "text/plain; charset=foobar". If thesubTypeof either operand is the special character '*', then the subtype is ignored during the match. For example, this method will returntruewhen comparing the ContentTypes for "text/plain" and "text/*"- Parameters:
- cType- ContentType to compare this against
- Returns:
- true if it matches
 
 - 
matchpublic boolean match(java.lang.String s) Match with the specified content-type string. This method compares only theprimaryTypeandsubType. The parameters of both operands are ignored.For example, this method will return truewhen comparing the ContentType for "text/plain" with "text/plain; charset=foobar". If thesubTypeof either operand is the special character '*', then the subtype is ignored during the match. For example, this method will returntruewhen comparing the ContentType for "text/plain" with "text/*"- Parameters:
- s- the content-type string to match
- Returns:
- true if it matches
 
 
- 
 
-