Java Doc for Part.java in  » EJB-Server-GlassFish » mail » javax » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server GlassFish » mail » javax.mail 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.mail.Part

All known Subclasses:   javax.mail.BodyPart,  javax.mail.Message,
Part
public interface Part (Code)
The Part 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:

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

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

  • As a DataHandler - using the getDataHandler() method. The "content" of a Part is also available through a javax.activation.DataHandler object. The DataHandler object allows clients to discover the operations available on the content, and to instantiate the appropriate component to perform those operations.
  • As an input stream - using the getInputStream() method. Any mail-specific encodings are decoded before this stream is returned.
  • As a Java object - using the getContent() method. This method returns the "content" as a Java object. The returned object is of course dependent on the content itself. In particular, a "multipart" Part's content is always a Multipart or subclass thereof. That is, getContent() on a "multipart" type Part will always return a Multipart (or subclass) object.
Part provides the writeTo() 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 (RFC 2045, Section 2.4).
author:
   John Mani



Field Summary
final public static  StringATTACHMENT
     This part should be presented as an attachment.
final public static  StringINLINE
     This part should be presented inline.


Method Summary
public  voidaddHeader(String header_name, String header_value)
     Add this value to the existing values for this header_name.
public  EnumerationgetAllHeaders()
     Return all the headers from this part as an Enumeration of Header objects.
public  ObjectgetContent()
     Return the content as a Java object.
public  StringgetContentType()
     Returns the Content-Type of the content of this part. Returns null if the Content-Type could not be determined.
public  DataHandlergetDataHandler()
     Return a DataHandler for the content within this part.
public  StringgetDescription()
     Return a description String for this part.
public  StringgetDisposition()
     Return the disposition of this part.
public  StringgetFileName()
     Get the filename associated with this part, if possible. Useful if this part represents an "attachment" that was loaded from a file.
public  String[]getHeader(String header_name)
     Get all the headers for this header name.
public  InputStreamgetInputStream()
     Return an input stream for this part's "content".
public  intgetLineCount()
     Return the number of lines in the content of this part.
public  EnumerationgetMatchingHeaders(String[] header_names)
     Return matching headers from this part as an Enumeration of Header objects.
public  EnumerationgetNonMatchingHeaders(String[] header_names)
     Return non-matching headers from this envelope as an Enumeration of Header objects.
public  intgetSize()
     Return the size of the content of this part in bytes. Return -1 if the size cannot be determined.
public  booleanisMimeType(String mimeType)
     Is this Part of the specified MIME type? This method compares only the primaryType and subType. The parameters of the content types are ignored.
public  voidremoveHeader(String header_name)
     Remove all headers with this name.
public  voidsetContent(Object obj, String type)
     A convenience method for setting this part's content.
public  voidsetContent(Multipart mp)
     This method sets the given Multipart object as this message's content.
public  voidsetDataHandler(DataHandler dh)
     This method provides the mechanism to set this part's content.
public  voidsetDescription(String description)
     Set a description String for this part.
public  voidsetDisposition(String disposition)
     Set the disposition of this part.
public  voidsetFileName(String filename)
     Set the filename associated with this part, if possible. Useful if this part represents an "attachment" that was loaded from a file.
public  voidsetHeader(String header_name, String header_value)
     Set the value for this header_name.
public  voidsetText(String text)
     A convenience method that sets the given String as this part's content with a MIME type of "text/plain".
public  voidwriteTo(OutputStream os)
     Output a bytestream for this Part.

Field Detail
ATTACHMENT
final public static String ATTACHMENT(Code)
This part should be presented as an attachment.
See Also:   Part.getDisposition
See Also:   Part.setDisposition



INLINE
final public static String INLINE(Code)
This part should be presented inline.
See Also:   Part.getDisposition
See Also:   Part.setDisposition





Method Detail
addHeader
public void addHeader(String header_name, String header_value) throws MessagingException(Code)
Add this value to the existing values for this header_name.
Parameters:
  header_name - the name of this header
Parameters:
  header_value - the value for this header
exception:
  MessagingException -
exception:
  IllegalWriteException - if the underlying implementation does not support modification of existing values
exception:
  IllegalStateException - if this Part is obtained from a READ_ONLY folder



getAllHeaders
public Enumeration getAllHeaders() throws MessagingException(Code)
Return all the headers from this part as an Enumeration of Header objects. enumeration of Header objects
exception:
  MessagingException -



getContent
public Object getContent() throws IOException, MessagingException(Code)
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 Object
exception:
  MessagingException -
exception:
  IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
See Also:   javax.activation.DataHandler.getContent




getContentType
public String getContentType() throws MessagingException(Code)
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. The ContentType of this part
exception:
  MessagingException -
See Also:   javax.activation.DataHandler




getDataHandler
public DataHandler getDataHandler() throws MessagingException(Code)
Return a DataHandler for the content within this part. The DataHandler allows clients to operate on as well as retrieve the content. DataHandler for the content
exception:
  MessagingException -



getDescription
public String getDescription() throws MessagingException(Code)
Return a description String for this part. This typically associates some descriptive information with this part. Returns null if none is available. description of this part
exception:
  MessagingException -



getDisposition
public String getDisposition() throws MessagingException(Code)
Return the disposition of this part. The disposition describes how the part should be presented to the user. (See RFC 2183.) The return value should be considered without regard to case. For example:

 String disp = part.getDisposition();
 if (disp == null || disp.equalsIgnoreCase(Part.ATTACHMENT))
 // treat as attachment if not first part
 
disposition of this part, or null if unknown
exception:
  MessagingException -
See Also:   Part.ATTACHMENT
See Also:   Part.INLINE
See Also:   Part.getFileName



getFileName
public String getFileName() throws MessagingException(Code)
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. Filename to associate with this part



getHeader
public String[] getHeader(String header_name) throws MessagingException(Code)
Get all the headers for this header name. Returns null if no headers for this header name are available.
Parameters:
  header_name - the name of this header the value fields for all headers with this name
exception:
  MessagingException -



getInputStream
public InputStream getInputStream() throws IOException, MessagingException(Code)
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's getInputStream() method. an InputStream
exception:
  IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
exception:
  MessagingException -
See Also:   Part.getDataHandler
See Also:   javax.activation.DataHandler.getInputStream




getLineCount
public int getLineCount() throws MessagingException(Code)
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. number of lines in the content.
exception:
  MessagingException -



getMatchingHeaders
public Enumeration getMatchingHeaders(String[] header_names) throws MessagingException(Code)
Return matching headers from this part as an Enumeration of Header objects. enumeration of Header objects
exception:
  MessagingException -



getNonMatchingHeaders
public Enumeration getNonMatchingHeaders(String[] header_names) throws MessagingException(Code)
Return non-matching headers from this envelope as an Enumeration of Header objects. enumeration of Header objects
exception:
  MessagingException -



getSize
public int getSize() throws MessagingException(Code)
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. size of content in bytes
exception:
  MessagingException -




isMimeType
public boolean isMimeType(String mimeType) throws MessagingException(Code)
Is this Part of the specified MIME type? This method compares only the primaryType and subType. The parameters of the content types are ignored.

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

If the subType of mimeType is the special character '*', then the subtype is ignored during the comparison.




removeHeader
public void removeHeader(String header_name) throws MessagingException(Code)
Remove all headers with this name.
Parameters:
  header_name - the name of this header
exception:
  MessagingException -
exception:
  IllegalWriteException - if the underlying implementation does not support modification of existing values
exception:
  IllegalStateException - if this Part is obtained from a READ_ONLY folder



setContent
public void setContent(Object obj, String type) throws MessagingException(Code)
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 do setContent(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.
Parameters:
  type - MIME type of this object.
exception:
  IllegalWriteException - if the underlying implementationdoes not support modification of existing values
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder




setContent
public void setContent(Multipart mp) throws MessagingException(Code)
This method sets the given Multipart object as this message's content.
Parameters:
  mp - The multipart object that is the Message's content
exception:
  IllegalWriteException - if the underlying implementation does not support modification of existing values
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder



setDataHandler
public void setDataHandler(DataHandler dh) throws MessagingException(Code)
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.
exception:
  MessagingException -
exception:
  IllegalWriteException - if the underlying implementationdoes not support modification of existing values
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder



setDescription
public void setDescription(String description) throws MessagingException(Code)
Set a description String for this part. This typically associates some descriptive information with this part.
Parameters:
  description - description of this part
exception:
  MessagingException -
exception:
  IllegalWriteException - if the underlying implementationdoes not support modification of this header
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder



setDisposition
public void setDisposition(String disposition) throws MessagingException(Code)
Set the disposition of this part.
Parameters:
  disposition - disposition of this part
exception:
  MessagingException -
exception:
  IllegalWriteException - if the underlying implementationdoes not support modification of this header
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder
See Also:   Part.ATTACHMENT
See Also:   Part.INLINE
See Also:   Part.setFileName



setFileName
public void setFileName(String filename) throws MessagingException(Code)
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
exception:
  IllegalWriteException - if the underlying implementationdoes not support modification of this header
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder



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



setText
public void setText(String text) throws MessagingException(Code)
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.
exception:
  IllegalWriteException - if the underlying implementation does not support modification of existing values
exception:
  IllegalStateException - if this Part is obtainedfrom a READ_ONLY folder



writeTo
public void writeTo(OutputStream os) throws IOException, MessagingException(Code)
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.
exception:
  IOException - if an error occurs writing to the stream or if an error is generatedby the javax.activation layer.
exception:
  MessagingException - if an error occurs fetching thedata to be written
See Also:   javax.activation.DataHandler.writeTo




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.