IT. Expert System.

Android Reference

ServerOperation


javax.obex

Class ServerOperation

  • All Implemented Interfaces:
    BaseStream, Operation


    public final class ServerOperation
    extends Object
    implements Operation, BaseStream
    This class implements the Operation interface for server side connections.

    Request Codes There are four different request codes that are in this class. 0x02 is a PUT request that signals that the request is not complete and requires an additional OBEX packet. 0x82 is a PUT request that says that request is complete. In this case, the server can begin sending the response. The 0x03 is a GET request that signals that the request is not finished. When the server receives a 0x83, the client is signaling the server that it is done with its request. TODO: Extend the ClientOperation and reuse the methods defined TODO: in that class.

    • Field Detail

      • isAborted

        public boolean isAborted
      • requestHeader

        public HeaderSet requestHeader
      • finalBitSet

        public boolean finalBitSet
    • Constructor Detail

      • ServerOperation

        public ServerOperation(ServerSession p,
                       InputStream in,
                       int request,
                       int maxSize,
                       ServerRequestHandler listen)
                        throws IOException
        Creates new ServerOperation
        Parameters:
        p - the parent that created this object
        in - the input stream to read from
        out - the output stream to write to
        request - the initial request that was received from the client
        maxSize - the max packet size that the client will accept
        listen - the listener that is responding to the request
        Throws:
        IOException - if an IO error occurs
    • Method Detail

      • isValidBody

        public boolean isValidBody()
      • continueOperation

        public boolean continueOperation(boolean sendEmpty,
                                boolean inStream)
                                  throws IOException
        Determines if the operation should continue or should wait. If it should continue, this method will continue the operation.
        Specified by:
        continueOperation in interface BaseStream
        Parameters:
        sendEmpty - if true then this will continue the operation even if no headers will be sent; if false then this method will only continue the operation if there are headers to send
        inStream - iftrue the stream is input stream, otherwise output stream
        Returns:
        true if the operation was completed; false if no operation took place
        Throws:
        IOException - if an IO error occurs
      • sendReply

        public boolean sendReply(int type)
                          throws IOException
        Sends a reply to the client. If the reply is a OBEX_HTTP_CONTINUE, it will wait for a response from the client before ending.
        Parameters:
        type - the response code to send back to the client
        Returns:
        true if the final bit was not set on the reply; false if no reply was received because the operation ended, an abort was received, or the final bit was set in the reply
        Throws:
        IOException - if an IO error occurs
      • abort

        public void abort()
                   throws IOException
        Sends an ABORT message to the server. By calling this method, the corresponding input and output streams will be closed along with this object.
        Specified by:
        abort in interface Operation
        Throws:
        IOException - if the transaction has already ended or if an OBEX server called this method
      • getReceivedHeader

        public HeaderSet getReceivedHeader()
                                    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.
        Specified by:
        getReceivedHeader in interface Operation
        Returns:
        the headers received during this Operation
        Throws:
        IOException - if this Operation has been closed
      • sendHeaders

        public void sendHeaders(HeaderSet headers)
                         throws IOException
        Specifies the headers that should be sent in the next OBEX message that is sent.
        Specified by:
        sendHeaders in interface Operation
        Parameters:
        headers - the headers to send in the next message
        Throws:
        IOException - if this Operation has been closed or the transaction has ended and no further messages will be exchanged
        IllegalArgumentException - if headers was not created by a call to ServerRequestHandler.createHeaderSet()
      • getResponseCode

        public int getResponseCode()
                            throws IOException
        Retrieves the response code retrieved from the server. Response codes are defined in the ResponseCodes interface.
        Specified by:
        getResponseCode in interface Operation
        Returns:
        the response code retrieved from the server
        Throws:
        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 object; if this is called from a server
        See Also:
        ResponseCodes
      • getType

        public String getType()
        Returns the type of content that the resource connected to is providing. E.g. if the connection is via HTTP, then the value of the content-type header field is returned.
        Specified by:
        getType in interface Operation
        Returns:
        the content type of the resource that the URL references, or null if not known
      • getLength

        public long getLength()
        Returns the length of the content which is being provided. E.g. if the connection is via HTTP, then the value of the content-length header field is returned.
        Specified by:
        getLength in interface Operation
        Returns:
        the content length of the resource that this connection's URL references, or -1 if the content length is not known
      • close

        public void close()
                   throws IOException
        Closes the connection and ends the transaction
        Specified by:
        close in interface Operation
        Throws:
        IOException - if the operation has already ended or is closed
      • ensureOpen

        public void ensureOpen()
                        throws IOException
        Verifies that the connection is open and no exceptions should be thrown.
        Specified by:
        ensureOpen in interface BaseStream
        Throws:
        IOException - if an exception needs to be thrown
      • ensureNotDone

        public void ensureNotDone()
                           throws IOException
        Verifies that additional information may be sent. In other words, the operation is not done.

        Included to implement the BaseStream interface only. It does not do anything on the server side since the operation of the Operation object is not done until after the handler returns from its method.

        Specified by:
        ensureNotDone in interface BaseStream
        Throws:
        IOException - if the operation is completed
      • streamClosed

        public void streamClosed(boolean inStream)
                          throws IOException
        Called when the output or input stream is closed. It does not do anything on the server side since the operation of the Operation object is not done until after the handler returns from its method.
        Specified by:
        streamClosed in interface BaseStream
        Parameters:
        inStream - true if the input stream is closed; false if the output stream is closed
        Throws:
        IOException - if an IO error occurs


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 572 / 158670800. Delta: 0.03689 с