001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.statemachine.context;
021
022import org.apache.mina.statemachine.State;
023import org.apache.mina.statemachine.StateMachine;
024
025/**
026 * {@link StateContext} objects are used to store the current {@link State} and
027 * any application specific attributes for a specific client of a 
028 * {@link StateMachine}. Since {@link StateMachine}s are singletons and shared
029 * by all clients using the {@link StateMachine} this is where client specific
030 * data needs to be stored.
031 *
032 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
033 */
034public interface StateContext {
035    /**
036     * @return the current {@link State}. This is only meant for internal use.
037     */
038    State getCurrentState();
039
040    /**
041     * Sets the current {@link State}. This is only meant for internal use.
042     * Don't call it directly!
043     * 
044     * @param state the new current {@link State}.
045     */
046    void setCurrentState(State state);
047
048    /**
049     * Returns the value of the attribute with the specified key or 
050     * <code>null</code>if not found.
051     * 
052     * @param key the key.
053     * @return the value or <code>null</code>.
054     */
055    Object getAttribute(Object key);
056
057    /**
058     * Sets the value of the attribute with the specified key.
059     * 
060     * @param key the key.
061     * @param value the value.
062     */
063    void setAttribute(Object key, Object value);
064}