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

dk.rode.thesis.flyweight
Class Letter

java.lang.Object
  extended by dk.rode.thesis.flyweight.AbstractCharacter
      extended by dk.rode.thesis.flyweight.Letter
All Implemented Interfaces:
Character, Textual<Character>, Stringable<Character>, CharSequence, Comparable<Character>

@Participant(value="ConcreteFlyweight")
public class Letter
extends AbstractCharacter

A letter represents a single letter that is not a whitespace or contain symbolic characters.

A digit is not considered a letter, but a symbol.

Author:
Gunni Rode / rode.dk

Field Summary
private  String letters
          The actual shared string.
 
Constructor Summary
Letter(char letter)
          Constructor.
Letter(CharSequence letters)
          Constructor.
 
Method Summary
 char charAt(int index)
           
 int compareTo(Character character)
           
 boolean isLowerCase()
          Returns true if this letter represents a lower case letter, false if not.
 boolean isUpperCase()
          Returns true if this letter represents an upper case letter, false if not.
 int length()
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class dk.rode.thesis.flyweight.AbstractCharacter
equals, getStringablePolicy, hashCode, indexOfIgnoreCase, lowerCaseFirst, toString, upperCaseFirst
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

letters

private final String letters
The actual shared string.

For certain languages/alphabets, each letter might contain more than a single character.

Never null.

Constructor Detail

Letter

Letter(char letter)
Constructor.

Parameters:
letter - The letter.

Letter

Letter(CharSequence letters)
Constructor.

Parameters:
letters - The letter(s) stored; cannot be null.
Throws:
NullPointerException - If letters are null.
Method Detail

charAt

public final char charAt(int index)

compareTo

public final int compareTo(Character character)

isLowerCase

public final boolean isLowerCase()
Returns true if this letter represents a lower case letter, false if not.

Returns:
True if lower case, false if not.

isUpperCase

public final boolean isUpperCase()
Returns true if this letter represents an upper case letter, false if not.

Returns:
True if upper case, false if not.

length

public final int length()

subSequence

public final CharSequence subSequence(int start,
                                      int end)

toString

public final String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

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.