|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.activation Class MimeType
java.lang.Object javax.activation.MimeType
- All Implemented Interfaces:
- Externalizable, Serializable
public class MimeType
- extends Object
- implements Externalizable
Implements:
java.io.Externalizable
RFC 2045 和 2046 中定义的多用途 Internet 邮件扩展(Multipurpose Internet Mail Extension,MIME)类型。
A Multipurpose Internet Mail Extension (MIME) type, as defined in RFC 2045 and 2046.
- See Also:
- Serialized Form
Constructor Summary | |
---|---|
MimeType()
Default constructor. |
|
MimeType(String rawdata)
Constructor that builds a MimeType from a String. |
|
MimeType(String primary,
String sub)
Constructor that builds a MimeType with the given primary and sub type but has an empty parameter list. |
Method Summary | |
---|---|
String |
getBaseType()
Return a String representation of this object without the parameter list. |
String |
getParameter(String name)
Retrieve the value associated with the given name, or null if there is no current association. |
MimeTypeParameterList |
getParameters()
Retrieve this object's parameter list. |
String |
getPrimaryType()
Retrieve the primary type of this object. |
String |
getSubType()
Retrieve the subtype of this object. |
boolean |
match(MimeType type)
Determine if the primary and sub type of this object is the same as what is in the given type. |
boolean |
match(String rawdata)
Determine if the primary and sub type of this object is the same as the content type described in rawdata. |
void |
readExternal(ObjectInput in)
The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. |
void |
removeParameter(String name)
Remove any value associated with the given name. |
void |
setParameter(String name,
String value)
Set the value to be associated with the given name, replacing any previous association. |
void |
setPrimaryType(String primary)
Set the primary type for this object to the given String. |
void |
setSubType(String sub)
Set the subtype for this object to the given String. |
String |
toString()
Return the String representation of this object. |
void |
writeExternal(ObjectOutput out)
The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings and arrays. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public
MimeType()
默认构造方法。
英文文档:
MimeType
public MimeType()
- Default constructor.
public
MimeType(String rawdata) throws MimeTypeParseException
根据 String 构建 MimeType 的构造方法。
rawdata | MIME 类型字符串 |
MimeType
public MimeType(String rawdata) throws MimeTypeParseException
- Constructor that builds a MimeType from a String.
- Parameters:
rawdata
- the MIME type string- Throws:
MimeTypeParseException
public
MimeType(String primary, String sub) throws MimeTypeParseException
用给定的基本类型和子类型构建 MimeType 的构造方法,它的参数列表为空。
primary | 基本 MIME 类型 |
sub | MIME 子类型 |
Throws | MimeTypeParseException: 如果基本类型或子类型不是有效的标记 |
MimeType
public MimeType(String primary, String sub) throws MimeTypeParseException
- Constructor that builds a MimeType with the given primary and sub type
but has an empty parameter list.
- Parameters:
primary
- the primary MIME typesub
- the MIME sub-type- Throws:
MimeTypeParseException
- if the primary type or subtype is not a valid token
Method Detail |
---|
public String
getPrimaryType()
获取此对象的基本类型。
return | 基本 MIME 类型 |
getPrimaryType
public String getPrimaryType()
- Retrieve the primary type of this object.
- Returns:
- the primary MIME type
public void
setPrimaryType(String primary) throws MimeTypeParseException
将此对象的基本类型设置为给定的 String。
primary | 基本 MIME 类型 |
Throws | MimeTypeParseException: 如果基本类型不是有效的标记 |
setPrimaryType
public void setPrimaryType(String primary) throws MimeTypeParseException
- Set the primary type for this object to the given String.
- Parameters:
primary
- the primary MIME type- Throws:
MimeTypeParseException
- if the primary type is not a valid token
public String
getSubType()
获取此对象的子类型。
return | MIME 子类型 |
getSubType
public String getSubType()
- Retrieve the subtype of this object.
- Returns:
- the MIME subtype
public void
setSubType(String sub) throws MimeTypeParseException
将此对象的子类型设置为给定的 String。
sub | MIME 子类型 |
Throws | MimeTypeParseException: 如果子类型不是有效的标记 |
setSubType
public void setSubType(String sub) throws MimeTypeParseException
- Set the subtype for this object to the given String.
- Parameters:
sub
- the MIME subtype- Throws:
MimeTypeParseException
- if the subtype is not a valid token
public MimeTypeParameterList
getParameters()
获取此对象的参数列表。
return | 表示参数的 MimeTypeParameterList 对象 |
getParameters
public MimeTypeParameterList getParameters()
- Retrieve this object's parameter list.
- Returns:
- a MimeTypeParameterList object representing the parameters
public String
getParameter(String name)
获取与给定名称关联的值;如果不存在当前关联,则返回 null。
name | 参数名 |
return | 参数的值 |
getParameter
public String getParameter(String name)
- Retrieve the value associated with the given name, or null if there
is no current association.
- Parameters:
name
- the parameter name- Returns:
- the paramter's value
public void
setParameter(String name, String value)
将值设置为与给定名称关联,替换以前的任何关联。
name | 参数名 |
value | 参数的值 |
setParameter
public void setParameter(String name, String value)
- Set the value to be associated with the given name, replacing
any previous association.
- Parameters:
name
- the parameter namevalue
- the paramter's value
public void
removeParameter(String name)
移除与给定名称关联的所有值。
name | 参数名 |
removeParameter
public void removeParameter(String name)
- Remove any value associated with the given name.
- Parameters:
name
- the parameter name
public String
toString()
返回此对象的 String 表示形式。
英文文档:
toString
public String toString()
public String
getBaseType()
返回此对象的 String 表示形式,不带参数列表。
return | MIME 类型和子类型 |
getBaseType
public String getBaseType()
- Return a String representation of this object
without the parameter list.
- Returns:
- the MIME type and sub-type
public boolean
match(MimeType type)
确定此对象的基本类型和子类型与给定类型中的类型是否相同。
type | 要与之比较的 MimeType 对象 |
return | 如果匹配,则返回 true |
match
public boolean match(MimeType type)
- Determine if the primary and sub type of this object is
the same as what is in the given type.
- Parameters:
type
- the MimeType object to compare with- Returns:
- true if they match
public boolean
match(String rawdata) throws MimeTypeParseException
确定此对象的基本类型和子类型与 rawdata 中描述的内容类型是否相同。
rawdata | 要与之比较的 MIME 类型字符串 |
return | 如果匹配,则返回 true |
match
public boolean match(String rawdata) throws MimeTypeParseException
- Determine if the primary and sub type of this object is
the same as the content type described in rawdata.
- Parameters:
rawdata
- the MIME type string to compare with- Returns:
- true if they match
- Throws:
MimeTypeParseException
public void
writeExternal(java.io.ObjectOutput out) throws java.io.IOException
对象可实现 writeExternal 方法来保存其内容:对于其基本值,调用 DataOutput 的方法;对于对象、字符串和数组,调用 ObjectOutput 的 writeObject 方法。
out | 要写入的 ObjectOutput 对象 |
Throws | java.io.IOException: 包含可能发生的所有 I/O 异常 |
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings
and arrays.
- Specified by:
writeExternal
in interfaceExternalizable
- Parameters:
out
- the ObjectOutput object to write to- Throws:
IOException
- Includes any I/O exceptions that may occur
public void
readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException
对象实现 readExternal 方法来恢复其内容,它通过调用 DataInput 的方法来恢复其基础类型,调用 readObject 来恢复对象、字符串和数组。readExternal 方法必须按照与 writeExternal 方法写入值时使用的相同顺序和类型来读取这些值。
in | 要从中读取的 ObjectInput 对象 |
Throws | ClassNotFoundException: 如果无法找到需要恢复的某个对象的类。 |
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays. The
readExternal method must read the values in the same sequence
and with the same types as were written by writeExternal.
- Specified by:
readExternal
in interfaceExternalizable
- Parameters:
in
- the ObjectInput object to read from- Throws:
ClassNotFoundException
- If the class for an object being restored cannot be found.IOException
|
|||||||||
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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!