org.apache.mina.statemachine.context

## Class AbstractStateContextLookup

- java.lang.Object
- - org.apache.mina.statemachine.context.AbstractStateContextLookup

- All Implemented Interfaces:
    StateContextLookup
  Direct Known Subclasses:
    IoSessionStateContextLookup

      public abstract class AbstractStateContextLookup
      extends Object
      implements StateContextLookup

  Abstract `StateContextLookup` implementation. The `lookup(Object[])` method will loop through the event arguments and call the `supports(Class)` method for each of them. The first argument that this method returns `true` for will be passed to the abstract `lookup(Object)` method which should try to extract a `StateContext` from the argument. If none is found a new `StateContext` will be created and stored in the event argument using the `store(Object, StateContext)` method.
  Author:
    Apache MINA Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractStateContextLookup(StateContextFactory contextFactory)` Creates a new instance which uses the specified `StateContextFactory` to create `StateContext` objects.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract StateContext` | `lookup(Object eventArg)` Extracts a `StateContext` from the specified event argument which is an instance of a class `supports(Class)` returns `true` for.
    `StateContext` | `lookup(Object[] eventArgs)` Searches the arguments from an `Event` and returns a `StateContext` if any of the arguments holds one.
    `protected abstract void` | `store(Object eventArg, StateContext context)` Stores a new `StateContext` in the specified event argument which is an instance of a class `supports(Class)` returns `true` for.
    `protected abstract boolean` | `supports(Class<?> c)` Must return `true` for any `Class` that this `StateContextLookup` can use to store and lookup `StateContext` objects.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractStateContextLookup

          public AbstractStateContextLookup(StateContextFactory contextFactory)

      Creates a new instance which uses the specified `StateContextFactory` to create `StateContext` objects.
      Parameters:
        `contextFactory` - the factory.

  - ### Method Detail

    - #### lookup

          public StateContext lookup(Object[] eventArgs)

      Description copied from interface: `StateContextLookup`
      Searches the arguments from an `Event` and returns a `StateContext` if any of the arguments holds one. NOTE! This method must create a new `StateContext` if a compatible object is in the arguments and the next time that same object is passed to this method the same `StateContext` should be returned.
      Specified by:
        `lookup` in interface `StateContextLookup`

    - #### lookup

          protected abstract StateContext lookup(Object eventArg)

      Extracts a `StateContext` from the specified event argument which is an instance of a class `supports(Class)` returns `true` for.
      Parameters:
        `eventArg` - the event argument.
      Returns:
        the `StateContext`.

    - #### store

          protected abstract void store(Object eventArg,
                   StateContext context)

      Stores a new `StateContext` in the specified event argument which is an instance of a class `supports(Class)` returns `true` for.
      Parameters:
        `eventArg` - the event argument.
        `context` - the `StateContext` to be stored.

    - #### supports

          protected abstract boolean supports(Class<?> c)

      Must return `true` for any `Class` that this `StateContextLookup` can use to store and lookup `StateContext` objects.
      Parameters:
        `c` - the class.
      Returns:
        `true` or `false`.

Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.