Top Description Fields Constructors Methods
javax.mail.internet

public Class ContentType

extends Object
Class Inheritance
Imports
javax.mail.*, java.util.*, java.io.*

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.
Author
John Mani

Field Summary

Modifier and TypeField and Description
private ParameterList
private String
private String

Constructor Summary

AccessConstructor and Description
public
ContentType()

No-arg Constructor.

public
ContentType(String
primary type
primaryType
,
String
subType
subType
,
ParameterList
ParameterList
list
)

Constructor.

public
ContentType(String
the Content-Type string.
s
)

Constructor that takes a Content-Type string.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the type
getBaseType
()

Return the MIME type string, without the parameters.

public String

Returns:

parameter value
getParameter
(String
the parameter name
name
)

Return the specified parameter value.

public ParameterList

Returns:

ParameterList
getParameterList
()

Return a ParameterList object that holds all the available parameters.

public String

Returns:

the primary type
getPrimaryType
()

Return the primary type.

public String

Returns:

the subType
getSubType
()

Return the subType.

public boolean

Returns:

true if it matches
match
(ContentType
ContentType to compare this against
cType
)

Match with the specified ContentType object.

public boolean

Returns:

true if it matches
match
(String
the content-type string to match
s
)

Match with the specified content-type string.

public void
setParameter(String
parameter name
name
,
String
parameter value
value
)

Set the specified parameter.

public void
setParameterList(ParameterList
ParameterList
list
)

Set a new ParameterList.

public void
setPrimaryType(String
primary type
primaryType
)

Set the primary type.

public void
setSubType(String
the subType
subType
)

Set the subType.

public String

Returns:

RFC2045 style string
toString
()

Overrides java.lang.Object.toString.

Retrieve a RFC2045 style string representation of this Content-Type.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

listback to summary
private ParameterList list
primaryTypeback to summary
private String primaryType
subTypeback to summary
private String subType

Constructor Detail

ContentTypeback to summary
public ContentType()

No-arg Constructor.

ContentTypeback to summary
public ContentType(String primaryType, String subType, ParameterList list)

Constructor.

Parameters
primaryType:String

primary type

subType:String

subType

list:ParameterList

ParameterList

ContentTypeback to summary
public ContentType(String s) throws ParseException

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:String

the Content-Type string.

Exceptions
ParseException:
if the parse fails.

Method Detail

getBaseTypeback to summary
public 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:String

the type

getParameterback to summary
public String getParameter(String name)

Return the specified parameter value. Returns null if this parameter is absent.

Parameters
name:String

the parameter name

Returns:String

parameter value

getParameterListback to summary
public ParameterList getParameterList()

Return a ParameterList object that holds all the available parameters. Returns null if no parameters are available.

Returns:ParameterList

ParameterList

getPrimaryTypeback to summary
public String getPrimaryType()

Return the primary type.

Returns:String

the primary type

getSubTypeback to summary
public String getSubType()

Return the subType.

Returns:String

the subType

matchback to summary
public boolean match(ContentType cType)

Match with the specified ContentType object. This method compares only the primaryType and subType . 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 the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentTypes for "text/plain" and "text/*"

Parameters
cType:ContentType

ContentType to compare this against

Returns:boolean

true if it matches

matchback to summary
public boolean match(String s)

Match with the specified content-type string. This method compares only the primaryType and subType . 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 the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentType for "text/plain" with "text/*"

Parameters
s:String

the content-type string to match

Returns:boolean

true if it matches

setParameterback to summary
public void setParameter(String name, String value)

Set the specified parameter. If this parameter already exists, it is replaced by this new value.

Parameters
name:String

parameter name

value:String

parameter value

setParameterListback to summary
public void setParameterList(ParameterList list)

Set a new ParameterList.

Parameters
list:ParameterList

ParameterList

setPrimaryTypeback to summary
public void setPrimaryType(String primaryType)

Set the primary type. Overrides existing primary type.

Parameters
primaryType:String

primary type

setSubTypeback to summary
public void setSubType(String subType)

Set the subType. Replaces the existing subType.

Parameters
subType:String

the subType

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Retrieve a RFC2045 style string representation of this Content-Type. Returns an empty string if the conversion failed.

Returns:String

RFC2045 style string

Annotations
@Override