OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

com.ibm.opencard.handler
Class HandlerChain

java.lang.Object
  |
  +--com.ibm.opencard.handler.HandlerChain

public class HandlerChain
extends java.lang.Object

This class implements a recognized design pattern, called Chain of Responsibility: A Request is handled by delegating it to the Handlers in the chain. The Request is propagated through the chain until it is handled by some Handler.
Each Handler must know which requests it can handle. A handler is expected to return true if it has handled a request, false otherwise.

Version:
$Id: HandlerChain.java,v 1.1 1999/12/02 16:06:03 damke Exp $
See Also:
Handler

Constructor Summary
HandlerChain()
           
 
Method Summary
 void add(Handler handler)
          This function adds a handler to the chain of responsibility at the first position.
 void addAt(Handler handler, int pos)
          Add a Handler at a given position in the chain of responsibility.
 Handler get(java.lang.String id)
          Get the handler with the given identifier.
 boolean handle(Request request)
          Handle a Request by delegating it to the handlers in the Chain of Responsibility.
 void remove(java.lang.String id)
          Remove a handler component.
 int size()
          This method returns the number of handlers which are currenty part of the HandlerChain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandlerChain

public HandlerChain()
Method Detail

size

public int size()
This method returns the number of handlers which are currenty part of the HandlerChain.
Returns:
Number of handlers in the chain.

add

public void add(Handler handler)
This function adds a handler to the chain of responsibility at the first position. This implies that handlers which have been added previously may be overridden by adding a new handler.
Parameters:
handler - The Handler to be added.

addAt

public void addAt(Handler handler,
                  int pos)
Add a Handler at a given position in the chain of responsibility.
Parameters:
handler - The Handler to be added.

remove

public void remove(java.lang.String id)
Remove a handler component.
Parameters:
id - The id of the handler to be removed.

get

public Handler get(java.lang.String id)
Get the handler with the given identifier.
Parameters:
id - identifier of the handler to be returned
Returns:
a handler with the given id

handle

public boolean handle(Request request)
               throws CardServiceException,
                      CardTerminalException
Handle a Request by delegating it to the handlers in the Chain of Responsibility.
Parameters:
request - The request to be handled.
Returns:
true if the request has been handled by some child, false otherwise.
Throws:
CardServiceException - !!! Change this !!!