My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/**
* BlueCove - Java library for Bluetooth
*
* Java docs licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
* (c) Copyright 2001, 2002 Motorola, Inc. ALL RIGHTS RESERVED.
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @version $Id$
*/
package javax.obex;

import java.io.IOException;

import javax.microedition.io.ContentConnection;

/**
* The <code>Operation</code> interface provides ways to manipulate a single
* OBEX PUT or GET operation. The implementation of this interface sends OBEX
* packets as they are built. If during the operation the peer in the operation
* ends the operation, an <code>IOException</code> is thrown on the next read
* from the input stream, write to the output stream, or call to
* <code>sendHeaders()</code>.
* <P>
* <STRONG>Definition of methods inherited from <code>ContentConnection</code>
* </STRONG>
* <P>
* <code>getEncoding()</code> will always return <code>null</code>. <BR>
* <code>getLength()</code> will return the length specified by the OBEX Length
* header or -1 if the OBEX Length header was not included. <BR>
* <code>getType()</code> will return the value specified in the OBEX Type
* header or <code>null</code> if the OBEX Type header was not included.<BR>
* <P>
* <STRONG>How Headers are Handled</STRONG>
* <P>
* As headers are received, they may be retrieved through the
* <code>getReceivedHeaders()</code> method. If new headers are set during the
* operation, the new headers will be sent during the next packet exchange.
* <P>
* <STRONG>PUT example</STRONG>
* <P>
*
* <pre>
* void putObjectViaOBEX(ClientSession conn, HeaderSet head, byte[] obj) throws IOException {
*
* // Include the length header
* head.setHeader(head.LENGTH, new Long(obj.length));
*
* // Initiate the PUT request
* Operation op = conn.put(head);
*
* // Open the output stream to put the object to it
* DataOutputStream out = op.openDataOutputStream();
*
* // Send the object to the server
* out.write(obj);
*
* // End the transaction
* out.close();
* op.close();
* }
* </pre>
*
* <P>
* <STRONG>GET example</STRONG>
* <P>
*
* <pre>
* byte[] getObjectViaOBEX(ClientSession conn, HeaderSet head) throws IOException {
*
* // Send the initial GET request to the server
* Operation op = conn.get(head);
*
* // Retrieve the length of the object being sent back
* int length = op.getLength();
*
* // Create space for the object
* byte[] obj = new byte[length];
*
* // Get the object from the input stream
* DataInputStream in = op.openDataInputStream();
* in.read(obj);
*
* // End the transaction
* in.close();
* op.close();
*
* return obj;
* }
* </pre>
*
* <H3>Client PUT Operation Flow</H3>
* For PUT operations, a call to <code>close()</code> the
* <code>OutputStream</code> returned from <code>openOutputStream()</code> or
* <code>openDataOutputStream()</code> will signal that the request is done. (In
* OBEX terms, the End-Of-Body header should be sent and the final bit in the
* request will be set.) At this point, the reply from the server may begin to
* be processed. A call to <code>getResponseCode()</code> will do an implicit
* close on the <code>OutputStream</code> and therefore signal that the request
* is done.
* <H3>Client GET Operation Flow</H3>
* For GET operation, a call to <code>openInputStream()</code> or
* <code>openDataInputStream()</code> signals that the request is complete. (In
* OBEX terms, the final bit in the request is set.) A call to
* <code>getResponseCode()</code> causes an implicit close on the
* <code>OutputStream</code> and therefore signal that the request is done.
*
*/
public interface Operation extends ContentConnection {

/**
* Sends an ABORT message to the server. By calling this method, the
* corresponding input and output streams will be closed along with this
* object. No headers are sent in the abort request. This will end the
* operation since <code>close()</code> will be called by this method.
*
* @exception IOException
* if the transaction has already ended or if an OBEX server
* calls this method
*/
public void abort() throws IOException;

/**
* Returns the headers that have been received during the operation.
* Modifying the object returned has no effect on the headers that are sent
* or retrieved.
*
* @return the headers received during this <code>Operation</code>
*
* @exception IOException
* if this <code>Operation</code> has been closed
*/
public HeaderSet getReceivedHeaders() throws IOException;

/**
* Specifies the headers that should be sent in the next OBEX message that
* is sent.
*
* @param headers
* the headers to send in the next message
*
* @exception IOException
* if this <code>Operation</code> has been closed or the
* transaction has ended and no further messages will be
* exchanged
*
* @exception IllegalArgumentException
* if <code>headers</code> was not created by a call to
* <code>ServerRequestHandler.createHeaderSet()</code> or
* <code>ClientSession.createHeaderSet()</code>
*
* @exception NullPointerException
* if <code>headers</code> if <code>null</code>
*/
public void sendHeaders(HeaderSet headers) throws IOException;

/**
* Returns the response code received from the server. Response codes are
* defined in the <code>ResponseCodes</code> class. The OBEX response code
* of CONTINUE (0x10 or 0x90) must never be returned from this method.
*
* @see ResponseCodes
*
* @return the response code retrieved from the server
*
* @exception IOException
* if an error occurred in the transport layer during the
* transaction; if this Operation object has been closed; if
* this object was created by an OBEX server
*/
public int getResponseCode() throws IOException;
}

Change log

r2531 by skarzhevskyy on Dec 9, 2008   Diff
sync package javax.obex javadocs with
JSR-82 1.1.1
Go to: 
Project members, sign in to write a code review

Older revisions

r2471 by skarzhevskyy on Nov 30, 2008   Diff
Change license to Apache License,
Version 2.0, Update headers
r2408 by skarzhevskyy on Oct 9, 2008   Diff
organize product to modules
r549 by skarzhevskyy on Jun 22, 2007   Diff
Java docs licensed under the Apache
License, Version 2.0
(c) Copyright 2001, 2002 Motorola,
Inc.
All revisions of this file

File info

Size: 7126 bytes, 188 lines

File properties

svn:mime-type
text/plain
svn:eol-style
native
svn:keywords
Date Author Id Revision
Powered by Google Project Hosting