|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.chainofresponsibility.AbstractHandlerChain<R>
R
- The type of requests handled by this chain.public abstract class AbstractHandlerChain<R>
An abstract handler chain implements the basic
traits of the HandlerChain
interface.
Constructor Summary | |
---|---|
protected |
AbstractHandlerChain()
No-arg constructor. |
Method Summary | |
---|---|
Handler<R> |
forward(R request,
Handler<R> current)
Forwards the the request supplied as request
to the handler represented by this link. |
Handler<R> |
handle(R request)
Handles the request supplied as request by forwarding
it to each handler in this chain until a
handler can handle it, starting from the first registered handler. |
Handler<R> |
handle(R request,
HandlerLink<R> link)
Handles the request supplied as request or
forwards it to the next handler in the chain represented
by the handler link supplied as
link , if any. |
String |
toString()
Returns the string representation of this handler chain. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.chainofresponsibility.HandlerChain |
---|
getHandlers, isRegistered, register, size, unregister |
Constructor Detail |
---|
protected AbstractHandlerChain()
Method Detail |
---|
public Handler<R> forward(R request, Handler<R> current)
HandlerLink
request
to the handler
represented by this link.
The next handler is the handler after current
in
the chain. current
can be located at any place
in the chain, and if not found, all handlers in the chain
are tried.
forward
in interface HandlerLink<R>
request
- The request to handle; nullability determined
by the actual handler implementation.current
- The handler in the chain that could not
handle request
; can be null if this
link represents the first handler in the chain.
request
, if any.
Can be null.public Handler<R> handle(R request)
request
by forwarding
it to each handler
in this chain until a
handler can handle it, starting from the first registered handler.
The handlers used are those delivered by HandlerChain.getHandlers(Handler)
with a null argument.
handle
in interface HandlerChain<R>
request
- The request to handle. This chain allows it to
be null, but individual handlers may not.
request
, if any; may be null.public Handler<R> handle(R request, HandlerLink<R> link)
Handler
request
or
forwards it to the next handler in the chain represented
by the handler link
supplied as
link
, if any. link
can be null,
in which case this handler is considered the last
handler in the chain.
If this handler handles request
, this handler
is returned. If this handler cannot handle request
,
the result from handling the request using link
is returned. Finally, if link
is null, null is
returned.
handle
in interface Handler<R>
request
- The request to handle; nullability determined
by the actual handler implementation.link
- The link to the next handler in the current
chain; can be null.
request
, if any.
Can be null.public String toString()
toString
in class Object
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |