|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.mail.internet Class ContentType
java.lang.Object javax.mail.internet.ContentType
public class ContentType
- extends Object
此类表示一个 MIME ContentType 值。它提供一些可将 ContentType 字符串解析为单个组件并生成一个 MIME 样式的 ContentType 字符串的方法。
version | 1.10, 07/05/04 |
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.10, 07/05/04
- Author:
- John Mani
Constructor Summary | |
---|---|
ContentType()
No-arg Constructor. |
|
ContentType(String s)
Constructor that takes a Content-Type string. |
|
ContentType(String primaryType,
String subType,
ParameterList list)
Constructor. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public
ContentType()
无参数构造方法。
英文文档:
ContentType
public ContentType()
- No-arg Constructor.
public
ContentType(String primaryType, String subType, ParameterList list)
构造方法。
primaryType | 基本类型 | |
subType |
| |
list |
|
ContentType
public ContentType(String primaryType, String subType, ParameterList list)
- Constructor.
- Parameters:
primaryType
- primary typesubType
- subTypelist
- ParameterList
public
ContentType(String s) throws ParseException
带有 Content-Type 字符串的构造方法。String 被解析为它的组成部分:primaryType、subType 和参数。如果解析失败,则抛出 ParseException。
s | Content-Type 字符串。 |
Throws | ParseException: 如果解析失败。 |
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 |
---|
public String
getPrimaryType()
返回基本类型。
return | 基本类型 |
getPrimaryType
public String getPrimaryType()
- Return the primary type.
- Returns:
- the primary type
public String
getSubType()
返回 subType。
return | subType |
getSubType
public String getSubType()
- Return the subType.
- Returns:
- the subType
public String
getBaseType()
返回 MIME 类型的字符串,不带参数。返回的值通常是 primaryType、'/' 字符和 secondaryType 连接而成的字符串。
return | 类型 |
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
public String
getParameter(String name)
返回指定的参数值。如果此参数不存在,则返回 null
。
return | 参数值 |
getParameter
public String getParameter(String name)
- Return the specified parameter value. Returns
null
if this parameter is absent. - Returns:
- parameter value
public ParameterList
getParameterList()
返回保存所有可用参数的 ParameterList 对象。如果没有任何参数可用,则返回 null。
return |
|
getParameterList
public ParameterList getParameterList()
- Return a ParameterList object that holds all the available
parameters. Returns null if no parameters are available.
- Returns:
- ParameterList
public void
setPrimaryType(String primaryType)
设置基本类型。重写现有的基本类型。
primaryType | 基本类型 |
setPrimaryType
public void setPrimaryType(String primaryType)
- Set the primary type. Overrides existing primary type.
- Parameters:
primaryType
- primary type
public void
setSubType(String subType)
设置 subType。替换现有的 subType。
subType | subType |
setSubType
public void setSubType(String subType)
- Set the subType. Replaces the existing subType.
- Parameters:
subType
- the subType
public void
setParameter(String name, String value)
设置指定的参数。如果此参数已经存在,则使用此新值替代它。
name | 参数名称 |
value | 参数值 |
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
public void
setParameterList(ParameterList list)
设置一个新的 ParameterList。
list |
|
setParameterList
public void setParameterList(ParameterList list)
- Set a new ParameterList.
- Parameters:
list
- ParameterList
public String
toString()
获取此 Content-Type 的 RFC2045 样式的字符串表示形式。如果转换失败,则返回 null
。
return | RFC2045 样式字符串 |
toString
public String toString()
- Retrieve a RFC2045 style string representation of
this Content-Type. Returns
null
if the conversion failed. - Returns:
- RFC2045 style string
public boolean
match(ContentType cType)
匹配指定的 ContentType 对象。此方法仅比较 primaryType
和 subType
。忽略两个操作数的参数。
例如,当比较 ContentType 的 "text/plain" 和 "text/plain; charset=foobar" 时,此方法将返回 true
。
如果任一操作数的 subType
是特殊字符 '*',则匹配过程中将忽略 subtype。例如,当比较 ContentType 的 "text/plain" 和 "text/*" 时,此方法将返回 true
。
cType | 与此比较的 ContentType |
match
public boolean match(ContentType cType)
- Match with the specified ContentType object. This method
compares only the
primaryType
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
public boolean
match(String s)
匹配指定的内容类型字符串。此方法仅比较 primaryType
和 subType
。忽略两个操作数的参数。
例如,当比较 ContentType 的 "text/plain" 和 "text/plain; charset=foobar" 时,此方法将返回 true
。
如果任一操作数的 subType
是特殊字符 '*',则匹配过程中将忽略 subtype。例如,当比较 ContentType 的 "text/plain" 和 "text/*" 时,此方法将返回 true
。
match
public boolean match(String s)
- Match with the specified content-type string. This method
compares only the
primaryType
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/*"
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!