ExchangerState.java

/*
 * Copyright © 2012 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */ 
package com.nokia.example.bcexchanger.comm;

import javax.obex.Operation;

/**
 * 
 * This is the abstract base class for the all states of the
 * communication state machine. Each state is implementing methods
 * which are can be executed in that particular case.
 * 
 * Classes IdleState, InquiryState, ServiceDiscoveryState,
 * ReceiveState and SendState inherit from this class
 * 
 * @see Design patterns: State
 * 
 */
public abstract class ExchangerState {

    protected ExchangerStateParent parent;

    /**
     * Implements OBEX GET command
     * <p>
     * Implements server handling of the OBEX GET command
     * 
     * @param op -
     *          OBEX operation class
     * @return - OBEX response code
     * @see javax.obex.ServerRequestHandler
     */
    abstract public int onGet(Operation op);

    /**
     * Implements OBEX PUT command
     * <p>
     * Implements server handling of the OBEX PUT command
     * 
     * @param op -
     *          OBEX operation class
     * @return - OBEX response code
     * @see javax.obex.ServerRequestHandler
     */
    abstract public int onPut(Operation op);

    /**
     * Implements actions related to starting sending process
     * <p>
     * Implements reaction of the state on command to start sending
     * process
     * 
     * @exception Exception -
     *              if any immediate error occur
     * @see example.BCExchanger.comm.ExchangerComm
     */
    abstract public void startSending(int oper) throws Exception;

    /**
     * Implements actions related to canceling sending process
     * <p>
     * Implements reaction of the state on command to cancel sending
     * process
     * 
     * @see example.BCExchanger.comm.ExchangerComm
     */
    abstract public void cancelSending();

    /**
     * Constructor
     * 
     * @param -
     *          _parent - the class which nests the current state of the
     *          communication machine
     */
    public ExchangerState(ExchangerStateParent _parent) {
        parent = _parent;
    }
}