javax.mail.internet
クラス MimeMultipart

java.lang.Object
  上位を拡張 javax.mail.Multipart
      上位を拡張 javax.mail.internet.MimeMultipart

public final class MimeMultipart
extends Multipart

MimeMultipart クラスは、multipart データについて MIME 規則を使用する抽象 Multipart クラスの実装です。

MimeMultipart は、プライマリタイプが "multipart" である MimePart から (パートの getContent() メソッドを呼び出す事によって) 取得するか、 新しい MimeMessage の作成の一部としてクライアントにより作成できます。

デフォルトの multipart サブタイプは "mixed" です。 他の multipart サブタイプである "alternative" や "related" 等は、 MimeMultipart のサブクラスとして実装し、 そのタイプの multipart コンテンツの補足的なセマンティクスを実装するメソッドを追加する事によって実装できます。 この目的は、サービスプロバイダ、メール JavaBean 開発者、 及びメールクライアントが多数の同様なサブクラスと Command Beans を作成し、 JavaBeans Activation Framework にインストールして、 任意の JavaMail 実装とクライアントがこれらのクラスを透過的に見つけ、使用できるようにする事です。 従って、MIME multipart ハンドラは他の任意のハンドラと同様に扱われ、 multipart ハンドラの提供処理を JavaMail API から分離します。 こうした補足的な MimeMultipart サブクラスがない場合、 MIME multipart データの全てのサブタイプは MimeMultipart オブジェクトとして現れます。

アプリケーションは、MimeMultipart(String Subtype) コンストラクタを使用する事で、 任意のサブタイプの MIME multipart オブジェクトを直接作成できます。 例えば、"multipart/alternative" オブジェクトを作成するには new MimeMultipart("alternative") を使用します。

In the current implementation, the mail.mime.multipart.ignoremissingendboundary System property may be set to false to cause a MessagingException to be thrown if the multipart data does not end with the required end boundary line. If this property is set to true or not set, missing end boundaries are not considered an error and the final body part ends at the end of the data.


フィールドの概要
protected  DataSource ds
          InputStream を供給する DataSource です。
protected  boolean parsed
          InputStream からのデータを構文解析したかどうかを示します。
 
クラス javax.mail.Multipart から継承されたフィールド
contentType, parent, parts
 
コンストラクタの概要
MimeMultipart()
          デフォルトのコンストラクタです。
MimeMultipart(String subtype)
          指定されたサブタイプの MimeMultipart オブジェクトを構築します。
 
メソッドの概要
protected  InternetHeaders createInternetHeaders(InputStream is)
          指定された InputStream からヘッダをロードする InternetHeaders オブジェクトを作成し、返します。
protected  MimeBodyPart createMimeBodyPart(InputStream is)
          InputStream から構文解析される本文部分を表す MimeBodyPart オブジェクトを作成し、返します。
protected  MimeBodyPart createMimeBodyPart(InternetHeaders headers, byte[] content)
          InputStream から構文解析される本文部分を表す MimeBodyPart オブジェクトを作成し、返します。
 BodyPart getBodyPart(int index)
          指定された BodyPart を取得します。
 BodyPart getBodyPart(String CID)
          指定された ContentID (CID) により参照される MimeBodyPart を取得します。
 int getCount()
          含まれる BodyPart オブジェクトの数を返します。
 String getPreamble()
          Get the preamble text, if any, that appears before the first body part of this multipart.
 boolean isComplete()
          Return true if the final boundary line for this multipart was seen.
protected  void parse()
          DataSource からの InputStream を構文解析し、適切な MimeBodyParts を構築します。
 void setPreamble(String preamble)
          Set the preamble text to be included before the first body part.
 void setSubType(String subtype)
          サブタイプを設定します。
protected  void updateHeaders()
          ヘッダを更新します。
 void writeTo(OutputStream os)
          全てのパートを通じて繰り返し、境界で区切られた各 Mime パートを出力します。
 
クラス javax.mail.Multipart から継承されたメソッド
addBodyPart, addBodyPart, getContentType, getParent, removeBodyPart, removeBodyPart, setMultipartDataSource, setParent
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

ds

protected DataSource ds
InputStream を供給する DataSource です。


parsed

protected boolean parsed
InputStream からのデータを構文解析したかどうかを示します。デフォルトは true です。 コンストラクタに構文解析が必要な InputStream を持つ DataSource が指定されている場合は、false に設定します。

コンストラクタの詳細

MimeMultipart

public MimeMultipart()
デフォルトのコンストラクタです。空の MimeMultipart オブジェクトが作成されます。 コンテンツ形式は "multipart/mixed" に設定されます。一意の境界文字列が生成され、 この文字列は contentType フィールドの "boundary" パラメータとして設定されます。

MimeBodyParts を後で追加することができます。


MimeMultipart

public MimeMultipart(String subtype)
指定されたサブタイプの MimeMultipart オブジェクトを構築します。一意の境界文字列が生成され、 この文字列は contentType フィールドの "boundary" パラメータとして設定されます。

MimeBodyParts を後で追加することができます。

メソッドの詳細

setSubType

public void setSubType(String subtype)
                throws MessagingException
サブタイプを設定します。 このメソッドはクライアントが作成した新しい MimeMultipart オブジェクト上で呼び出されなければなりません。 こうした multipart オブジェクトのデフォルトのサブタイプは "mixed" です。

パラメータ:
subtype - Subtype
例外:
MessagingException

getCount

public int getCount()
             throws MessagingException
含まれる BodyPart オブジェクトの数を返します。

オーバーライド:
クラス Multipart 内の getCount
戻り値:
パートの数
例外:
MessagingException
関連項目:
Multipart.parts

getBodyPart

public BodyPart getBodyPart(int index)
                     throws MessagingException
指定された BodyPart を取得します。BodyParts には 0 から始まる番号が付けられます。

オーバーライド:
クラス Multipart 内の getBodyPart
パラメータ:
index - 要求する BodyPart のインデックス
戻り値:
Part
例外:
MessagingException - 要求された BodyPart が存在しない場合

getBodyPart

public BodyPart getBodyPart(String CID)
                     throws MessagingException
指定された ContentID (CID) により参照される MimeBodyPart を取得します。 パートが見つからない場合は null を返します。

パラメータ:
CID - 要求するパートの ContentID
戻り値:
Part
例外:
MessagingException

isComplete

public boolean isComplete()
                   throws MessagingException
Return true if the final boundary line for this multipart was seen. When parsing multipart content, this class will (by default) terminate parsing with no error if the end of input is reached before seeing the final multipart boundary line. In such a case, this method will return false. (If the System property "mail.mime.multipart.ignoremissingendboundary" is set to false, parsing such a message will instead throw a MessagingException.)

戻り値:
true if the final boundary line was seen
例外:
MessagingException
導入されたバージョン:
JavaMail 1.4

getPreamble

public String getPreamble()
                   throws MessagingException
Get the preamble text, if any, that appears before the first body part of this multipart. Some protocols, such as IMAP, will not allow access to the preamble text.

戻り値:
the preamble text, or null if no preamble
例外:
MessagingException
導入されたバージョン:
JavaMail 1.4

setPreamble

public void setPreamble(String preamble)
                 throws MessagingException
Set the preamble text to be included before the first body part. Applications should generally not include any preamble text. In some cases it may be helpful to include preamble text with instructions for users of pre-MIME software. The preamble text should be complete lines, including newlines.

パラメータ:
preamble - the preamble text
例外:
MessagingException
導入されたバージョン:
JavaMail 1.4

updateHeaders

protected void updateHeaders()
                      throws MessagingException
ヘッダを更新します。ここでのデフォルトの実装は、 子の BodyParts のそれぞれで updateHeaders メソッドを呼び出すだけです。

新しい空の MimeMultipart オブジェクトが作成される場合、 境界パラメータは既に設定されている事に注意して下さい。

このメソッドは、この Multipart を含む Message オブジェクト上で saveChanges メソッドが呼び出される時に呼び出されます。 これは一般に Message 送信処理の一部として行われますが、 クライアントから何度でも呼び出す事が可能である事に注意して下さい。 従って、ヘッダ更新処理が特定の MimeMultipart サブクラスにとって負荷が重い場合、 内部状態が実際に変化したかどうかを追跡し、必要な場合にのみヘッダ更新を行う事もあります。

例外:
MessagingException

writeTo

public void writeTo(OutputStream os)
             throws IOException,
                    MessagingException
全てのパートを通じて繰り返し、境界で区切られた各 Mime パートを出力します。

定義:
クラス Multipart 内の writeTo
例外:
IOException - IO 関連の例外が発生した場合
MessagingException

parse

protected void parse()
              throws MessagingException
DataSource からの InputStream を構文解析し、適切な MimeBodyParts を構築します。 parsed フラグは true に設定されます。 呼ばれた時に true の場合は何も行われません。 このメソッドは本文部分のデータが必要な他の全てのメソッドにより呼び出され、 データが構文解析済みである事を保証します。

例外:
MessagingException
導入されたバージョン:
JavaMail 1.2

createInternetHeaders

protected InternetHeaders createInternetHeaders(InputStream is)
                                         throws MessagingException
指定された InputStream からヘッダをロードする InternetHeaders オブジェクトを作成し、返します。 必要であれば、サブクラスはこのメソッドをオーバーライドし、InternetHeaders のサブクラスを返す事ができます。 この実装は単に InternetHeaders オブジェクトを構築し、返します。

パラメータ:
is - ヘッダ読み込み元の InputStream
例外:
MessagingException
導入されたバージョン:
JavaMail 1.2

createMimeBodyPart

protected MimeBodyPart createMimeBodyPart(InternetHeaders headers,
                                          byte[] content)
InputStream から構文解析される本文部分を表す MimeBodyPart オブジェクトを作成し、返します。 必要であれば、サブクラスはこのメソッドをオーバーライドし、MimeBodyPart のサブクラスを返す事ができます。 この実装は単に MimeBodyPart オブジェクトを構築し、返します。

パラメータ:
headers - 本文部分のヘッダ
content - 本文部分のコンテンツ
例外:
MessagingException
導入されたバージョン:
JavaMail 1.2

createMimeBodyPart

protected MimeBodyPart createMimeBodyPart(InputStream is)
                                   throws MessagingException
InputStream から構文解析される本文部分を表す MimeBodyPart オブジェクトを作成し、返します。 必要であれば、サブクラスはこのメソッドをオーバーライドし、MimeBodyPart のサブクラスを返す事ができます。 この実装は単に MimeBodyPart オブジェクトを構築し、返します。

パラメータ:
is - 本文部分を含む InputStream
例外:
MessagingException
導入されたバージョン:
JavaMail 1.2