ContentType (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail.internet Class ContentType

java.lang.Object
  extended by javax.mail.internet.ContentType

public 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.

版本:
1.10, 07/05/04
作者:
John Mani

构造器摘要
ContentType()
          No-arg Constructor.
ContentType(String s)
          Constructor that takes a Content-Type string.
ContentType(String primaryType, String subType, ParameterList list)
          Constructor.
 
方法摘要
 String getBaseType()
          Return the MIME type string, without the parameters.
 String getParameter(String name)
          Return the specified parameter value.
 ParameterList getParameterList()
          Return a ParameterList object that holds all the available parameters.
 String getPrimaryType()
          Return the primary type.
 String getSubType()
          Return the subType.
 boolean match(ContentType cType)
          Match with the specified ContentType object.
 boolean match(String s)
          Match with the specified content-type string.
 void setParameter(String name, String value)
          Set the specified parameter.
 void setParameterList(ParameterList list)
          Set a new ParameterList.
 void setPrimaryType(String primaryType)
          Set the primary type.
 void setSubType(String subType)
          Set the subType.
 String toString()
          Retrieve a RFC2045 style string representation of this Content-Type.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造器详细信息

ContentType

public ContentType()
No-arg Constructor.


ContentType

public ContentType(String primaryType,
                   String subType,
                   ParameterList list)
Constructor.

参数:
primaryType - primary type
subType - subType
list - 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.

参数:
s - the Content-Type string.
抛出异常:
ParseException - if the parse fails.

方法详细信息

getPrimaryType

public String getPrimaryType()
Return the primary type.

返回:
the primary type

getSubType

public String getSubType()
Return the subType.

返回:
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.

返回:
the type

getParameter

public String getParameter(String name)
Return the specified parameter value. Returns null if this parameter is absent.

返回:
parameter value

getParameterList

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

返回:
ParameterList

setPrimaryType

public void setPrimaryType(String primaryType)
Set the primary type. Overrides existing primary type.

参数:
primaryType - primary type

setSubType

public void setSubType(String subType)
Set the subType. Replaces the existing subType.

参数:
subType - the 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.

参数:
name - parameter name
value - parameter value

setParameterList

public void setParameterList(ParameterList list)
Set a new ParameterList.

参数:
list - ParameterList

toString

public String toString()
Retrieve a RFC2045 style string representation of this Content-Type. Returns null if the conversion failed.

重写:
toString in class Object
返回:
RFC2045 style string

match

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/*"

参数:
cType - ContentType to compare this against

match

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/*"


Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.