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

dk.rode.thesis.flyweight
Enum CharacterPolicy

java.lang.Object
  extended by java.lang.Enum<CharacterPolicy>
      extended by dk.rode.thesis.flyweight.CharacterPolicy
All Implemented Interfaces:
StringablePolicy<Character>, Serializable, Comparable<CharacterPolicy>

public enum CharacterPolicy
extends Enum<CharacterPolicy>
implements StringablePolicy<Character>

Default policies for formatting Character objects into char sequences (not part of the core Flyweight implementation).

Implementation notes:
This is NOT part of the core Flyweight functionality, merely to provide better log descriptions!

See implementation notes for the ObjectPolicy enumeration.

Author:
Gunni Rode / rode.dk

Nested Class Summary
 
Nested classes/interfaces inherited from interface dk.rode.thesis.strategy.StringablePolicy
StringablePolicy.NameIdiom, StringablePolicy.Type
 
Enum Constant Summary
IDENTITY
          Generates a char sequence representation of a Character having the following format.
NAME
          Generates a char sequence representation of a Character having the following format.
SHORT
          Generates a char sequence representation of a Character having the following format.
VALUE
          Generates a char sequence representation of a Character having the following format.
VALUE_UPPERCASE
          Generates a char sequence representation of a Character having the following format.
 
Method Summary
 CharSequence toString(Character character)
          Returns a textual representation of the object supplied as object in form of a char sequence.
 StringablePolicy.Type type()
          Returns the type of this policy.
static CharacterPolicy valueOf(String name)
          Returns the enum constant of this type with the specified name.
static CharacterPolicy[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

IDENTITY

public static final CharacterPolicy IDENTITY
Generates a char sequence representation of a Character having the following format.
   Character[hash-code: ..; value: ".."]
 
Where Character is the simple class name of the class of the character, .. is the hash-code, and ".." value of the character (excluding quotation marks), respectively.


NAME

public static final CharacterPolicy NAME
Generates a char sequence representation of a Character having the following format.
   Character
 
Where Character is the simple class name of the class of the character.

This policy is considered StringablePolicy.Type.CLOSED.


SHORT

public static final CharacterPolicy SHORT
Generates a char sequence representation of a Character having the following format.
   Character[..]
 
Where Character is the simple class name of the class of the character, and .. is the value of the character, respectively.


VALUE

public static final CharacterPolicy VALUE
Generates a char sequence representation of a Character having the following format.
   ..
 
Where .. is the value of the character, i.e. its string representation.

This policy is considered StringablePolicy.Type.CLOSED.


VALUE_UPPERCASE

public static final CharacterPolicy VALUE_UPPERCASE
Generates a char sequence representation of a Character having the following format.
   ..
 
Where .. is the upper-cased value of the character, i.e. its string representation upper-cased.

This policy is considered StringablePolicy.Type.CLOSED.

Method Detail

toString

public CharSequence toString(Character character)
Description copied from interface: StringablePolicy
Returns a textual representation of the object supplied as object in form of a char sequence.

Specified by:
toString in interface StringablePolicy<Character>
Parameters:
character - The object; cannot be null.
Returns:
The char sequence representation; never null.
See Also:
Stringable.toString(StringablePolicy)

type

public StringablePolicy.Type type()
Description copied from interface: StringablePolicy
Returns the type of this policy.

The stringable context can use the type to decide how to use the textual representation of this policy in conjunction with additional text.

Specified by:
type in interface StringablePolicy<Character>
Returns:
StringablePolicy.Type.APPENDABLE is returned unless explicitly documented otherwise for a given constant.

valueOf

public static CharacterPolicy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

values

public static CharacterPolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CharacterPolicy c : CharacterPolicy.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

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.