|
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.Objectdk.rode.thesis.chainofresponsibility.CharacterHandler
@Participant(value="Handler") public abstract class CharacterHandler
An abstract character handler implements the basic traits
of handlers handling Character objects.
Character handlers ignore null requests.
| Constructor Summary | |
|---|---|
protected |
CharacterHandler()
No-arg constructor. |
protected |
CharacterHandler(HandlerChain<Character> chain)
Constructor, which registers this character handler to the end of the handler chain supplied as chain. |
| Method Summary | |
|---|---|
protected abstract boolean |
handle(Character character)
Returns true if this handler can and have handled character, false if not. |
Handler<Character> |
handle(Character character,
HandlerLink<Character> link)
Implements the semantics required for chaining character handlers so sub-classes do not have to. |
void |
register(HandlerChain<Character> chain)
Registers this character handler to the handler chain supplied as chain. |
String |
toString()
Returns the string representation of this handler. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected CharacterHandler()
This handler is not registered to any
handler chain until specifically
registered using the register(HandlerChain)
method.
protected CharacterHandler(HandlerChain<Character> chain)
chain.
chain - The handler chain; cannot be null.
NullPointerException - If chain is null.| Method Detail |
|---|
protected abstract boolean handle(Character character)
character, false if not.
character - The character; can be null.
character was handled, false if not.
public Handler<Character> handle(Character character,
HandlerLink<Character> link)
handle(Character) method,
which sub-classes must implement.
If this handler can handle character, this
handler is returned. If not, link is used
to forward character to the next handler
in the current chain. If link is null, null
is returned.
handle in interface Handler<Character>character - 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 void register(HandlerChain<Character> chain)
chain.
chain - The handler chain; cannot be null.
NullPointerException - If chain is null.
IllegalArgumentException - If this handler has already been
registered to chain.public String toString()
toString in class ObjectObjectPolicy.ID
|
Gunni Rode / rode.dk | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||