Movatterモバイル変換


[0]ホーム

URL:


         


Interface Part

All Known Subinterfaces:
MimePart
All Known Implementing Classes:
Message,BodyPart

public interfacePart

ThePart interface is the common base interface for Messages and BodyParts.

Part consists of a set of attributes and a "Content".

Attributes:

The JavaMail API defines a set of standard Part attributes that are considered to be common to most existing Mail systems. These attributes have their own settor and gettor methods. Mail systems may support other Part attributes as well, these are represented as name-value pairs where both the name and value are Strings.

Content:

Thedata type of the "content" is returned by thegetContentType() method. The MIME typing system is used to name data types.

The "content" of a Part is available in various formats:

Part provides thewriteTo() method that streams out its bytestream in mail-safe form suitable for transmission. This bytestream is typically an aggregation of the Part attributes and its content's bytestream.

Message and BodyPart implement the Part interface. Note that in MIME parlance, Part models an Entity (RFC2045, Section 2.4)


ATTACHMENT
          This part should be presented as an attachment.
INLINE
          This part should be presented inline.
 
addHeader(java.lang.String header_name, java.lang.String header_value)
          Add this value to the existing values for this header_name.
getAllHeaders()
          Return all the headers from this part as an Enumeration of Header objects.
getContent()
          Return the content as a Java object.
getContentType()
          Returns the Content-Type of the content of this part.
getDataHandler()
          Return a DataHandler for the content within this part.
getDescription()
          Return a description String for this part.
getDisposition()
          Return the disposition of this part.
getFileName()
          Get the filename associated with this part, if possible.
getHeader(java.lang.String header_name)
          Get all the headers for this header name.
getInputStream()
          Return an input stream for this part's "content".
getLineCount()
          Return the number of lines in the content of this part.
getMatchingHeaders(java.lang.String[] header_names)
          Return matching headers from this part as an Enumeration of Header objects.
getNonMatchingHeaders(java.lang.String[] header_names)
          Return non-matching headers from this envelope as an Enumeration of Header objects.
getSize()
          Return the size of the content of this part in bytes.
isMimeType(java.lang.String mimeType)
          Is this Part of the specified MIME type? This method comparesonly theprimaryType andsubType.
removeHeader(java.lang.String header_name)
          Remove all headers with this name.
setContent(Multipart mp)
          This method sets the given Multipart object as this message's content.
setContent(java.lang.Object obj, java.lang.String type)
          A convenience method for setting this part's content.
setDataHandler(DataHandler dh)
          This method provides the mechanism to set this part's content.
setDescription(java.lang.String description)
          Set a description String for this part.
setDisposition(java.lang.String disposition)
          Set the disposition of this part.
setFileName(java.lang.String filename)
          Set the filename associated with this part, if possible.
setHeader(java.lang.String header_name, java.lang.String header_value)
          Set the value for this header_name.
setText(java.lang.String text)
          A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
writeTo(java.io.OutputStream os)
          Output a bytestream for this Part.
 

ATTACHMENT

public static final java.lang.StringATTACHMENT
This part should be presented as an attachment.
See Also:
getDisposition(),setDisposition(java.lang.String)

INLINE

public static final java.lang.StringINLINE
This part should be presented inline.
See Also:
getDisposition(),setDisposition(java.lang.String)

getSize

public intgetSize()            throwsMessagingException
Return the size of the content of this part in bytes. Return -1 if the size cannot be determined.

Note that the size may not be an exact measure of the content size and may or may not account for any transfer encoding of the content. The size is appropriate for display in a user interface to give the user a rough idea of the size of this part.

Returns:
size of content in bytes
Throws:
MessagingException -  

getLineCount

public intgetLineCount()                 throwsMessagingException
Return the number of lines in the content of this part. Return -1 if the number cannot be determined. Note that this number may not be an exact measure of the content length and may or may not account for any transfer encoding of the content.
Returns:
number of lines in the content.
Throws:
MessagingException -  

getContentType

public java.lang.StringgetContentType()                                throwsMessagingException
Returns the Content-Type of the content of this part. Returns null if the Content-Type could not be determined.

The MIME typing system is used to name Content-types.

Returns:
The ContentType of this part
Throws:
MessagingException -  
See Also:
DataHandler

isMimeType

public booleanisMimeType(java.lang.String mimeType)                   throwsMessagingException
Is this Part of the specified MIME type? This method comparesonly theprimaryType andsubType. The parameters of the content types are ignored.

For example, this method will returntrue when comparing a Part of content type"text/plain" with"text/plain; charset=foobar".

If thesubType ofmimeType is the special character '*', then the subtype is ignored during the comparison.


getDisposition

public java.lang.StringgetDisposition()                                throwsMessagingException
Return the disposition of this part. The disposition describes how the part should be presented to the user.
Returns:
disposition of this part, or null if unknown
Throws:
MessagingException -  
See Also:
ATTACHMENT,INLINE,getFileName()

setDisposition

public voidsetDisposition(java.lang.String disposition)                    throwsMessagingException
Set the disposition of this part.
Parameters:
disposition - disposition of this part
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementationdoes not support modification of this header
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder
See Also:
ATTACHMENT,INLINE,setFileName(java.lang.String)

getDescription

public java.lang.StringgetDescription()                                throwsMessagingException
Return a description String for this part. This typically associates some descriptive information with this part. Returns null if none is available.
Returns:
description of this part
Throws:
MessagingException -  

setDescription

public voidsetDescription(java.lang.String description)                    throwsMessagingException
Set a description String for this part. This typically associates some descriptive information with this part.
Parameters:
description - description of this part
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementationdoes not support modification of this header
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

getFileName

public java.lang.StringgetFileName()                             throwsMessagingException
Get the filename associated with this part, if possible. Useful if this part represents an "attachment" that was loaded from a file. The filename will usually be a simple name, not including directory components.
Returns:
Filename to associate with this part

setFileName

public voidsetFileName(java.lang.String filename)                 throwsMessagingException
Set the filename associated with this part, if possible. Useful if this part represents an "attachment" that was loaded from a file. The filename will usually be a simple name, not including directory components.
Parameters:
filename - Filename to associate with this part
Throws:
IllegalWriteException - if the underlying implementationdoes not support modification of this header
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

getInputStream

public java.io.InputStreamgetInputStream()                                   throws java.io.IOException,MessagingException
Return an input stream for this part's "content". Any mail-specific transfer encodings will be decoded before the input stream is provided.

This is typically a convenience method that just invokes the DataHandler'sgetInputStream() method.

Returns:
an InputStream
Throws:
java.io.IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
MessagingException -  
See Also:
getDataHandler(),DataHandler.getInputStream()

getDataHandler

publicDataHandlergetDataHandler()                           throwsMessagingException
Return a DataHandler for the content within this part. The DataHandler allows clients to operate on as well as retrieve the content.
Returns:
DataHandler for the content
Throws:
MessagingException -  

getContent

public java.lang.ObjectgetContent()                            throws java.io.IOException,MessagingException
Return the content as a Java object. The type of the returned object is of course dependent on the content itself. For example, the object returned for "text/plain" content is usually a String object. The object returned for a "multipart" content is always a Multipart subclass. For content-types that are unknown to the DataHandler system, an input stream is returned as the content

This is a convenience method that just invokes the DataHandler's getContent() method

Returns:
Object
Throws:
MessagingException -  
java.io.IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
See Also:
DataHandler.getContent()

setDataHandler

public voidsetDataHandler(DataHandler dh)                    throwsMessagingException
This method provides the mechanism to set this part's content. The DataHandler wraps around the actual content.
Parameters:
dh - The DataHandler for the content.
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementationdoes not support modification of existing values
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

setContent

public voidsetContent(java.lang.Object obj,                       java.lang.String type)                throwsMessagingException
A convenience method for setting this part's content. The part internally wraps the content in a DataHandler.

Note that a DataContentHandler class for the specified type should be available to the JavaMail implementation for this to work right. i.e., to dosetContent(foobar, "application/x-foobar"), a DataContentHandler for "application/x-foobar" should be installed. Refer to the Java Activation Framework for more information.

Parameters:
obj - A java object.
type - MIME type of this object.
Throws:
IllegalWriteException - if the underlying implementationdoes not support modification of existing values
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

setText

public voidsetText(java.lang.String text)             throwsMessagingException
A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
Parameters:
text - The text that is the Message's content.
Throws:
IllegalWriteException - if the underlying implementation does not support modification of existing values
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

setContent

public voidsetContent(Multipart mp)                throwsMessagingException
This method sets the given Multipart object as this message's content.
Parameters:
mp - The multipart object that is the Message's content
Throws:
IllegalWriteException - if the underlying implementationdoes not support modification of existing values
java.lang.IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder

writeTo

public voidwriteTo(java.io.OutputStream os)             throws java.io.IOException,MessagingException
Output a bytestream for this Part. This bytestream is typically an aggregration of the Part attributes and an appropriately encoded bytestream from its 'content'.

Classes that implement the Part interface decide on the appropriate encoding algorithm to be used.

The bytestream is typically used for sending.

Throws:
java.io.IOException - if an error occurs writing to the stream or if an error is generatedby the javax.activation layer.
MessagingException - if an error occurs fetching thedata to be written
See Also:
DataHandler.writeTo(java.io.OutputStream)

getHeader

public java.lang.String[]getHeader(java.lang.String header_name)                             throwsMessagingException
Get all the headers for this header name. Returnsnull if no headers for this header name are available.
Parameters:
header_name - the name of this header
Returns:
the value fields for all headers with this name
Throws:
MessagingException -  

setHeader

public voidsetHeader(java.lang.String header_name,                      java.lang.String header_value)               throwsMessagingException
Set the value for this header_name. Replaces all existing header values with this new value.
Parameters:
header_name - the name of this header
header_value - the value for this header
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementation does not support modification of existing values
java.lang.IllegalStateException - if this Part is obtained from a READ_ONLY folder

addHeader

public voidaddHeader(java.lang.String header_name,                      java.lang.String header_value)               throwsMessagingException
Add this value to the existing values for this header_name.
Parameters:
header_name - the name of this header
header_value - the value for this header
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementation does not support modification of existing values
java.lang.IllegalStateException - if this Part is obtained from a READ_ONLY folder

removeHeader

public voidremoveHeader(java.lang.String header_name)                  throwsMessagingException
Remove all headers with this name.
Parameters:
header_name - the name of this header
Throws:
MessagingException -  
IllegalWriteException - if the underlying implementation does not support modification of existing values
java.lang.IllegalStateException - if this Part is obtained from a READ_ONLY folder

getAllHeaders

public java.util.EnumerationgetAllHeaders()                                    throwsMessagingException
Return all the headers from this part as an Enumeration of Header objects.
Returns:
array of Header objects
Throws:
MessagingException -  

getMatchingHeaders

public java.util.EnumerationgetMatchingHeaders(java.lang.String[] header_names)                                         throwsMessagingException
Return matching headers from this part as an Enumeration of Header objects.
Returns:
array of Header objects
Throws:
MessagingException -  

getNonMatchingHeaders

public java.util.EnumerationgetNonMatchingHeaders(java.lang.String[] header_names)                                            throwsMessagingException
Return non-matching headers from this envelope as an Enumeration of Header objects.
Returns:
array of Header objects
Throws:
MessagingException -  

         


[8]ページ先頭

©2009-2025 Movatter.jp