MimeType (Java EE 5 SDK)

Java

Java EE 5 SDK

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


javax.activation Class MimeType

java.lang.Object
  extended by javax.activation.MimeType
所有已实现的接口:
Externalizable, Serializable

public class MimeType
extends Object
implements Externalizable

A Multipurpose Internet Mail Extension (MIME) type, as defined in RFC 2045 and 2046.

另请参见:
Serialized Form

构造器摘要
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.
 
方法摘要
 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.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造器详细信息

MimeType

public MimeType()
Default constructor.


MimeType

public MimeType(String rawdata)
         throws MimeTypeParseException
Constructor that builds a MimeType from a String.

参数:
rawdata - the MIME type string
抛出异常:
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.

参数:
primary - the primary MIME type
sub - the MIME sub-type
抛出异常:
MimeTypeParseException - if the primary type or subtype is not a valid token

方法详细信息

getPrimaryType

public String getPrimaryType()
Retrieve the primary type of this object.

返回:
the primary MIME type

setPrimaryType

public void setPrimaryType(String primary)
                    throws MimeTypeParseException
Set the primary type for this object to the given String.

参数:
primary - the primary MIME type
抛出异常:
MimeTypeParseException - if the primary type is not a valid token

getSubType

public String getSubType()
Retrieve the subtype of this object.

返回:
the MIME subtype

setSubType

public void setSubType(String sub)
                throws MimeTypeParseException
Set the subtype for this object to the given String.

参数:
sub - the MIME subtype
抛出异常:
MimeTypeParseException - if the subtype is not a valid token

getParameters

public MimeTypeParameterList getParameters()
Retrieve this object's parameter list.

返回:
a MimeTypeParameterList object representing the parameters

getParameter

public String getParameter(String name)
Retrieve the value associated with the given name, or null if there is no current association.

参数:
name - the parameter name
返回:
the paramter's value

setParameter

public void setParameter(String name,
                         String value)
Set the value to be associated with the given name, replacing any previous association.

参数:
name - the parameter name
value - the paramter's value

removeParameter

public void removeParameter(String name)
Remove any value associated with the given name.

参数:
name - the parameter name

toString

public String toString()
Return the String representation of this object.

重写:
toString in class Object

getBaseType

public String getBaseType()
Return a String representation of this object without the parameter list.

返回:
the MIME type and sub-type

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.

参数:
type - the MimeType object to compare with
返回:
true if they match

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.

参数:
rawdata - the MIME type string to compare with
返回:
true if they match
抛出异常:
MimeTypeParseException

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.

规范说明:
writeExternal in interface Externalizable
参数:
out - the ObjectOutput object to write to
抛出异常:
IOException - Includes any I/O exceptions that may occur

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.

规范说明:
readExternal in interface Externalizable
参数:
in - the ObjectInput object to read from
抛出异常:
ClassNotFoundException - If the class for an object being restored cannot be found.
IOException

Java EE 5 SDK

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


提交错误或意见

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