Class ContentType
- java.lang.Object
-
- com.sun.xml.messaging.saaj.packaging.mime.internet.ContentType
-
public final class ContentType extends Object
This class represents a MIME ContentType value. It provides methods to parse a ContentType string into individual components and to generate a MIME style ContentType string.- Version:
- 1.7, 02/03/27
- Author:
- John Mani
-
-
Constructor Summary
Constructors Constructor Description ContentType()No-arg Constructor.ContentType(String s)Constructor that takes a Content-Type string.ContentType(String primaryType, String subType, ParameterList list)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentTypecopy()StringgetBaseType()Return the MIME type string, without the parameters.StringgetParameter(String name)Return the specified parameter value.ParameterListgetParameterList()Return a ParameterList object that holds all the available parameters.StringgetPrimaryType()Return the primary type.StringgetSubType()Return the subType.booleanmatch(ContentType cType)Match with the specified ContentType object.booleanmatch(String s)Match with the specified content-type string.voidsetParameter(String name, String value)Set the specified parameter.voidsetParameterList(ParameterList list)Set a new ParameterList.voidsetPrimaryType(String primaryType)Set the primary type.voidsetSubType(String subType)Set the subType.StringtoString()Retrieve a RFC2045 style string representation of this Content-Type.
-
-
-
Constructor Detail
-
ContentType
public ContentType()
No-arg Constructor.
-
ContentType
public ContentType(String primaryType, String subType, ParameterList list)
Constructor.- Parameters:
primaryType- primary typesubType- subTypelist- ParameterList
-
ContentType
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- the Content-Type string.- Throws:
ParseException- if the parse fails.
-
-
Method Detail
-
copy
public ContentType copy()
-
getPrimaryType
public String getPrimaryType()
Return the primary type.- Returns:
- the primary type
-
getSubType
public String getSubType()
Return the subType.- Returns:
- the subType
-
getBaseType
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:
- the type
-
getParameter
public String getParameter(String name)
Return the specified parameter value. Returnsnullif this parameter is absent.- Parameters:
name- parameter name- Returns:
- parameter value
-
getParameterList
public ParameterList getParameterList()
Return a ParameterList object that holds all the available parameters. Returns null if no parameters are available.- Returns:
- ParameterList
-
setPrimaryType
public void setPrimaryType(String primaryType)
Set the primary type. Overrides existing primary type.- Parameters:
primaryType- primary type
-
setSubType
public void setSubType(String subType)
Set the subType. Overrides existing subType- Parameters:
subType- subType
-
setParameter
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- parameter namevalue- parameter value
-
setParameterList
public void setParameterList(ParameterList list)
Set a new ParameterList.- Parameters:
list- ParameterList
-
toString
public String toString()
Retrieve a RFC2045 style string representation of this Content-Type. Returnsnullif the conversion failed.
-
match
public boolean match(ContentType cType)
Match with the specified ContentType object. This method compares only theprimaryTypeandprimaryType. 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- to compare this against- Returns:
- true if
primaryTypeandsubTypematch specified content type.
-
match
public boolean match(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- content type- Returns:
- true if
primaryTypeandsubTypematch specified content type.
-
-