|
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | ||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | ||||||||
Objectcom.docomostar.io.IrClientObexConnection
public class IrClientObexConnection
OBEX クライアントとして赤外線通信を行う場合の接続を定義します。
IrDA 通信のコード例については ClientObexConnection のクラス説明を参照してください。
端末によっては、IrDA 通信に加え IrSimple 片方向通信と IrSimple 双方向通信をサポートします。
IrSimple 通信機能では、connect(int) によって通信モードを指定できます。
接続確立後、getCommMode()を呼び出すことで通信モードを確認することができます。
なお、IrDA 通信のみサポートしているサーバに対して、IrSimple 双方向通信を試みた場合には、
IrSimple 通信機能の IrDA 通信互換により IrDA 通信で接続が確立されます。
IrSimple 片方向通信と IrSimple 双方向通信においては、 オペレーションとして PUT のみをサポートしています。
以下に IrSimple 片方向通信を行う場合のコード例を示します。
try {
IrClientObexConnection coc;
coc = (IrClientObexConnection)Connector.open("obex:/irclient");
coc.connect(ClientObexConnection.COMM_MODE_IRSIMPLE_UNILATERALLY); // この時点でデバイスに通電して
// CONNECT オペレーションを発行します。
// Server側からの接続要求応答がない為、
// 接続要求応答の受信が完了するまで待ちません。
while (true) { // 複数のオペレーションを行う場合のループ。
// ループの中で PUT のみ指定できます。
coc.setOperation(ObexConnection.PUT);
coc.setName("foo");
OutputStream out = coc.openOutputStream();
// 書き込み処理
out.close();
coc.sendRequest(); // この時点で PUT オペレーションを送信します。
// Server側からのレスポンスがない為、レスポンスは受け取りません。
int response = coc.getResponseCode(); // 必ずレスポンスコード「ObexConnection.SUCCESS」が返ります。
}
coc.close(); // IrSimple の場合、この時点で DISCONNECT オペレーションを
// 発行して、デバイスをオフにします。
} catch (IOException e) {
}
以下に IrSimple 双方向通信を行う場合のコード例を示します。
try {
IrClientObexConnection coc;
coc = (IrClientObexConnection)Connector.open("obex:/irclient");
coc.connect(ClientObexConnection.COMM_MODE_IRSIMPLE_INTERACTIVE); // この時点でデバイスに通電して
// CONNECT オペレーションを発行します。
// Server側からの接続要求応答の受信が完了するまで待ちます。
while (true) { // 複数のオペレーションを行う場合のループ。
// ループの中で PUT のみ指定できます。
coc.setOperation(ObexConnection.PUT);
coc.setName("foo");
OutputStream out = coc.openOutputStream();
// 書き込み処理
out.close();
coc.sendRequest(); // この時点で PUT オペレーションを送信して、レスポンスを受け取ります。
int response = coc.getResponseCode();
}
coc.close(); // IrSimple の場合、この時点で DISCONNECT オペレーションを
// 発行して、デバイスをオフにします。
} catch (IOException e) {
}
| フィールドの概要 |
|---|
| メソッドの概要 | |
|---|---|
void |
close()
CLDC の仕様に従ってこの接続をクローズする処理を実装します。 |
void |
connect()
接続を確立します。 |
void |
connect(int mode) [iアプリオプションAPI]
通信モードに対応した接続を確立します。 |
int |
getCommMode() [iアプリオプションAPI]
接続確立後の通信モードを取得します。 |
int |
getContentLength()
コンテンツの長さを取得します。 |
String |
getName()
NAME ヘッダを取得します。 |
int |
getResponseCode()
レスポンスコードを取得します。 |
long |
getTime()
TIME ヘッダを取得します。 |
String |
getType()
TYPE ヘッダを取得します。 |
java.io.DataInputStream |
openDataInputStream()
CLDC の仕様に従って DataInputStream オブジェクトを返す処理を実装します。 |
java.io.DataOutputStream |
openDataOutputStream()
CLDC の仕様に従って DataOutputStream オブジェクトを返す処理を実装します。 |
java.io.InputStream |
openInputStream()
CLDC の仕様に従って InputStream オブジェクトを返す処理を実装します。 |
java.io.OutputStream |
openOutputStream()
CLDC の仕様に従って OutputStream オブジェクトを返す処理を実装します。 |
void |
sendRequest()
リクエストを送信して、レスポンスの受信を完了するまで待ちます。 |
void |
setName(String name)
NAME ヘッダを設定します。 |
void |
setOperation(int operation)
オペレーションコードを設定します。 |
void |
setTime(long time)
TIME ヘッダを設定します。 |
void |
setType(String type)
TYPE ヘッダを設定します。 |
| クラス Object から継承されたメソッド |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| メソッドの詳細 |
|---|
public void connect()
throws java.io.IOException
ClientObexConnection 内の connectRuntimeException -
ConnectionException - ConnectionException - java.io.InterruptedIOException -
IllegalStateException -
ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
java.io.IOException -
public void connect(int mode)
throws java.io.IOException [iアプリオプションAPI]
以下の通信モードを指定できます。
ObexConnection.COMM_MODE_IRDA
ObexConnection.COMM_MODE_IRSIMPLE_INTERACTIVE
ObexConnection.COMM_MODE_IRSIMPLE_UNILATERALLY
ObexConnection.COMM_MODE_IRDA を指定した場合は、IrDA 通信を試みます。
connect() の振る舞いと同じになります。
ObexConnection.COMM_MODE_IRSIMPLE_INTERACTIVE を指定した場合は、IrSimple 双方向通信を試みます。
サーバが IrDA 通信のみサポートしている場合、
IrSimple 通信機能の IrDA 通信互換により IrDA 通信で接続が確立されます。
ObexConnection.COMM_MODE_IRSIMPLE_UNILATERALLY を指定した場合は、IrSimple 片方向通信を試みます。
IrSimple 片方向通信においては、サーバからレスポンスが送信されないため、
サーバとの接続の確立を待たずにこのメソッドから戻ります。
このため、このメソッドで ConnectionException(TIMEOUT) が発生することはありません。
接続確立後、getCommMode()
を呼び出すことで実際の通信モードを確認することができます。
端末によっては、IrSimple 通信機能をサポートしていない場合があります。 その場合には、例外 UnsupportedOperationException が発生します。
mode - 通信モード
UnsupportedOperationException -
IllegalArgumentException -
RuntimeException -
ConnectionException - ConnectionException - java.io.InterruptedIOException -
IllegalStateException -
ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
java.io.IOException -
public int getCommMode() [iアプリオプションAPI]
ObexConnection.COMM_MODE_IRDA、
ObexConnection.COMM_MODE_IRSIMPLE_UNILATERALLY、
ObexConnection.COMM_MODE_IRSIMPLE_INTERACTIVE のいずれかの通信モードが取得できます。
接続が確立されていない場合は RuntimeException またはそのサブクラスの例外が発生します。
端末によっては、IrSimple 通信機能をサポートしていない場合があります。 その場合には、例外 UnsupportedOperationException が発生します。
UnsupportedOperationException -
RuntimeException -
public int getResponseCode()
レスポンスコードを取得します。 直前に実行した sendRequest メソッドにおいて受信した レスポンスのレスポンスコードを返します。
1つのデータを複数のパケットに分割して受信した場合、 一番最後に受信したパケットのレスポンスコードを返します。
IrSimple 片方向通信の場合、戻り値として常に ObexConnection.SUCCESS を返します。
ただし、IrSimple 片方向通信においては、サーバからレスポンスが送信されないため、
ObexConnection.SUCCESS は実際のレスポンスコードではありません。
ミニマムスペックでは、 以下のレスポンスコードについて取得できることが保証されています。
ObexConnection.CONTINUE
ObexConnection.SUCCESS
ObexConnection.NON_AUTHORITATIVE_INFORMATION
ObexConnection.UNAUTHORIZED
ObexConnection.FORBIDDEN
ObexConnection.NOT_FOUND
ObexConnection.REQUEST_TIME_OUT
ObexConnection.CONFLICT
ObexConnection.NOT_IMPLEMENTED
ObexConnection.BAD_REQUEST
ObexConnection.DATABASE_FULL
ObexConnection.DATABASE_LOCKED
ClientObexConnection 内の getResponseCodeRuntimeException -
public void sendRequest()
throws java.io.IOException
このメソッドを呼び出すことによって、それより前にこの接続オブジェクトから 取り出した InputStream, DataInputStream, OutputStream, DataOutputStream が無効になります。 次に InputStream, DataInputStream を取り出した時は、 このオペレーションで受信したデータを読み出す入力ストリームを返します。 また、次に OutputStream, DataOutputStream を取り出した時は、 次のオペレーションで送信するデータを書き込む出力ストリームを返します。
IrSimple 片方向通信の場合、リクエストを全て送信し終わったらこのメソッドから戻ります。 IrSimple 片方向通信においては、サーバからレスポンスが送信されないため、 レスポンスの受信を待つことはありません。 このため、このメソッドで ConnectionException(TIMEOUT)、ConnectionException(OBEX_ERROR)が発生することはありません。
ClientObexConnection 内の sendRequestRuntimeException -
ConnectionException - java.io.InterruptedIOException -
ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
java.io.IOException -
ConnectionException - public void setOperation(int operation)
IrSimple 片方向通信と IrSimple 双方向通信で設定できるオペレーションは "PUT" のみです。
ClientObexConnection 内の setOperationoperation - オペレーションコードを指定します。
RuntimeException -
IllegalArgumentException -
IllegalArgumentException -
public int getContentLength()
ObexConnection 内の getContentLengthRuntimeException -
public String getName()
ObexConnection 内の getNameRuntimeException -
public long getTime()
ObexConnection 内の getTimeRuntimeException -
public String getType()
ObexConnection 内の getTypeRuntimeException -
public void setName(String name)
ObexConnection 内の setNamename - NAME ヘッダに設定する文字列を指定します。
RuntimeException -
IllegalArgumentException -
public void setTime(long time)
ObexConnection 内の setTimetime - 日付を表す整数値を指定します。
RuntimeException -
public void setType(String type)
ObexConnection 内の setTypetype - TYPE ヘッダに設定する文字列を指定します。
RuntimeException -
IllegalArgumentException -
public java.io.DataInputStream openDataInputStream()
throws java.io.IOException
javax.microedition.io.InputConnection 内の openDataInputStreamRuntimeException -
ConnectionException - ConnectionException - java.io.IOException -
public java.io.InputStream openInputStream()
throws java.io.IOException
javax.microedition.io.InputConnection 内の openInputStreamRuntimeException -
ConnectionException - ConnectionException - java.io.IOException -
public void close()
throws java.io.IOException
javax.microedition.io.Connection 内の closejava.io.IOException -
public java.io.DataOutputStream openDataOutputStream()
throws java.io.IOException
javax.microedition.io.OutputConnection 内の openDataOutputStreamRuntimeException -
ConnectionException - ConnectionException - java.io.IOException -
public java.io.OutputStream openOutputStream()
throws java.io.IOException
javax.microedition.io.OutputConnection 内の openOutputStreamRuntimeException -
ConnectionException - ConnectionException - java.io.IOException -
|
|||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | ||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | ||||||||
NTT DOCOMO,INC.
本製品または文書は著作権法により保護されており、その使用、複製、再頒布および逆コンパイルを制限するライセンスのもとにおいて頒布されます。NTTドコモ(その他に許諾者がある場合は当該許諾者も含めて)の書面による事前の許可なく、本製品および関連する文書のいかなる部分も、いかなる方法によっても複製することが禁じられます。フォントを含む第三者のソフトウェアは、著作権法により保護されており、その提供者からライセンスを受けているものです。
Sun、Sun Microsystems、Java、J2MEおよびJ2SEは、米国およびその他の国における米国 Sun Microsystems,Inc.の商標または登録商標です。サンのロゴマークは、米国 Sun Microsystems, Inc.の登録商標です。
FeliCaは、ソニー株式会社が開発した非接触ICカードの技術方式です。FeliCaは、ソニー株式会社の登録商標です。
「iモード」、「iアプリ/アイアプリ」、「i-αppli」ロゴ、「DoJa」はNTTドコモの商標または登録商標です。
その他記載された会社名、製品名などは該当する各社の商標または登録商標です。