|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
Objectcom.docomostar.io.IrServerObexConnection
OBEX サーバとして赤外線通信を行う場合の接続を定義します。
端末によっては、 IrDA 通信に加え IrSimple 片方向通信と IrSimple 双方向通信をサポートします。
IrSimple 通信機能では、クライアントの通信モードに応じてサーバの通信モードが決まります。
接続確立後、getCommMode()
を呼び出すことで通信モードを確認することができます。
IrSimple 片方向通信と IrSimple 双方向通信においては、 オペレーションとして PUT と DISCONNECT をサポートしています。
以下にコード例を示します。
try {
IrServerObexConnection soc;
soc = (IrServerObexConnection)Connector.open("obex:/irserver");
soc.accept(); // IrDA または IrSimple の場合、この時点でデバイスに通電して
// CONNECT オペレーションの待ち状態に入ります。
while (true) { // 複数のオペレーションを行う場合のループ
soc.receiveRequest(); // このメソッドから戻った時点で
// リクエストが到着しています。
int operation = soc.getOperation();
if (operation == ObexConnection.PUT) {
String name = soc.getName();
InputStream in = soc.openInputStream();
// 読み出し処理
in.close();
soc.sendResponse(ObexConnection.SUCCESS);
} else if (operation == ObexConnection.GET) {
String name = soc.getName();
OutputStream out = soc.openOutputStream();
// 書き込み処理
out.close();
soc.sendResponse(ObexConnection.SUCCESS);
} else if (operation == ObexConnection.DISCONNECT) {
break;
}
}
soc.close();
} catch (IOException e) {
}
| フィールドの概要 |
| メソッドの概要 | |
void |
accept()
接続要求を待ちます。 |
void |
close()
CLDC の仕様に従ってこの接続をクローズする処理を実装します。 |
int |
getCommMode() [iアプリオプションAPI]
接続確立後の通信モードを取得します。 |
int |
getContentLength()
コンテンツの長さを取得します。 |
String |
getName()
NAME ヘッダを取得します。 |
int |
getOperation()
リクエストのオペレーションを取得します。 |
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 |
receiveRequest()
リクエストの受信を完了するのを待ちます。 |
void |
sendResponse(int code)
レスポンスを送信します。 |
void |
setName(String name)
NAME ヘッダを設定します。 |
void |
setTime(long time)
TIME ヘッダを設定します。 |
void |
setType(String type)
TYPE ヘッダを設定します。 |
| クラス Object から継承したメソッド |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| メソッドの詳細 |
public void accept()
throws java.io.IOException
ServerObexConnection 内の acceptRuntimeException -
ConnectionException - ConnectionException - java.io.InterruptedIOException -
IllegalStateException -
ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
java.io.IOException -
public int getOperation()
ServerObexConnection 内の getOperationRuntimeException -
public void receiveRequest()
throws java.io.IOException
リクエストの受信を完了するのを待ちます。 このメソッドを呼び出すと、リクエストが到着するまでブロックして、 リクエストを全て受信し終わったらこのメソッドから戻ります。 このメソッドから正常に戻った場合は、 クライアントに対してレスポンスを送信するために、必ず sendResponse メソッドを呼ばなければなりません。
このメソッドを呼び出すことによって、それより前にこの接続オブジェクトから 取り出した InputStream, DataInputStream, OutputStream, DataOutputStream が無効になります。 次に InputStream, DataInputStream を取り出した時は、 このリクエストで受信したデータを読み出す入力ストリームを返します。 また、次に OutputStream, DataOutputStream を取り出した時は、 このレスポンスで送信するデータを書き込む出力ストリームを返します。
なお、IrSimple 片方向通信は実際にクライアントに対するレスポンスを送信しませんが、 このメソッドを呼び出した後に、必ず sendResponse メソッドを呼ばなければなりません。
ServerObexConnection 内の receiveRequestRuntimeException -
java.io.InterruptedIOException -
ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
public void sendResponse(int code)
throws java.io.IOException
ミニマムスペックでは、以下のレスポンスコードがサポートされています。
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
ServerObexConnection 内の sendResponsecode - レスポンスコードを指定します。
RuntimeException -
ConnectionException - IllegalArgumentException -
java.io.InterruptedIOException -
ConnectionException - ConnectionException - java.io.IOException -
java.io.IOException -
java.io.IOException -
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 -
public int getCommMode() [iアプリオプションAPI]
ObexConnection.COMM_MODE_IRDA、
ObexConnection.COMM_MODE_IRSIMPLE_UNILATERALLY、
ObexConnection.COMM_MODE_IRSIMPLE_INTERACTIVE のいずれかの通信モードが取得できます。
接続が確立されていない場合は RuntimeException またはそのサブクラスの例外が発生します。
端末によっては、IrSimple 通信機能をサポートしていない場合があります。 その場合には、例外 UnsupportedOperationException が発生します。
UnsupportedOperationException -
RuntimeException -
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
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ドコモの商標または登録商標です。
その他記載された会社名、製品名などは該当する各社の商標または登録商標です。