Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.chainofresponsibility
Class LetterCaseHandler

java.lang.Object
  extended by dk.rode.thesis.chainofresponsibility.CharacterHandler
      extended by dk.rode.thesis.chainofresponsibility.LetterCaseHandler
All Implemented Interfaces:
Handler<Character>

@Participant(value="ConcreteHandler")
public class LetterCaseHandler
extends CharacterHandler

A letter case handler is a handler that can handle letter characters in either upper or lower case only.

Author:
Gunni Rode / rode.dk
See Also:
Letter.isUpperCase(), Letter.isLowerCase()

Field Summary
private  boolean upperCase
          True for upper case only, false for lower case only.
 
Constructor Summary
LetterCaseHandler(boolean upperCase)
          Constructor.
LetterCaseHandler(HandlerChain<Character> chain, boolean upperCase)
          Constructor, which registers this letter handler to the handler chain supplied as chain.
 
Method Summary
protected  boolean handle(Character character)
          Returns true if this handler can and have handled character, false if not.
 
Methods inherited from class dk.rode.thesis.chainofresponsibility.CharacterHandler
handle, register, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

upperCase

private final boolean upperCase
True for upper case only, false for lower case only.

Constructor Detail

LetterCaseHandler

public LetterCaseHandler(boolean upperCase)
Constructor.

This handler is not registered to any handler chain until specifically registered using the CharacterHandler.register(HandlerChain) method.

Parameters:
upperCase - True for upper case only, false for lower case only.

LetterCaseHandler

public LetterCaseHandler(HandlerChain<Character> chain,
                         boolean upperCase)
Constructor, which registers this letter handler to the handler chain supplied as chain.

Parameters:
chain - The handler chain; cannot be null.
upperCase - True for upper case only, false for lower case only.
Throws:
NullPointerException - If chain is null.
Method Detail

handle

protected boolean handle(Character character)
Description copied from class: CharacterHandler
Returns true if this handler can and have handled character, false if not.

Specified by:
handle in class CharacterHandler
Parameters:
character - The character; can be null.
Returns:
True if character was handled, false if not.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.