public final class ClientOperation extends Object implements Operation, BaseStream
Operation
interface. It will read and
write data via puts and gets.Constructor and Description |
---|
ClientOperation(int maxSize,
ClientSession p,
HeaderSet header,
boolean type)
Creates new OperationImpl to read and write data to a server
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Sends an ABORT message to the server.
|
void |
close()
Closes the connection and ends the transaction
|
boolean |
continueOperation(boolean sendEmpty,
boolean inStream)
Continues the operation since there is no data to read.
|
void |
ensureNotDone()
Verifies that additional information may be sent.
|
void |
ensureOpen()
Verifies that the connection is open and no exceptions should be thrown.
|
String |
getEncoding()
This method will always return
null |
int |
getHeaderLength() |
long |
getLength()
Returns the length of the content which is being provided.
|
int |
getMaxPacketSize() |
HeaderSet |
getReceivedHeader()
Returns the headers that have been received during the operation.
|
int |
getResponseCode()
Retrieves the response code retrieved from the server.
|
String |
getType()
Returns the type of content that the resource connected to is providing.
|
void |
noBodyHeader() |
DataInputStream |
openDataInputStream()
Open and return a data input stream for a connection.
|
DataOutputStream |
openDataOutputStream()
Open and return a data output stream for a connection.
|
InputStream |
openInputStream()
Open and return an input stream for a connection.
|
OutputStream |
openOutputStream()
Open and return an output stream for a connection.
|
void |
sendHeaders(HeaderSet headers)
Specifies the headers that should be sent in the next OBEX message that
is sent.
|
void |
setGetFinalFlag(boolean flag)
Allows to set flag which will force GET to be always sent as single packet request with
final flag set.
|
void |
streamClosed(boolean inStream)
Called when the output or input stream is closed.
|
public ClientOperation(int maxSize, ClientSession p, HeaderSet header, boolean type) throws IOException
maxSize
- the maximum packet sizep
- the parent to this objecttype
- true
if this is a get request;
false
header
- the header to set in the initial request
- Throws:
IOException
- if the an IO error occurred
public void setGetFinalFlag(boolean flag)
public void abort() throws IOException
abort
in interface Operation
IOException
- if the transaction has already ended or if an OBEX
server called this methodpublic int getResponseCode() throws IOException
ResponseCodes
interface.getResponseCode
in interface Operation
IOException
- if an error occurred in the transport layer during
the transaction; if this method is called on a
HeaderSet
object created by calling
createHeaderSet
in a ClientSession
objectResponseCodes
public String getEncoding()
null
getEncoding
in interface Operation
null
public String getType()
public long getLength()
public InputStream openInputStream() throws IOException
openInputStream
in interface Operation
IOException
- if an I/O error occurspublic DataInputStream openDataInputStream() throws IOException
openDataInputStream
in interface Operation
IOException
- if an I/O error occurspublic OutputStream openOutputStream() throws IOException
openOutputStream
in interface Operation
IOException
- if an I/O error occurspublic int getMaxPacketSize()
getMaxPacketSize
in interface Operation
public int getHeaderLength()
getHeaderLength
in interface Operation
public DataOutputStream openDataOutputStream() throws IOException
openDataOutputStream
in interface Operation
IOException
- if an I/O error occurspublic void close() throws IOException
close
in interface Operation
IOException
- if the operation has already ended or is closedpublic HeaderSet getReceivedHeader() throws IOException
getReceivedHeader
in interface Operation
Operation
IOException
- if this Operation
has been closedpublic void sendHeaders(HeaderSet headers) throws IOException
sendHeaders
in interface Operation
headers
- the headers to send in the next messageIOException
- if this Operation
has been closed or the
transaction has ended and no further messages will be exchangedIllegalArgumentException
- if headers
was not created
by a call to ServerRequestHandler.createHeaderSet()
NullPointerException
- if headers
is null
public void ensureNotDone() throws IOException
ensureNotDone
in interface BaseStream
IOException
- if the operation is completedpublic void ensureOpen() throws IOException
ensureOpen
in interface BaseStream
IOException
- if an exception needs to be thrownpublic boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException
continueOperation
in interface BaseStream
sendEmpty
- true
if the operation should send an empty
packet or not send anything if there is no data to sendinStream
- true
if the stream is input stream or is
output streamtrue
if the operation was completed;
false
if no operation took placeIOException
- if an IO error occurspublic void streamClosed(boolean inStream) throws IOException
streamClosed
in interface BaseStream
inStream
- true
if the input stream is closed;
false
if the output stream is closedIOException
- if an IO error occurspublic void noBodyHeader()
noBodyHeader
in interface Operation