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

@Pattern(name="Decorator", scope=Object, purpose=Structural, participants={"Component","ConcreteComponent","Decorator","ConcreteDecorator"})

Package dk.rode.thesis.decorator

Implementations and examples of the Decorator design pattern [Gamma95, p.175].

See:
          Description

Class Summary
AppenderDecorator An appender decorator returns the String value from a decorated sequence prefixed and/or postfixed with values supplied at construction time, respectively.
DuplexDecorator A duplex sequence decorator returns the String value returned by the decorated sequence concatenated with the same value, for example x -> xx.
Main Decorator tests.
SequenceDecorator<E> A sequence decorator is a decorator that forwards all request to the decorated Sequence without performing additional operations except for toString().
UppercaseDecorator An upper-case sequence decorator returns the string value returned by the decorated sequence in upper-case, for example a -> A.
 

Enum Summary
DecoratedPolicy Additional policies for formatting decorated sequences into char sequences (not part of the core Decorator implementation).
 

Package dk.rode.thesis.decorator Description

Implementations and examples of the Decorator design pattern [Gamma95, p.175].

Intent:

Here, the Component participant is represented by the Sequence interface. Any Sequence implementation thus represent the ConcreteComponent participant.

The Decorator participant is represented by the abstract SequenceDecorator class, which also implements the Sequence interface as required. It implements all the basic Sequence functionality by forwarding calls to the decorated sequence. This package defines several decorators that represent the ConcreteDecorator participant, for example AppenderDecorator and DuplexDecorator.

UML Class Diagram:

Implementation notes:
All the decorators defined here only adds behaviour, no additional state.

Author:
Gunni Rode / rode.dk

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.