aboutsummaryrefslogtreecommitdiffstats
path: root/docs/sandbox/ubc-design-patterns/src
diff options
context:
space:
mode:
authorwisberg <wisberg>2004-03-31 01:51:03 +0000
committerwisberg <wisberg>2004-03-31 01:51:03 +0000
commitbff61ab1e3ae811650af9b88e344035607619b33 (patch)
treebb43b298eba3699e242fd9860e389e21a4c47362 /docs/sandbox/ubc-design-patterns/src
parenta0c02a3f1fcdbe81157d0fdaa8a0d0c8b1dd2cd1 (diff)
downloadaspectj-bff61ab1e3ae811650af9b88e344035607619b33.tar.gz
aspectj-bff61ab1e3ae811650af9b88e344035607619b33.zip
Jan Hannemann's design patterns implementations, plus .lst files and test scripts
Diffstat (limited to 'docs/sandbox/ubc-design-patterns/src')
-rw-r--r--docs/sandbox/ubc-design-patterns/src/allPatterns.lst51
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactory.java64
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactoryImplementation.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Display.java103
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/FramedFactory.java84
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Main.java158
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/RegularFactory.java58
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/ComponentFactory.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Display.java102
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/FramedFactory.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Main.java155
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/RegularFactory.java70
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Main.java87
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/PrinterAdapter.java62
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/SystemOutPrinter.java58
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Writer.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Main.java92
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/PrinterAdapter.java73
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/SystemOutPrinter.java49
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Writer.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/AbstractionImplementation.java96
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/CrossCapitalImplementation.java64
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/GreetingScreen.java57
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/InformationScreen.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Main.java110
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Screen.java58
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/ScreenImplementation.java56
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/StarImplementation.java62
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/CrossCapitalImplementation.java64
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/GreetingScreen.java57
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/InformationScreen.java62
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Main.java110
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Screen.java103
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/ScreenImplementation.java56
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/StarImplementation.java62
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Creator.java70
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/CreatorImplementation.java76
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Main.java97
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/TextCreator.java66
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/XMLCreator.java103
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Creator.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Main.java99
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/TextCreator.java66
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/XMLCreator.java90
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Button.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Click.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/ClickChain.java102
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Frame.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Main.java108
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Panel.java37
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Button.java86
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Click.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/ClickHandler.java38
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Frame.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Main.java102
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Panel.java81
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Button.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand.java52
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand2.java40
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommanding.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Main.java104
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Printer.java38
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Button.java87
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand.java46
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand2.java47
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Command.java40
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Main.java98
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Directory.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/File.java80
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/FileSystemComposition.java180
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Main.java141
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Directory.java120
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/File.java120
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/FileSystemComponent.java81
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Main.java119
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/BracketDecorator.java56
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/ConcreteOutput.java47
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/Main.java78
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/StarDecorator.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/BracketDecorator.java56
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/ConcreteOutput.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Main.java73
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Output.java43
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/OutputDecorator.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/StarDecorator.java59
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/Main.java52
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Decoration.java44
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Main.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/OutputFacade.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/RegularScreen.java52
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/StringTransformer.java56
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/ButtonCreator.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/CreatorImplementation.java76
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/GUIComponentCreator.java66
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/LabelCreator.java60
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/Main.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/ButtonCreator.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/GUIComponentCreator.java102
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/LabelCreator.java60
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/Main.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/CharacterFlyweight.java64
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/FlyweightImplementation.java89
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/Main.java114
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/PrintableFlyweight.java44
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/WhitespaceFlyweight.java66
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/CharacterFlyweight.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/Main.java122
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweight.java46
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweightFactory.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/WhitespaceFlyweight.java66
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/AndExpression.java70
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanConstant.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanExpression.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanInterpretation.java185
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/ExpressionException.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/Main.java131
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/NotExpression.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/OrExpression.java70
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableContext.java71
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableExpression.java73
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/AndExpression.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanConstant.java84
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanExpression.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/ExpressionException.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/Main.java115
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/NotExpression.java85
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/OrExpression.java92
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableContext.java69
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableExpression.java99
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/Main.java98
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenList.java88
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenListIteration.java130
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/SimpleList.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/Main.java97
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/OpenList.java95
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/ReverseIterator.java94
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/SimpleList.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Button.java57
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Label.java46
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Main.java89
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/MediatorImplementation.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Button.java71
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIColleague.java44
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIMediator.java45
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Label.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Main.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Counter.java58
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/CounterMemento.java92
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Main.java85
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Counter.java78
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/CounterMemento.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Main.java75
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ColorObserver.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/CoordinateObserver.java76
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Main.java112
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Point.java112
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Screen.java63
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ScreenObserver.java77
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeObserver.java43
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeSubject.java57
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Main.java141
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Point.java161
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Screen.java123
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/Main.java105
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeA.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeB.java73
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypes.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/tut-source-compile-error.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/Main.java108
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeA.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeB.java82
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/AlternateOutputImplementation.java47
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/Main.java99
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/OutputImplementation.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestBlocking.java78
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestCounting.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestDelegation.java105
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/Main.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputImplementation.java67
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputSubject.java60
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestBlocker.java94
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestCounter.java104
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Main.java158
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Printer.java75
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/PrinterSubclass.java46
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/SingletonInstance.java60
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/Main.java157
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSingleton.java100
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSubclass.java43
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Main.java138
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Queue.java85
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueEmpty.java76
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueFull.java85
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueNormal.java94
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueState.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueStateAspect.java114
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Main.java147
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Queue.java85
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueContext.java43
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueEmpty.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueFull.java105
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueNormal.java129
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueState.java70
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/BubbleSort.java67
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/LinearSort.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Main.java96
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Sorter.java39
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/SortingStrategy.java106
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/BubbleSort.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/LinearSort.java72
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Main.java75
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Sorter.java69
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/SortingStrategy.java36
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/DecoratedStringGenerator.java69
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/FancyGenerator.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Generating.java51
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Main.java75
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/SimpleGenerator.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/DecoratedStringGenerator.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/FancyGenerator.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/Main.java76
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/SimpleGenerator.java68
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeLeaf.java61
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeNode.java79
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Main.java103
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/SummationVisitor.java80
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/TraversalVisitor.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visitable.java34
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visiting.java55
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/build.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/visitor.lst2
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeLeaf.java71
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeNode.java89
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeVisitor.java59
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Main.java104
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/SummationVisitor.java74
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/TraversalVisitor.java77
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Visitable.java43
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityException.java47
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityProtocol.java176
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Command.java52
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandInvoker.java38
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandProtocol.java255
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandReceiver.java39
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CompositeProtocol.java209
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/FlyweightProtocol.java83
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MediatorProtocol.java143
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Memento.java51
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoException.java46
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoProtocol.java65
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ObserverProtocol.java168
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/PrototypeProtocol.java91
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ProxyProtocol.java115
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/SingletonProtocol.java93
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/StrategyProtocol.java87
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/VisitorProtocol.java130
-rw-r--r--docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/build-lib.lst5
-rw-r--r--docs/sandbox/ubc-design-patterns/src/tut-all.lst253
-rw-r--r--docs/sandbox/ubc-design-patterns/src/tut-source.lst5
280 files changed, 20740 insertions, 0 deletions
diff --git a/docs/sandbox/ubc-design-patterns/src/allPatterns.lst b/docs/sandbox/ubc-design-patterns/src/allPatterns.lst
new file mode 100644
index 000000000..3e5fafe8a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/allPatterns.lst
@@ -0,0 +1,51 @@
+ca/ubc/cs/spl/aspectPatterns/patternLibrary/*.java
+
+ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/builder/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/*.java
+
+ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/composite/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/facade/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/command/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/memento/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/observer/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/state/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/*.java
+ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/*.java
+
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactory.java
new file mode 100644
index 000000000..669aa042d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactory.java
@@ -0,0 +1,64 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JButton;
+
+/**
+ * Defines the interface for creating products. The only factory methods are
+ * <code>createLabel()</code> and <code>createButton(..)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public interface ComponentFactory {
+
+ /**
+ * Creates factory-specific <code>JLabel</code> products.
+ *
+ * @return the factory-specific <code>JLabel</code>
+ */
+
+ public JLabel createLabel();
+
+ /**
+ * Creates factory-specific <code>JButton</code> products.
+ *
+ * @return the factory-specific <code>JButton</code>
+ */
+
+ public JButton createButton(String label);
+
+
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactoryImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactoryImplementation.java
new file mode 100644
index 000000000..4a983c8c7
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/ComponentFactoryImplementation.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JButton;
+
+/**
+ * Illustrates AspectJ's inter-type declarations: a default implementation
+ * of the two factory methods declared in the <code>AbstractFactory</code>
+ * interface is provided here.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public aspect ComponentFactoryImplementation {
+
+ /**
+ * Provides a default implementation for all <code>ComponentFactories
+ * </code> for the <code>createLabel()</code> method.
+ *
+ * @return a regular <code>JLabel</code>
+ */
+
+ public JLabel ComponentFactory.createLabel() {
+ return new JLabel("This Label was created by " +getName());
+ }
+
+ /**
+ * Provides a default implementation for all <code>ComponentFactories
+ * </code> for the <code>createButton()</code> method.
+ *
+ * @param a label for the new <code>JButton</code>
+ * @return a regular <code>JButton</code>
+ */
+
+ public JButton ComponentFactory.createButton(String label) {
+ return new JButton(label);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Display.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Display.java
new file mode 100644
index 000000000..2575cf817
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Display.java
@@ -0,0 +1,103 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JButton;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Sets up and displays a new GUI given a concrete factory.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public class Display extends JFrame {
+
+ /**
+ * Sets up the frame with a label and a button created by the respective
+ * <i>ConcreteFactory</i>. Both button and frame receive their appropriate
+ * listeners to close the frame when either the button is clicked or
+ * the frame is closing.
+ *
+ * @param factory the concrete factory to use for creating GUI elements
+ */
+
+ Display(ComponentFactory factory) {
+ super("New GUI");
+ JLabel label = factory.createLabel();
+ JButton button = factory.createButton("OK");
+ button.addActionListener(new myActionListener(this));
+ JPanel panel = new JPanel();
+ panel.add(label);
+ panel.add(button);
+ this.getContentPane().add(panel);
+ this.pack();
+ this.setVisible(true);
+ this.addWindowListener(new myWindowListener(this));
+ }
+
+ /**
+ * Adds a window listener that closes the frame on demand
+ */
+
+ private class myWindowListener extends WindowAdapter {
+
+ Display display = null;
+
+ protected myWindowListener(Display display) {
+ super();
+ this.display = display;
+ }
+
+ public void windowClosing(WindowEvent e) {
+ display.setVisible(false);
+ }
+ }
+
+ /**
+ * Adds a button listener that closes the frame on demand
+ */
+
+ private class myActionListener implements ActionListener {
+
+ Display display;
+
+ protected myActionListener(Display display) {
+ super();
+ this.display = display;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ display.setVisible(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/FramedFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/FramedFactory.java
new file mode 100644
index 000000000..2666d1754
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/FramedFactory.java
@@ -0,0 +1,84 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+
+import javax.swing.JLabel;
+import javax.swing.border.Border;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+
+/**
+ * This <i>Concrete Factory</i> implements the <code>ComcreteFactory</code>
+ * interface to provide framed Swing GUI components.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public class FramedFactory implements ComponentFactory {
+
+ /**
+ * Factroy method to create framed <code>JLabel</code> objects.
+ *
+ * @return the framed <code>JLabel</code>
+ */
+
+
+ public JLabel createLabel() {
+ JLabel label = new JLabel("This Label was created by " + getName());
+ Border raisedbevel = BorderFactory.createRaisedBevelBorder();
+ Border loweredbevel = BorderFactory.createLoweredBevelBorder();
+ label.setBorder(BorderFactory.createCompoundBorder(
+ raisedbevel, loweredbevel));
+
+ return label;
+ }
+
+ /**
+ * Factory method to create framed <code>JButton</code> objects.
+ *
+ * @param the label for the new <code>JButton</code>
+ * @return the framed <code>JButton</code>
+ */
+
+ public JButton createButton(String label) {
+ JButton button = new JButton(label);
+ Border raisedbevel = BorderFactory.createRaisedBevelBorder();
+ Border loweredbevel = BorderFactory.createLoweredBevelBorder();
+ button.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel));
+ return button;
+ }
+
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName() {
+ return "Framed Factory";
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Main.java
new file mode 100644
index 000000000..8cff6d26d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/Main.java
@@ -0,0 +1,158 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JRadioButton;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.ButtonGroup;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+
+/**
+ * Implements a driver for the Abstract Factory design pattern example.
+ * The pattern intent is:
+ * <blockquote>
+ * Provide an interface for creating families of related or dependent objects
+ * without specifying their concrete classes.
+ * </blockquote>
+ *
+ * As an example scenario, our abstract factory interface defines two
+ * factory methods, <code>createLabel()</code> and
+ * <code>createButton()</code>, that create related products
+ * (here: Swing GUI elements).
+ *
+ * The driver is a GUI that allows the user to choose between the two
+ * concrete factories (<code>RegularFactory</code> and <code>FramedFactory
+ * </code>), and creates a new GUI with elements from the respective factory.
+ * <p>
+ *
+ * <code>RegularFactory</code> creates standard Swing GUI elements, while
+ * <code>FramedFactory</code> produces elements which are framed.
+ *
+ * <P><i>This is the AspectJ implementation. </i><p>
+ *
+ * We decided to implement <code>AbstractFactory</code> as an interace,
+ * not an abstract class. In the AspectJ solution, we can still define
+ * default implementations for the interface methods. This approach uses
+ * AspectJ's inter-type declaration mechanism.
+ *
+ * To illustrate this, the aspect <code>AbstratFactoryEnhancement</code>
+ * attaches a default implementation of both factory methods to all
+ * classes that implement the <code>AbstractFactory</code> interface.
+ * This default implementation creates regular Swing elements and is
+ * used by <code>RegularFactory</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+public class Main
+{
+ /**
+ * a concrete factory that creates regular GUI components
+ */
+
+ private static ComponentFactory factory1 = new RegularFactory();
+
+ /**
+ * a concrete factory that creates framed GUI components
+ */
+
+ private static ComponentFactory factory2 = new FramedFactory();
+
+ /**
+ * stores the currently selected factory
+ */
+
+ private static ComponentFactory factory = factory1;
+
+
+ /**
+ * Creates the initial GUI that allows the user to choose a factory
+ * and generate a new GUI with the elements that the respective
+ * factory provides.
+ *
+ * @return a <code>JPanel</code> containing the GUI
+ */
+
+ private static JPanel createGUI()
+ {
+ ActionListener radioListener = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals("factory1")) factory = factory1;
+ else factory = factory2;
+ }
+ };
+
+ JPanel panel = new JPanel();
+ JRadioButton factoryButton1 = new JRadioButton("use Factory 1");
+ JRadioButton factoryButton2 = new JRadioButton("use Factory 2");
+ factoryButton1.setActionCommand("factory1");
+ factoryButton2.setActionCommand("factory2");
+ factoryButton1.addActionListener(radioListener);
+ factoryButton2.addActionListener(radioListener);
+ JButton create = new JButton("Create GUI");
+
+ ButtonGroup choices = new ButtonGroup();
+
+ choices.add(factoryButton1);
+ choices.add(factoryButton2);
+
+ create.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ Display display = new Display(factory);
+ }
+ });
+
+ panel.add(factoryButton1);
+ panel.add(factoryButton2);
+ panel.add(create);
+
+ return panel;
+ }
+
+ /**
+ * Implements the driver for this design pattern example. It sets up
+ * the initial GUI.
+ */
+
+ public static void main(String[] args)
+ {
+ JFrame frame = new JFrame("Abstract Factory Demo");
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ frame.getContentPane().add(createGUI());
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/RegularFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/RegularFactory.java
new file mode 100644
index 000000000..573f89571
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/RegularFactory.java
@@ -0,0 +1,58 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code please see
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JButton;
+
+/**
+ * This <i>Concrete Factory</i> implements the
+ * <code>AbstractFactory</code> interface to provide
+ * regular Swing GUI components.
+ *
+ * The factroy methods <code>createLabel()</code> and <create>Button()</code>
+ * do not need to be defined here, they recieve their implementation from
+ * the inter-type declarations in aspect
+ * <code>AbstractFactroyEnhancement</code>.
+ *
+ * This is done so that future concrete factories can reuse the
+ * implementations of the factory methods and will only have to specify those
+ * that differ from the default ones.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+public class RegularFactory implements ComponentFactory {
+
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName() {
+ return ("Regular Factory");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/ComponentFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/ComponentFactory.java
new file mode 100644
index 000000000..ea2036430
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/ComponentFactory.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JButton;
+
+/**
+ * Defines the interface for creating products. The only factory methods are
+ * <code>createLabel()</code> and <code>createButton(..)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+public interface ComponentFactory {
+
+ /**
+ * Creates factory-specific <code>JLabel</code> products.
+ *
+ * @return the factory-specific <code>JLabel</code>
+ */
+
+ public JLabel createLabel();
+
+ /**
+ * Creates factory-specific <code>JButton</code> products.
+ *
+ * @return the factory-specific <code>JButton</code>
+ */
+
+ public JButton createButton(String label);
+
+
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Display.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Display.java
new file mode 100644
index 000000000..40e2b5b48
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Display.java
@@ -0,0 +1,102 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JButton;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Sets up and displays a new GUI given a concrete factory.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+public class Display extends JFrame {
+
+ /**
+ * Sets up the frame with a label and a button created by the respective
+ * concrete factories. Both button and frame receive their appropriate
+ * listeners to close the frame when either the button is clicked or
+ * the frame is closing.
+ *
+ * @param factory the factory to create GUI elements
+ */
+
+ public Display(ComponentFactory factory) {
+ super("New GUI");
+ JLabel label = factory.createLabel();
+ JButton button = factory.createButton("OK");
+ button.addActionListener(new myActionListener(this));
+ JPanel panel = new JPanel();
+ panel.add(label);
+ panel.add(button);
+ this.getContentPane().add(panel);
+ this.pack();
+ this.setVisible(true);
+ this.addWindowListener(new myWindowListener(this));
+ }
+
+ /**
+ * Adds a window listener that closes the frame on demand
+ */
+
+ private class myWindowListener extends WindowAdapter {
+
+ Display display = null;
+
+ protected myWindowListener(Display display) {
+ super();
+ this.display = display;
+ }
+
+ public void windowClosing(WindowEvent e) {
+ display.setVisible(false);
+ }
+ }
+
+ /**
+ * Adds a button listener that closes the frame on demand
+ */
+
+ private class myActionListener implements ActionListener {
+
+ Display display;
+
+ protected myActionListener(Display display) {
+ super();
+ this.display = display;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ display.setVisible(false);
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/FramedFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/FramedFactory.java
new file mode 100644
index 000000000..0a2f5b4b8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/FramedFactory.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.border.Border;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+
+/**
+ * This <i>Concrete Factory</i> implements the
+ * <code>ComponentFactory</code> interface to provide
+ * framed Swing GUI components.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public class FramedFactory implements ComponentFactory {
+
+ /**
+ * Factory method to create framed <code>JLabel</code> objects.
+ *
+ * @return the framed <code>JLabel</code>
+ */
+
+
+ public JLabel createLabel() {
+ JLabel label = new JLabel("This Label was created by " +getName());
+ Border raisedbevel = BorderFactory.createRaisedBevelBorder();
+ Border loweredbevel = BorderFactory.createLoweredBevelBorder();
+ label.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel));
+
+ return label;
+ }
+
+ /**
+ * Factory method to create framed <code>JButton</code> objects.
+ *
+ * @param the label for the new <code>JButton</code>
+ * @return the framed <code>JButton</code>
+ */
+
+ public JButton createButton(String label) {
+ JButton button = new JButton(label);
+ Border raisedbevel = BorderFactory.createRaisedBevelBorder();
+ Border loweredbevel = BorderFactory.createLoweredBevelBorder();
+ button.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel));
+ return button;
+ }
+
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName() {
+ return "Framed Factory";
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Main.java
new file mode 100644
index 000000000..001e36a25
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/Main.java
@@ -0,0 +1,155 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code please see
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JRadioButton;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.ButtonGroup;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+
+/**
+ * Implements the driver for the Abstract Factory design pattern example.<p>
+ *
+ * Intent: <i>Provide an interface for creating families of related or
+ * dependent objects without specifying their concrete classes.</i><p>
+ *
+ * As an example scenario, our abstract factory interface defines two
+ * factory methods <code>createLabel()</code> and <code>createButton()</code>
+ * that create related products (Swing GUI elements).
+ *
+ * The driver is a swing GUI that allows the user to choose between the two
+ * concrete factories <code>RegularFactory</code> and <code>FramedFactory
+ * </code>, and creates a new GUI with elements from the respective factory.
+ * <p>
+ *
+ * <code>RegularFactory</code> creates standard Swing GUI elements, while
+ * <code>FramedFactory</code> produces elements which are framed.
+ *
+ * <P><i>This is the Java implementation. </i><p>
+ *
+ * We decided to implement <code>AbstractFactory</code> as an interace,
+ * not an abstract class. This has the following advantages and liabilities:
+ * <UL>
+ * <LI> Concrete factories do not need to be subclasses of the abstract
+ * factory. That way existing classes can be subclassed and just have
+ * to implement the interface methods. This can be more flexible if
+ * we want an existing class to become a factory (e.g. because we
+ * want to make use of its functionality.
+ * <LI> By defining the abstract factory as an interface we cannot attach
+ * any (default) implementations to its methods, nor is it possible
+ * to include fields (such as the <code>name</code> field in this
+ * example.
+ * </UL>
+ *
+ */
+
+public class Main
+{
+ /**
+ * a concrete factory that creates regular GUI components
+ */
+
+ private static ComponentFactory factory1 = new RegularFactory();
+
+ /**
+ * a concrete factory that creates framed GUI components
+ */
+
+ private static ComponentFactory factory2 = new FramedFactory();
+
+ /**
+ * stores the currently selected factory
+ */
+
+ private static ComponentFactory factory = factory1;
+
+
+ /**
+ * Creates the initial GUI that allows the user to choose a factory
+ * and generate a new GUI with the elements that the respective
+ * factory provides.
+ *
+ * @return a <code>JPanel</code> containing the GUI
+ */
+
+ private static JPanel createGUI()
+ {
+ ActionListener radioListener = new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getActionCommand().equals("factory1")) factory = factory1;
+ else factory = factory2;
+ }
+ };
+
+ JPanel panel = new JPanel();
+ JRadioButton factoryButton1 = new JRadioButton("use Factory 1");
+ JRadioButton factoryButton2 = new JRadioButton("use Factory 2");
+ factoryButton1.setActionCommand("factory1");
+ factoryButton2.setActionCommand("factory2");
+ factoryButton1.addActionListener(radioListener);
+ factoryButton2.addActionListener(radioListener);
+ JButton create = new JButton("Create GUI");
+
+ ButtonGroup choices = new ButtonGroup();
+
+ choices.add(factoryButton1);
+ choices.add(factoryButton2);
+
+ create.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ Display display = new Display(factory);
+ }
+ });
+
+ panel.add(factoryButton1);
+ panel.add(factoryButton2);
+ panel.add(create);
+
+ return panel;
+ }
+
+ /**
+ * Implements the driver for this design pattern example. It sets up
+ * the initial GUI.
+ */
+
+ public static void main(String[] args)
+ {
+ JFrame frame = new JFrame("Abstract Factory Demo");
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ frame.getContentPane().add(createGUI());
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/RegularFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/RegularFactory.java
new file mode 100644
index 000000000..b6aa6376e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/abstractFactory/java/RegularFactory.java
@@ -0,0 +1,70 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code please see
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JButton;
+
+/**
+ * This <i>Concrete Factory</i> implements the <code>ComponentFactory</code>
+ * interface to provide regular Swing GUI components.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/20/04
+ *
+ */
+
+public class RegularFactory implements ComponentFactory {
+
+ /**
+ * Factroy method to create regular <code>JLabel</code> objects.
+ *
+ * @return the regular <code>JLabel</code>
+ */
+
+ public JLabel createLabel() {
+ return new JLabel("This Label was created by " +getName());
+ }
+
+ /**
+ * Factory method to create regular <code>JButton</code> objects.
+ *
+ * @param the label for the new <code>JButton</code>
+ * @return the regular <code>JButton</code>
+ */
+
+ public JButton createButton(String label) {
+ return new JButton(label);
+ }
+ /**
+ * Returns the name of the factory.
+ *
+ * @return the name of the factory
+ */
+
+ public String getName() {
+ return ("Regular Factory");
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Main.java
new file mode 100644
index 000000000..c544be6ed
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Main.java
@@ -0,0 +1,87 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Adapter design pattern example. <p>
+ *
+ * Intent: <i> Convert the interface of a class into another interface clients
+ * expect. Adapter lets classes work together that couldn't otherwise because
+ * incompatible interfaces.</i><p>
+ *
+ * Experimental setup: anloguous to the pattern structure as described on page
+ * 141 of the "Design Patterns" book:
+ *
+ * <code>Adaptee</code> can print strings to <code>System.out</code>.
+ * <code>Adapter</code> allows to access <code>Adaptee</code>'s functionality
+ * via <code>Target</code>'s interface.<p>
+ *
+ * <i>This is the AspectJ implementation.</i><p>
+ *
+ * The implementation is that of an <i>object adapter</i> (NOT class adapter),
+ * as the latter requires multiple inheritance which Java does not provide.
+ *
+ * In this implementation, the <i>Adaptee</i> is effectively made to conform
+ * with the <i>Target</i> interface directly. <code>Adapter</code> is an
+ * aspect that ensures that by using the <code>declare parents</code>
+ * construct (to ensure <i>Adaptee</i> is of type <i>Target</i>) and an
+ * inter-type declaration of the missing interface method.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Target
+ * @see Adaptee
+ * @see Adapter
+ */
+
+public class Main {
+
+ /**
+ * the Adaptee in the scenario
+ */
+
+ private static SystemOutPrinter adaptee;
+
+ /**
+ * Implements the driver.
+ *
+ * In this implementation, the <i>Adaptee</i> becomes its own
+ * <i>Adapter</i>, so only one variable is needed.
+ *
+ * @param args required for a main method, but ignored
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Creating Adaptee (which is its own Adapter)...");
+ adaptee = new SystemOutPrinter();
+
+ System.out.print ("Adapter and Adaptee are the same object: ");
+ System.out.println(adaptee == adaptee);
+
+ System.out.println("Issuing the request() to the Adapter...");
+ adaptee.write("Test successful.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/PrinterAdapter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/PrinterAdapter.java
new file mode 100644
index 000000000..86360ec43
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/PrinterAdapter.java
@@ -0,0 +1,62 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Adapts <code>SystemOutPrinter</code> to match the <code>Writer</code>
+ * interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Target
+ * @see Adaptee
+ */
+
+public aspect PrinterAdapter {
+
+ /**
+ * Ensures that <code>SystemOutPrinter</code> implements <code>Writer
+ * </code>. This means that the <i>Adaptee</i> effectively becomes its
+ * own <i>Adapter</i>.
+ */
+
+ declare parents: SystemOutPrinter implements Writer;
+
+ /**
+ * Defines a <code>write(String)</code> method on <code>Adaptee</code>
+ * to ensure compliance with the <i>Writer</i> interface.
+ *
+ * On the pattern level, this means that <i>Adaptee</i> now implements
+ * <i>request()</i>.
+ *
+ * @param s the string to print
+ * @see Writer#write(String)
+ * @see SystemOutPrinter#printToSystemOut(String)
+ */
+
+ public void SystemOutPrinter.write(String s) {
+ printToSystemOut(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/SystemOutPrinter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/SystemOutPrinter.java
new file mode 100644
index 000000000..abe34d6e8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/SystemOutPrinter.java
@@ -0,0 +1,58 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Provides a specialized print method. Acts as the <i>Adaptee</i> in the
+ * pattern context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+/**
+ * Provides a specialized print method. Acts as the <i>Adaptee</i> in the
+ * pattern context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class SystemOutPrinter {
+
+ /**
+ * Prints the argument string to <code>System.out</code>. In the pattern
+ * context, this is the <i>specificRequest()</i> method on
+ * the <i>Adaptee</i>.
+ *
+ * @param s the string to be printed
+ * @see Writer#write(String) the adapted method
+ */
+
+
+ public void printToSystemOut(String s) {
+ System.out.println(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Writer.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Writer.java
new file mode 100644
index 000000000..bd1ad3f4b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/Writer.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the target interface with a general output method. Acts as the
+ * <i>Target</i> in the pattern context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public interface Writer {
+
+ /**
+ * Prints the argument string. In the pattern context, this is the
+ * <i>request()</i> method on the <i>Target</i>.
+ *
+ * @param s the string to print
+ * @see PrinterAdapter
+ */
+
+ public void write(String s);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Main.java
new file mode 100644
index 000000000..b7e01fd30
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Main.java
@@ -0,0 +1,92 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.patterns.
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Adapter design pattern example. <p>
+ *
+ * Intent: <i> Convert the interface of a class into another interface clients
+ * expect. Adapter lets classes work together that couldn't otherwise because
+ * incompatible interfaces.</i><p>
+ *
+ * Experimental setup: anloguous to the pattern structure as described on page
+ * 141 of the "Design Patterns" book:
+ *
+ * <code>Adaptee</code> can print strings to <code>System.out</code>.
+ * <code>Adapter</code> allows to access <code>Adaptee</code>'s functionality
+ * via <code>Target</code>'s interface.<p>
+ *
+ * <i>This is the Java implementation.</i><p>
+ *
+ * Participants and their roles: <ul>
+ * <LI> Main (Client)
+ * <LI> Writer (Target)
+ * <LI> SystemOutPrinter (Adaptee)
+ * <LI> PrinterAdapter (Adapter)
+ * </ul>
+ *
+ * The implementation is that of an <i>object adapter</i> (NOT class adapter),
+ * as the latter requires multiple inheritance which Java does not provide.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Adapter
+ * @see Adaptee
+ * @see Target
+ */
+
+public class Main {
+
+ /**
+ * the Target in the scenario
+ */
+
+ private static Writer myTarget;
+
+ /**
+ * the Adaptee in the scenario
+ */
+
+ private static SystemOutPrinter adaptee;
+
+ /**
+ * Implements the driver.
+ *
+ * @param args required for a main method, but ignored
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Creating the Adaptee...");
+ adaptee = new SystemOutPrinter();
+
+ System.out.println("Creating the Adapter...");
+ myTarget = new PrinterAdapter(adaptee);
+
+ System.out.print ("Adapter and Adaptee are the same object: ");
+ System.out.println(myTarget.equals(adaptee));
+
+ System.out.println("Issuing the request() to the Adapter...");
+ myTarget.write("Test successful.");
+
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/PrinterAdapter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/PrinterAdapter.java
new file mode 100644
index 000000000..bcc5196fd
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/PrinterAdapter.java
@@ -0,0 +1,73 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Represents an <i>Object Adapter</i>. Implements the <i>Target</i> interface
+ * and stores a private variable of type <i>Adaptee</i> (here: <code>
+ * SystemOutWriter</code>) to which it forwards appropriate method calls. <p>
+ *
+ * It is not possible to use a class adapter in Java as it requires multiple
+ * inheritance.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Writer
+ * @see SystemOutPrinter
+ */
+
+public class PrinterAdapter implements Writer {
+
+ /**
+ * the adaptee to forward appropriate messages to.
+ */
+
+ private SystemOutPrinter adaptee = null;
+
+
+ /**
+ * Creates a new Adapter for a given Adaptee.
+ *
+ * @param screen the screen to adapt
+ */
+
+ public PrinterAdapter(SystemOutPrinter adaptee) {
+ this.adaptee = adaptee;
+ }
+
+ /**
+ * Implements the <i>Target</i> interface. This is where the actual
+ * adaption happens: calls to write(String) trigger calls
+ * to printToSystemOut(String) on the adaptee.
+ *
+ * @param s the string to print
+ * @see Writer#write(String)
+ * @see SystemOutPrinter#printToSystemOut(String)
+ */
+
+ public void write(String s) {
+ adaptee.printToSystemOut(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/SystemOutPrinter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/SystemOutPrinter.java
new file mode 100644
index 000000000..023ab46db
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/SystemOutPrinter.java
@@ -0,0 +1,49 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Provides a specialized print method. Acts as the <i>Adaptee</i> in the
+ * pattern context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class SystemOutPrinter {
+
+ /**
+ * Prints the argument string to <code>System.out</code>. In the pattern
+ * context, this is the <i>specificRequest()</i> method on
+ * the <i>Adaptee</i>.
+ *
+ * @param s the string to be printed
+ * @see Writer#write(String) the adapted method
+ */
+
+
+ public void printToSystemOut(String s) {
+ System.out.println(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Writer.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Writer.java
new file mode 100644
index 000000000..63f0e0978
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/adapter/java/Writer.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.adapter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the target interface with a general output method. Acts as the
+ * <i>Target</i> in the pattern context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public interface Writer {
+
+ /**
+ * Prints the argument string. In the pattern context, this is the
+ * <i>request()</i> method on the <i>Target</i>.
+ *
+ * @param s the string to print
+ * @see PrinterAdapter
+ */
+
+ public void write(String s);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/AbstractionImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/AbstractionImplementation.java
new file mode 100644
index 000000000..35f47ca16
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/AbstractionImplementation.java
@@ -0,0 +1,96 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Represents the <i>Abstraction</i> in the scenario. <code>Screen</code>
+ * provides two methods to draw/print: <code>drawText(String)</code> and
+ * <code>drawTextBox(String)</code>. The method implementations are provided
+ * by this aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public aspect AbstractionImplementation {
+
+ /**
+ * stores the actual <i>Implementor</i> to use
+ */
+
+ private ScreenImplementation Screen.implementor;
+
+ /**
+ * Draws or prints a text to an output device determined by the
+ * current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void Screen.drawText(String text) {
+ implementor.printText(text);
+ implementor.printLine();
+ }
+
+ /**
+ * Draws or prints a text in a box to an output device determined
+ * by the current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void Screen.drawTextBox(String text) {
+
+ int length = text.length();
+
+ for(int i=0; i<length+4; i++) {
+ implementor.printDecor();
+ }
+
+ implementor.printLine();
+ implementor.printDecor();
+ implementor.printText(" "+text+" ");
+ implementor.printDecor();
+ implementor.printLine();
+
+ for(int i=0; i<length+4; i++) {
+ implementor.printDecor();
+ }
+
+ implementor.printLine();
+ }
+
+ /**
+ * Sets the current <i>Implementor</i>.
+ *
+ * @param implementor The new implementor
+ */
+
+ public void Screen.setImplementor(ScreenImplementation implementor) {
+ this.implementor = implementor;
+ }
+
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/CrossCapitalImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/CrossCapitalImplementation.java
new file mode 100644
index 000000000..99088ed25
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/CrossCapitalImplementation.java
@@ -0,0 +1,64 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints capitalized text and uses the double cross ("#") to decorate.
+ * Represents a <i>ConcreteImplementation</i> in the context of the Bridge
+ * design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class CrossCapitalImplementation implements ScreenImplementation {
+
+
+ /**
+ * Does a line feed (to <code>System.out</code>).
+ */
+
+ public void printLine() {
+ System.out.println();
+ }
+
+ /**
+ * Prints a double cross ("#") to <code>System.out</code>.
+ */
+
+ public void printDecor() {
+ System.out.print("X");
+ }
+
+ /**
+ * Prints the argument text in capitals to <code>System.out</code>.
+ *
+ * @param text the text to print
+ */
+
+ public void printText(String text) {
+ System.out.print(text.toUpperCase());
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/GreetingScreen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/GreetingScreen.java
new file mode 100644
index 000000000..4fb5fbc4a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/GreetingScreen.java
@@ -0,0 +1,57 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints/draws a greeting in a text box. Represents a <i>RefinedAbstraction
+ * </i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class GreetingScreen implements Screen {
+
+ /**
+ * Creates a new <code>GreetingScreen</code> object with the provided
+ * <i>Implementor</i>.
+ *
+ * @param si the implementor to use
+ */
+
+ public GreetingScreen(ScreenImplementation si) {
+ setImplementor(si);
+ }
+
+ /**
+ * Draws/prints a greeting in a text box
+ */
+
+ public void drawGreeting() {
+ drawTextBox("Greetings!");
+ }
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/InformationScreen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/InformationScreen.java
new file mode 100644
index 000000000..3a4eed280
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/InformationScreen.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints/draws the current system time in a text box. Represents a
+ * <i>RefinedAbstraction</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+import java.util.Date;
+
+public class InformationScreen implements Screen {
+
+
+ /**
+ * Creates a new <code>InformationScreen</code> object with the provided
+ * <i>Implementor</i>.
+ *
+ * @param si the implementor to use
+ */
+
+ public InformationScreen(ScreenImplementation si) {
+ setImplementor(si);
+ }
+
+
+ /**
+ * Draws/prints the system time in a text box
+ */
+
+ public void drawInfo() {
+ Date date = new Date();
+ drawTextBox("Current system time: "+date);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Main.java
new file mode 100644
index 000000000..3c4a97e26
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Main.java
@@ -0,0 +1,110 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Bridge design pattern example. <p>
+ *
+ * Intent: <i> Decouple an abstraction from its implementation so that the
+ * two can vary independently.</i><p>
+ *
+ * Scenario: Have seperate hierarchies for Abstractions (here: Screens)
+ * and Implementors (here: ScreenImplementation), so that both
+ * can change independently of each other
+ *
+ * Participants: <UL>
+ *
+ * <LI> <code>Screen</code> - <i>Abstraction</i> that defines
+ * an interface for printing text and boxedText to stdout.
+ * <LI> <code>GreetingScreen</code> - <i>RefinedAbstraction</i> that prints
+ * a boxed greeting message
+ * <LI> <code>InformationScreen</code> - <i>RefinedAbstraction</i> that prints
+ * the system time (boxed)
+ * <LI> <code>ScreenImplementation</code> - <i>Implementor</i> interface,
+ * defines basic operations to output formatted strings
+ * <LI> <code>StarImplementation</code> - <i>ConcreteImplementation</i> that
+ * creates textBoxes of stars
+ * <LI> <code>CrossCapitalImplementation</code> - <i>ConcreteImplementation
+ * </i> that creates textBoxes of double crosses (hashes) and prints all
+ * text capitalized
+ * <LI> <code>AbstractionImplementation</code> - An aspect that defines
+ * the implementation of the methods of the <i>Abstraction</i>
+ * </UL><p>
+ *
+ * <i>This is the AspectJ implementation.</i><p>
+ *
+ * The implementations for methods on the <i>Abstraction</i> are declared
+ * in the <code>AbstractImplementation</code> aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Screen
+ * @see InformationScreen
+ * @see GreetingScreen
+ * @see ScreenImplementation
+ * @see StarImplementation
+ * @see CrossCapitalImplementation
+ * @see AbstractionImplementation
+ */
+
+
+public class Main {
+
+ /**
+ * Implements the driver for this example. The two different screens
+ * and screen implementations are tested in all possible combinations.
+ *
+ * @param args required by Java, but ignored
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Creating implementations...");
+
+ ScreenImplementation i1 = new StarImplementation();
+ ScreenImplementation i2 = new CrossCapitalImplementation();
+
+ System.out.println("Creating abstraction (screens) / implementation combinations...");
+
+ GreetingScreen gs1 = new GreetingScreen(i1);
+ GreetingScreen gs2 = new GreetingScreen(i2);
+ InformationScreen is1 = new InformationScreen(i1);
+ InformationScreen is2 = new InformationScreen(i2);
+
+ System.out.println("Starting test:\n");
+
+ gs1.drawText("\nScreen 1 (Refined Abstraction 1, Implementation 1):");
+ gs1.drawGreeting();
+
+ gs2.drawText("\nScreen 2 (Refined Abstraction 1, Implementation 2):");
+ gs2.drawGreeting();
+
+ is1.drawText("\nScreen 3 (Refined Abstraction 2, Implementation 1):");
+ is1.drawInfo();
+
+ is2.drawText("\nScreen 4 (Refined Abstraction 2, Implementation 2):");
+ is2.drawInfo();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Screen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Screen.java
new file mode 100644
index 000000000..67f0a34ff
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/Screen.java
@@ -0,0 +1,58 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+
+/**
+ * Represents the <i>Abstraction</i> in the scenario. <code>Screen</code>
+ * provides two methods to draw/print: <code>drawText(String)</code> and
+ * <code>drawTextBox(String)</code>. The method implementations are provided
+ * by an aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public interface Screen {
+
+ /**
+ * Draws or prints a text to an output device determined by the
+ * current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void drawText(String text);
+
+ /**
+ * Draws or prints a text in a box to an output device determined
+ * by the current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void drawTextBox(String text);
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/ScreenImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/ScreenImplementation.java
new file mode 100644
index 000000000..050912c6f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/ScreenImplementation.java
@@ -0,0 +1,56 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints lines, decorators and text. Represents a
+ * <i>Implementor</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public interface ScreenImplementation {
+
+ /**
+ * Prints a line feed.
+ */
+
+ void printLine();
+
+ /**
+ * Prints a decorator symbol (a string of length 1).
+ */
+
+ void printDecor();
+
+ /**
+ * Prints the argument text.
+ *
+ * @param text the text to print
+ */
+
+ void printText(String text);
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/StarImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/StarImplementation.java
new file mode 100644
index 000000000..eddcdebee
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/StarImplementation.java
@@ -0,0 +1,62 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints regular text and uses the star ("*") to decorate. Represents a
+ * <i>ConcreteImplementation</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class StarImplementation implements ScreenImplementation {
+
+ /**
+ * Does a line feed (to <code>System.out</code>).
+ */
+
+ public void printLine() {
+ System.out.println();
+ }
+
+ /**
+ * Prints a star ("*") to <code>System.out</code>.
+ */
+
+ public void printDecor() {
+ System.out.print("*");
+ }
+
+ /**
+ * Prints the argument text to <code>System.out</code>.
+ *
+ * @param text the text to print
+ */
+
+ public void printText(String text) {
+ System.out.print(text);
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/CrossCapitalImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/CrossCapitalImplementation.java
new file mode 100644
index 000000000..32456bda8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/CrossCapitalImplementation.java
@@ -0,0 +1,64 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints capitalized text and uses double crosses ("#") to decorate.
+ * Represents a <i>ConcreteImplementation</i> in the context of the Bridge
+ * design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class CrossCapitalImplementation implements ScreenImplementation {
+
+
+ /**
+ * Does a line feed (to <code>System.out</code>).
+ */
+
+ public void printLine() {
+ System.out.println();
+ }
+
+ /**
+ * Prints a double cross ("#") to <code>System.out</code>.
+ */
+
+ public void printDecor() {
+ System.out.print("X");
+ }
+
+ /**
+ * Prints the argument text in capitals to <code>System.out</code>.
+ *
+ * @param text the text to print
+ */
+
+ public void printText(String text) {
+ System.out.print(text.toUpperCase());
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/GreetingScreen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/GreetingScreen.java
new file mode 100644
index 000000000..5ce3507a2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/GreetingScreen.java
@@ -0,0 +1,57 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints/draws a greeting in a text box. Represents a <i>RefinedAbstraction
+ * </i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class GreetingScreen extends Screen {
+
+ /**
+ * Creates a new <code>GreetingScreen</code> object with the provided
+ * <i>Implementor</i>.
+ *
+ * @param si the implementor to use
+ */
+
+ public GreetingScreen(ScreenImplementation si) {
+ super(si);
+ }
+
+ /**
+ * Draws/prints a greeting in a text box
+ */
+
+ public void drawGreeting() {
+ drawTextBox("Greetings!");
+ }
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/InformationScreen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/InformationScreen.java
new file mode 100644
index 000000000..a15b6f562
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/InformationScreen.java
@@ -0,0 +1,62 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+
+/**
+ * Prints/draws the current system time in a text box. Represents a
+ * <i>RefinedAbstraction</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+import java.util.Date;
+
+public class InformationScreen extends Screen {
+
+
+ /**
+ * Creates a new <code>InformationScreen</code> object with the provided
+ * <i>Implementor</i>.
+ *
+ * @param si the implementor to use
+ */
+
+ public InformationScreen(ScreenImplementation si) {
+ super(si);
+ }
+
+
+ /**
+ * Draws/prints the system time in a text box
+ */
+
+ public void drawInfo() {
+ Date date = new Date();
+ drawTextBox("Current system time: "+date);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Main.java
new file mode 100644
index 000000000..a058cffb7
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Main.java
@@ -0,0 +1,110 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Bridge design pattern example. <p>
+ *
+ * Intent: <i> Decouple an abstraction from its implementation so that the
+ * two can vary independently.</i><p>
+ *
+ * Scenario: Have seperate hierarchies for Abstractions (here: Screens)
+ * and Implementors (here: ScreenImplementation), so that both
+ * can change independently of each other
+ *
+ * Participants: <UL>
+ *
+ * <LI> <code>Screen</code> - <i>Abstraction</i> that defines
+ * an interface for printing text and boxedText to System.out.
+ * <LI> <code>GreetingScreen</code> - <i>RefinedAbstraction</i> that prints
+ * a boxed greeting message
+ * <LI> <code>InformationScreen</code> - <i>RefinedAbstraction</i> that prints
+ * the system time (boxed)
+ * <LI> <code>ScreenImplementation</code> - <i>Implementor</i> interface,
+ * defines basic operations to output formatted strings
+ * <LI> <code>StarImplementation</code> - <i>ConcreteImplementation</i> that
+ * creates textBoxes of stars
+ * <LI> <code>CrossCapitalImplementation</code> - <i>ConcreteImplementation
+ * </i> that creates textBoxes of double crosses (hashes) and prints all
+ * text capitalized
+ * </UL><p>
+ *
+ * <i>This is the Java implementation.</i><p>
+ *
+ * Note that <i>Abstraction</i> cannot be an interface in Java, as we need to
+ * specify how <i>operation()</i> is performed using the interface of
+ * <i>Implementor</i>. As <i>Abstraction</i> is not necessarily a defining
+ * role, this is a limitation. With multiple inheritance, this would not be
+ * the case.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Screen
+ * @see InformationScreen
+ * @see GreetingScreen
+ * @see ScreenImplementation
+ * @see StarImplementation
+ * @see CrossCapitalImplementation
+ */
+
+
+public class Main {
+
+ /**
+ * Implements the driver for this example. The two different screens
+ * and screen implementations are tested in all possible combinations.
+ *
+ * @param args required by Java, but ignored
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Creating implementations...");
+
+ ScreenImplementation i1 = new StarImplementation();
+ ScreenImplementation i2 = new CrossCapitalImplementation();
+
+ System.out.println("Creating abstraction (screens) / implementation combinations...");
+
+ GreetingScreen gs1 = new GreetingScreen(i1);
+ GreetingScreen gs2 = new GreetingScreen(i2);
+ InformationScreen is1 = new InformationScreen(i1);
+ InformationScreen is2 = new InformationScreen(i2);
+
+ System.out.println("Starting test:\n");
+
+ gs1.drawText("\nScreen 1 (Refined Abstraction 1, Implementation 1):");
+ gs1.drawGreeting();
+
+ gs2.drawText("\nScreen 2 (Refined Abstraction 1, Implementation 2):");
+ gs2.drawGreeting();
+
+ is1.drawText("\nScreen 3 (Refined Abstraction 2, Implementation 1):");
+ is1.drawInfo();
+
+ is2.drawText("\nScreen 4 (Refined Abstraction 2, Implementation 2):");
+ is2.drawInfo();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Screen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Screen.java
new file mode 100644
index 000000000..5fbed961d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/Screen.java
@@ -0,0 +1,103 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+
+/**
+ * Represents the <i>Abstraction</i> in the scenario. <code>Screen</code>
+ * provides two methods to draw/print: <code>drawText(String)</code> and
+ * <code>drawTextBox(String)</code>. Both methods call appropriate methods
+ * on the <code>ScreenImplementor</code> of this <code>Screen</code> object.
+ *
+ * Note that cannot be an interface, since it has implementation
+ * associated with it (otherwise it would require multiple inheritance).
+ * This restricts the flexibility of the patter somewhat as all
+ * <i>RefinedAbstractions</i> consequently can not have additional
+ * superclasses.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public abstract class Screen {
+
+ /**
+ * stores the actual <i>Implementor</i> to use
+ */
+
+ private ScreenImplementation implementor;
+
+ /**
+ * Creates a new <code>Screen</code> object given an <i>Implementor</i>
+ *
+ * @param implementor the implementor to use for calls to
+ * <i>operationImpl()</i>
+ */
+
+ public Screen(ScreenImplementation implementor) {
+ this.implementor = implementor;
+ }
+
+ /**
+ * Draws or prints a text to an output device determined by the
+ * current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void drawText(String text) {
+ implementor.printText(text);
+ implementor.printLine();
+ }
+
+ /**
+ * Draws or prints a text in a box to an output device determined
+ * by the current <i>Implementor</i>.
+ *
+ * @param text The text to be drawn/printed
+ */
+
+ public void drawTextBox(String text) {
+
+ int length = text.length();
+
+ for(int i=0; i<length+4; i++) {
+ implementor.printDecor();
+ }
+
+ implementor.printLine();
+ implementor.printDecor();
+ implementor.printText(" "+text+" ");
+ implementor.printDecor();
+ implementor.printLine();
+
+ for(int i=0; i<length+4; i++) {
+ implementor.printDecor();
+ }
+
+ implementor.printLine();
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/ScreenImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/ScreenImplementation.java
new file mode 100644
index 000000000..1ea18ffd5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/ScreenImplementation.java
@@ -0,0 +1,56 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares methods to print lines, decorators and text. Represents an
+ * <i>Implementor</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public interface ScreenImplementation {
+
+ /**
+ * Prints a line feed.
+ */
+
+ void printLine();
+
+ /**
+ * Prints a decorator symbol (a string of length 1).
+ */
+
+ void printDecor();
+
+ /**
+ * Prints the argument text.
+ *
+ * @param text the text to print
+ */
+
+ void printText(String text);
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/StarImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/StarImplementation.java
new file mode 100644
index 000000000..87c00a36f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/bridge/java/StarImplementation.java
@@ -0,0 +1,62 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.bridge.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Prints regular text and uses stars ("*") to decorate. Represents a
+ * <i>ConcreteImplementation</i> in the context of the Bridge design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ */
+
+public class StarImplementation implements ScreenImplementation {
+
+ /**
+ * Does a line feed (to <code>System.out</code>).
+ */
+
+ public void printLine() {
+ System.out.println();
+ }
+
+ /**
+ * Prints a star ("*") to <code>System.out</code>.
+ */
+
+ public void printDecor() {
+ System.out.print("*");
+ }
+
+ /**
+ * Prints the argument text to <code>System.out</code>.
+ *
+ * @param text the text to print
+ */
+
+ public void printText(String text) {
+ System.out.print(text);
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Creator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Creator.java
new file mode 100644
index 000000000..a480a78a2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Creator.java
@@ -0,0 +1,70 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>Builder</i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see TextBuilder
+ * @see StructureBuilder
+ */
+
+public interface Creator {
+
+ /**
+ * Defines the <i>buildPart()</i> operation for type parts.
+ *
+ * @param type the type to process
+ */
+
+ public abstract void processType(String type);
+
+ /**
+ * Defines the <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param type the type to process
+ */
+
+ public abstract void processAttribute(String type);
+
+ /**
+ * Defines the <i>buildPart()</i> operation for value parts.
+ *
+ * @param type the type to process
+ */
+
+ public abstract void processValue(String type);
+
+ /**
+ * Defines the <i>getResult()</i> operation for <i>Builder</i>s.
+ *
+ * @param type the type to process
+ */
+
+ public String getRepresentation();
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/CreatorImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/CreatorImplementation.java
new file mode 100644
index 000000000..6a2a2638f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/CreatorImplementation.java
@@ -0,0 +1,76 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a concrete builder design pattern instance. This aspect allows
+ * to have the <code>Creator</code> abstract class to become an interface,
+ * without losing the possibility to declare default implementations and even
+ * variables.
+ *
+ * This also illiustrates the tradeoffs: The current version of AspectJ
+ * (1.0.4) does not allow protected introduction. To achieve the same result
+ * as in the OO case, the result variable has to be introduced as public
+ * (to be inherited). To make sure that no other classes can access that
+ * variable, we define an error here that the compiler reports when other
+ * classes try to access the result variable.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Builder
+ * @see TextBuilder
+ * @see StructureBuilder
+ */
+
+public aspect CreatorImplementation {
+
+ /**
+ * Declares the result variable on the <code>Creator</code> interface.
+ */
+
+ public String Creator.representation;
+
+ /**
+ * Declares the <i>getResult()</i> method with a default implementation
+ * to the <code>Creator</code> interface.
+ *
+ * @returns the representation string for the builder.
+ */
+
+ public String Creator.getRepresentation() {
+ return representation;
+ }
+
+ /**
+ * Declares a compiler error that gets reported if other classes
+ * (except Creators or this aspect) try to access the result variable.
+ */
+
+ declare error: (set(public String Creator+.representation)
+ || get(public String Creator+.representation))
+ && ! (within(Creator+)
+ || within(CreatorImplementation)):
+ "variable result is aspect protected. Use getResult() to access it";
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Main.java
new file mode 100644
index 000000000..e3101e89e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/Main.java
@@ -0,0 +1,97 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Builder design pattern example.<p>
+ *
+ * Intent: <i>Separate the construction of a complex object from its
+ * representation so that the same construction process can create different
+ * representations</i><p>
+ *
+ * Participating objects are <code>TextCreator</code> and
+ * <code>XMLCreator</code> as <i>Builder</i>s that implement the
+ * <code>Creator</code> interface.<p>
+ *
+ * In this example, <code>Main</code> acts as the <i>Director</i> that
+ * uses two different builders to build string representations of a
+ * person. <code>TextCreator</code> creates a text-like representation,
+ * <code>XMLCreator</code> an XML-like one.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * The abstract class is now replaced by an interface. A concrete aspect
+ * declares the instance variable and default method implementations.
+ * This frees the participants (<i>ConcreteBuilder</i>s) to be
+ * subclasses of something else.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Builder
+ * @see TextCreator
+ * @see XMLCreator
+ */
+
+public class Main {
+
+ /**
+ * Builds a string representation of a person using a given builder.
+ *
+ * @param the builder to use.
+ */
+
+ protected static void build(Creator builder) {
+ builder.processType("Person");
+ builder.processAttribute("Name");
+ builder.processValue("James Brick");
+ builder.processAttribute("Age");
+ builder.processValue("33");
+ builder.processAttribute("Occupation");
+ builder.processValue("Builder");
+ }
+
+ /**
+ * Implements the driver for the Builder design pattern example.<p>
+ *
+ * In this example, <code>Main</code> acts as the <i>Director</i> that
+ * uses two different builders to build string representations of a
+ * person. <code>TextCreator</code> creates a text-like representation,
+ * <code>XMLCreator</code> an XML-like one.
+ *
+ * @param args the command-line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+
+ Creator builder1 = new TextCreator();
+ Creator builder2 = new XMLCreator();
+
+ build(builder1);
+ build(builder2);
+
+ System.out.println(builder1.getRepresentation());
+ System.out.println(builder2.getRepresentation());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/TextCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/TextCreator.java
new file mode 100644
index 000000000..43307c021
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/TextCreator.java
@@ -0,0 +1,66 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteBuilder</i> that builds textual descriptions
+ * of complex objects consisting of type, attributes and values. This version
+ * makes use of the default implementation of <code>getRepresentation()</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class TextCreator implements Creator {
+
+ /**
+ * Defines a <i>buildPart()</i> operation for type parts.
+ *
+ * @param newType the type to process
+ */
+
+ public void processType(String newType) {
+ representation = "This is a new "+newType+":\n";
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param newAttribute the type to process
+ */
+
+ public void processAttribute(String newAttribute) {
+ representation += ("Its " + newAttribute + " is ");
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for value parts.
+ *
+ * @param newValue the value to process
+ */
+
+ public void processValue(String newValue) {
+ representation += (newValue + ".\n");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/XMLCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/XMLCreator.java
new file mode 100644
index 000000000..ff66a4184
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/XMLCreator.java
@@ -0,0 +1,103 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteBuilder</i> that builds XML descriptions
+ * of complex objects consisting of type, attributes and values.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class XMLCreator implements Creator {
+
+ protected String type = null;
+ protected String attribute = null;
+
+ /**
+ * Defines a <i>buildPart()</i> operation for type parts.
+ *
+ * @param newType the type to process
+ */
+
+ public void processType(String newType) {
+ representation = "<"+newType+">\n";
+ type = newType;
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param newAttribute the attribute to process
+ */
+
+ public void processAttribute(String newAttribute) {
+ checkAttribute();
+ representation += ("\t<" + newAttribute + ">");
+ this.attribute = newAttribute;
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for value parts.
+ *
+ * @param newValue the type to process
+ */
+
+ public void processValue(String newValue) {
+ representation += newValue;
+ }
+
+ /**
+ * Checks wether the opening type tag is closed and closes it if not.
+ */
+
+ protected void checkType() {
+ if (type != null) {
+ representation += ("</" + type + ">\n");
+ type = null;
+ }
+ }
+
+ /**
+ * Checks wether the opening attribute tag is closed and closes it if not.
+ */
+
+ protected void checkAttribute() {
+ if (attribute != null) {
+ representation += ("</" + attribute + ">\n");
+ attribute = null;
+ }
+ }
+
+ /**
+ * Defines the <i>getResult()</i> operation for <i>Builder</i>s.
+ */
+
+ public String getRepresentation() {
+ checkAttribute();
+ checkType();
+ return representation;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Creator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Creator.java
new file mode 100644
index 000000000..828540806
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Creator.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>Builder</i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see TextCreator
+ * @see XMLCreator
+ */
+
+public abstract class Creator {
+
+ /**
+ * An inheritable variable that carries the result of the build.
+ */
+
+ protected String representation;
+
+ /**
+ * Defines a <i>buildPart()</i> operation for type parts.
+ *
+ * @param type the type to process
+ */
+
+ public abstract void processType(String type);
+
+ /**
+ * Defines a <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param newAttribute the attribute to process
+ */
+
+ public abstract void processAttribute(String newAttribute);
+
+ /**
+ * Defines a <i>buildPart()</i> operation for value parts.
+ *
+ * @param newValue the value to process
+ */
+
+ public abstract void processValue(String newValue);
+
+ /**
+ * Defines a <i>getResult()</i> operation for <i>Builder</i>s.
+ * This is the default implementation.
+ *
+ * @return a representation of the build result
+ */
+
+ public String getRepresentation() {
+ return representation;
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Main.java
new file mode 100644
index 000000000..217eda258
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/Main.java
@@ -0,0 +1,99 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Builder design pattern example.<p>
+ *
+ * Intent: <i>Separate the construction of a complex object from its
+ * representation so that the same construction process can create different
+ * representations</i><p>
+ *
+ * Participating objects are <code>TextCreator</code> and
+ * <code>XMLCreator</code> which act as <i>Builder</i>s that implement the
+ * <code>Creator</code> interface.<p>
+ *
+ * In this example, <code>Main</code> acts as the <i>Director</i> that
+ * uses two different builders to build string representations of a
+ * person. <code>TextCreator</code> creates a text-like representation,
+ * <code>XMLCreator</code> an XML-like one.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * In Java, the <i>Builder</i> has to be an abstract class (as opposed to
+ * an interface) to allow to define variables or default implementations.
+ * Consequently, all <i>ConcreteBuilders</i> have to have that
+ * class as their superclass, making it impossible to be part of another
+ * class hierarchy.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ *
+ * @see Builder
+ * @see TextCreator
+ * @see XMLCreator
+ */
+
+public class Main {
+
+ /**
+ * Builds a string representation of a person using a given builder.
+ *
+ * @param builder the builder to use.
+ */
+
+ protected static void build(Creator builder) {
+ builder.processType("Person");
+ builder.processAttribute("Name");
+ builder.processValue("James Brick");
+ builder.processAttribute("Age");
+ builder.processValue("33");
+ builder.processAttribute("Occupation");
+ builder.processValue("Builder");
+ }
+
+ /**
+ * Implements the driver for the Builder design pattern example.<p>
+ *
+ * In this example, <code>Main</code> acts as the <i>Director</i> that
+ * uses two different builders to build string representations of a
+ * person. <code>TextCreator</code> creates a text-like representation,
+ * <code>XMLCreator</code> an XML-like one.
+ *
+ * @param args the command-line parameters, unused.
+ *
+ */
+
+ public static void main(String[] args) {
+
+ Creator builder1 = new TextCreator();
+ Creator builder2 = new XMLCreator();
+
+ build(builder1);
+ build(builder2);
+
+ System.out.println(builder1.getRepresentation());
+ System.out.println(builder2.getRepresentation());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/TextCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/TextCreator.java
new file mode 100644
index 000000000..397144108
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/TextCreator.java
@@ -0,0 +1,66 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteBuilder</i> that builds textual descriptions
+ * of complex objects consisting of type, attributes and values. This version
+ * makes use of the default implementation of <code>getResult()</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class TextCreator extends Creator {
+
+ /**
+ * Defines a <i>buildPart()</i> operation for type parts.
+ *
+ * @param newType the type to process
+ */
+
+ public void processType(String newType) {
+ representation = "This is a new "+newType+":\n";
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param newAttribute the attribute to process
+ */
+
+ public void processAttribute(String newAttribute) {
+ representation += ("Its " + newAttribute + " is ");
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for value parts.
+ *
+ * @param newValue the value to process
+ */
+
+ public void processValue(String newValue) {
+ representation += (newValue + ".\n");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/XMLCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/XMLCreator.java
new file mode 100644
index 000000000..8c678ea9c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/builder/java/XMLCreator.java
@@ -0,0 +1,90 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.builder.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteBuilder</i> that builds XML descriptions
+ * of complex objects consisting of type, attributes and values.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/26/04
+ */
+
+public class XMLCreator extends Creator {
+
+ protected String type = null;
+ protected String attribute = null;
+
+ /**
+ * Defines a <i>buildPart()</i> operation for type parts.
+ *
+ * @param newType the type to process
+ */
+
+ public void processType(String newType) {
+ representation = "<"+newType+">\n";
+ type = newType;
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for attribute parts.
+ *
+ * @param newAttribute the attribute to process
+ */
+
+ public void processAttribute(String newAttribute) {
+ if (attribute != null) {
+ representation += ("</" + attribute + ">\n");
+ }
+ representation += ("\t<" + newAttribute + ">");
+ this.attribute = newAttribute;
+ }
+
+ /**
+ * Defines a <i>buildPart()</i> operation for value parts.
+ *
+ * @param newValue the value to process
+ */
+
+ public void processValue(String newValue) {
+ representation += (newValue);
+ }
+
+ /**
+ * Defines the <i>getResult()</i> operation for <i>Builder</i>s. Includes
+ * a default implementation.
+ */
+
+ public String getRepresentation() {
+ if (attribute != null) {
+ representation += ("</" + attribute + ">\n");
+ attribute = null;
+ }
+ if (type != null) {
+ representation += ("</" + type + ">\n");
+ type = null;
+ }
+ return representation;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Button.java
new file mode 100644
index 000000000..ba0aa96f6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Button.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * A simple GUI button that implements its own ActionListener.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Button extends JButton {
+
+ /**
+ * Creates a Button widget. An ActionListener is also added that calls
+ * the <code>doClick(Click)</code> method when the button is pressed
+ *
+ * @param label the button label
+ */
+
+ public Button(String label) {
+ super(label);
+ this.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ doClick(new Click(ae));
+ }
+ });
+ }
+
+
+ /**
+ * An empty method that is called when the button is clicked. This method
+ * could also be defined in the concrete aspect.
+ *
+ * @param click the <code>Click</code> that was created when the
+ * button was clicked.
+ */
+
+ public void doClick(Click click) {}
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Click.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Click.java
new file mode 100644
index 000000000..fc524c0eb
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Click.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Represents the <i>Request</i> in the <i>Chain of Responsibility</i>
+ * pattern, which is a button click in this case. Provides methods for
+ * accessing key masks associated with the click (to find out whether
+ * the SHIFT, ALT, or CTRL keys were pressed during the click).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Click {
+
+ /**
+ * the ActionEvent that describes this Click
+ */
+
+ protected ActionEvent description;
+
+ /**
+ * Creates a <code>Click</code> described by the provided <code>
+ * ActionEvent</code>.
+ *
+ * @param description the ActionEvent that describes this Click
+ */
+
+ public Click(ActionEvent description) {
+ this.description = description;
+ }
+
+ /**
+ * Convenience method for inquiring whether SHIFT was pressed while
+ * the click occured.
+ *
+ * @return whether the SHIFT key was pressed when the click occured
+ */
+
+ public boolean hasShiftMask() {
+ return ((description.getModifiers() & ActionEvent.SHIFT_MASK) != 0 );
+ }
+
+ /**
+ * Convenience method for inquiring whether ALT was pressed while
+ * the click occured.
+ *
+ * @return whether the ALT key was pressed when the click occured
+ */
+
+ public boolean hasAltMask() {
+ return ((description.getModifiers() & ActionEvent.ALT_MASK) != 0 );
+ }
+
+ /**
+ * Convenience method for inquiring whether CTRL was pressed while
+ * the click occured.
+ *
+ * @return whether the CTRL key was pressed when the click occured
+ */
+
+ public boolean hasCtrlMask() {
+ return ((description.getModifiers() & ActionEvent.CTRL_MASK) != 0 );
+ }
+
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/ClickChain.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/ClickChain.java
new file mode 100644
index 000000000..96223074c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/ClickChain.java
@@ -0,0 +1,102 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.event.ActionEvent;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ChainOfResponsibilityProtocol;
+
+/**
+ * Implements an instance of the abstracted ChainOfResponsibility design
+ * pattern. Here, the a click on the button triggers an event (request)
+ * that gets passed along the widget hierarchy (button -> panel -> frame).
+ *
+ * In this implementation, the request is handled by the panel if the
+ * CTRL mask is active (i.e., if the CTRL key was pressed while the button
+ * was clicked). If the SHIFT mask is active, the frame handles the request.
+ * Otherwise, the request is unhandled.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public aspect ClickChain extends ChainOfResponsibilityProtocol {
+
+ /**
+ * Frame, Panel and Button are all Handlers
+ */
+
+ declare parents: Frame implements Handler;
+ declare parents: Panel implements Handler;
+ declare parents: Button implements Handler;
+
+ declare parents: Click implements Request;
+
+
+ protected pointcut eventTrigger(Handler handler, Request request):
+ call(void Button.doClick(Click)) && target(handler) && args(request);
+
+
+ public boolean Button.acceptRequest(Request request) {
+ System.out.println("Button is asked to accept the request...");
+ if (request instanceof Click) {
+ Click click = (Click) request;
+ return (click.hasShiftMask());
+ }
+ return false;
+ }
+
+ public void Button.handleRequest(Request request) {
+ System.out.println("Button is handling the event.\n");
+ }
+
+
+ public boolean Panel.acceptRequest(Request request) {
+ System.out.println("Panel is asked to accept the request...");
+ if (request instanceof Click) {
+ Click click = (Click) request;
+ return (click.hasCtrlMask());
+ }
+ return false;
+ }
+
+ public void Panel.handleRequest(Request event) {
+ System.out.println("Panel is handling the event.\n");
+ }
+
+
+ public boolean Frame.acceptRequest(Request request) {
+ System.out.println("Frame is asked to accept the request...");
+ if (request instanceof Click) {
+ Click click = (Click) request;
+ return (click.hasAltMask());
+ }
+ return false;
+ }
+
+ public void Frame.handleRequest(Request event) {
+ System.out.println("Frame is handling the event.\n");
+ }
+
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Frame.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Frame.java
new file mode 100644
index 000000000..c91e12c4a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Frame.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+
+import javax.swing.JFrame;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowAdapter;
+
+/**
+ * Represents a regular GUI frame. No pattern-specific modifications are
+ * needed here. A WindowListener is added.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Frame extends JFrame {
+
+ /**
+ * Creates a <code>Frame</code> with a given title that responds
+ * properly to <code>WindowClosing<code> events
+ *
+ * @param title the frame title
+ */
+
+ public Frame(String title) {
+ super(title);
+
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+}
+
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Main.java
new file mode 100644
index 000000000..28add4a5f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Main.java
@@ -0,0 +1,108 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a GUI-motivated example for the Chain Of Rspsonsibility design
+ * pattern.<p>
+ *
+ * Intent: <i>Avoid coupling the sender of a request to its receiver by giving
+ * more than one object a chance to handle the request. Chain the receiving
+ * objects and pass the request along the chain until an object handles it.
+ * </i><p>
+ *
+ * Participatng objects are a <code>Frame</code>, a <code>Panel</code>, and
+ * <code>Button</code>
+ *
+ * A click on the button triggers an event (request) that gets passed along
+ * the widget hierarchy (button -> panel -> frame).
+ *
+ * The <code>Handler</code> interface defines the <code>handleRequest()</code>
+ * method for asking an object if it is willing to handle the request.
+ *
+ * Clicking the button will start a request, that gets passed on
+ * along the following chain: button, panel, frame. Depending on
+ * whether the ALT, SHIFT, or CTRL keys are pressed during the
+ * button click, a different object in the chain will handle the
+ * request:
+ *
+ * <ol>
+ * <li> If the SHIFT key is pressed, Button will handle the request
+ * <li> If the CTRL key is pressed, Panel will handle the request
+ * <li> If the ALT key is pressed, Frame will handle the request
+ * <li> If no keys are pressed, the request will not be handled and
+ * an exception will be raised.
+ * </ol>
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * In this implementation, the former <i>ConcreteHandlers</i> do not
+ * contain any pattern code at all. The shared logic for forwarding requests
+ * is implemented once in the reusable abstract library aspect. The current
+ * implementation does require some casts (as generally the case in AspectJ
+ * solutions that employ similar approaches), due to the lack of support for
+ * generics.
+ *
+ * For limitations of this approach, see the ChainOfResponsibilityProtocol
+ * library aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ * @see Button
+ * @see Panel
+ * @see Frame
+ * @see MyChain
+ * @see ChainOfResponsibilityProtocol
+ */
+
+public class Main {
+
+ /**
+ * Implements a GUI-motivated example for the Chain Of Responsibility design
+ * pattern.<p>
+ *
+ * In this implementation, the request is handled by the panel if the
+ * CTRL mask is active (i.e., if the CTRL key was pressed while the button
+ * was clicked). If the SHIFT mask is active, the frame handles the request.
+ * Otherwise, the request is unhandled.
+ *
+ * @param args command line parameters, unused
+ */
+
+ public static void main(String[] args) {
+ Frame frame = new Frame("Chain of Responsibility pattern example");
+ Panel panel = new Panel();
+ Button button = new Button("Click me to see the pattern in action! Use <SHIFT>, <CTRL>, and <ALT> during clicks to see different behavior");
+
+ ClickChain.aspectOf().setSuccessor(button, panel);
+ ClickChain.aspectOf().setSuccessor(panel, frame);
+
+ frame.getContentPane().add(panel);
+ panel.add(button);
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Panel.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Panel.java
new file mode 100644
index 000000000..1e268a840
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/Panel.java
@@ -0,0 +1,37 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+
+/**
+ * A regular GUI JPanel with no modifications
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Panel extends JPanel {}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Button.java
new file mode 100644
index 000000000..5513ea367
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Button.java
@@ -0,0 +1,86 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * GUI element at the start of the responsibility chain. A click on the
+ * button starts a request. The <code>Button</code> will only handle the
+ * request if the SHIFT key was pressed when the button was clicked.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Button extends JButton implements ClickHandler {
+
+ /**
+ * the successor in the chain of responsibility
+ */
+
+ protected ClickHandler successor;
+
+ /**
+ * Creates a <code>Button</code> with a given label and successor.
+ *
+ * @param label The button label
+ * @param successor The successor in the chain of responsibility
+ */
+
+ public Button(String label, ClickHandler successor) {
+ super(label);
+ this.successor = successor;
+ this.addActionListener( new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ handleClick(new Click(ae));
+ }
+ });
+ }
+
+ /**
+ * Implements the method to handle requests as defined by the
+ * <code>ClickHandler</code> interface. The request is only handled here
+ * if the SHIFT key was pressed.
+ *
+ * @see ClickHandler
+ */
+
+ public void handleClick(Click click) {
+ System.out.println("Button is asked to handle the request...");
+ if (click.hasShiftMask()) {
+ System.out.println("Button handles the request.");
+ } else {
+ if (successor == null) {
+ throw new RuntimeException("request unhandled (end of chain reached)");
+ } else {
+ successor.handleClick(click);
+ }
+ }
+ }
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Click.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Click.java
new file mode 100644
index 000000000..334fbfac5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Click.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Represents the <i>Request</i> in the <i>Chain of Responsibility</i>
+ * pattern, which is a button click in this case. Provides methods for
+ * accessing key masks associated with the click (to find out whether
+ * the SHIFT, ALT, or CTRL keys were pressed during the click).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Click {
+
+ /**
+ * the ActionEvent that describes this Click
+ */
+
+ protected ActionEvent description;
+
+ /**
+ * Creates a <code>Click</code> described by the provided <code>
+ * ActionEvent</code>.
+ *
+ * @param description the ActionEvent that describes this Click
+ */
+
+ public Click(ActionEvent description) {
+ this.description = description;
+ }
+
+ /**
+ * Convenience method for inquiring whether SHIFT was pressed while
+ * the click occured.
+ *
+ * @return whether the SHIFT key was pressed when the click occured
+ */
+
+ public boolean hasShiftMask() {
+ return ((description.getModifiers() & ActionEvent.SHIFT_MASK) != 0 );
+ }
+
+ /**
+ * Convenience method for inquiring whether ALT was pressed while
+ * the click occured.
+ *
+ * @return whether the ALT key was pressed when the click occured
+ */
+
+ public boolean hasAltMask() {
+ return ((description.getModifiers() & ActionEvent.ALT_MASK) != 0 );
+ }
+
+ /**
+ * Convenience method for inquiring whether CTRL was pressed while
+ * the click occured.
+ *
+ * @return whether the CTRL key was pressed when the click occured
+ */
+
+ public boolean hasCtrlMask() {
+ return ((description.getModifiers() & ActionEvent.CTRL_MASK) != 0 );
+ }
+
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/ClickHandler.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/ClickHandler.java
new file mode 100644
index 000000000..c0436fc38
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/ClickHandler.java
@@ -0,0 +1,38 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for letting <i>ConcreteHandlers</i> handle a request
+ * (here: a button click).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public interface ClickHandler {
+ public void handleClick(Click click);
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Frame.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Frame.java
new file mode 100644
index 000000000..10e1ac2a5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Frame.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowAdapter;
+
+
+/**
+ * Represents a regular GUI frame modified to play its role in the
+ * <i>Chain of Responisiblity</i> pattern, i.e. to handle requests and/or
+ * forward them to its successor in the chain.
+ *
+ * Requests are only handled if the ALT key is pressed during a click.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Frame extends JFrame implements ClickHandler {
+
+ /**
+ * the successor in the chain of responsibility
+ */
+
+ protected ClickHandler successor;
+
+
+ /**
+ * Creates a <code>Frame</code> with a given title that responds
+ * properly to <code>WindowClosing<code> events. The frame
+ * does not have a successor and handles request that it receives.
+ *
+ * @param title the frame title
+ */
+
+ public Frame(String title) {
+ super(title);
+
+ this.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ }
+
+ /**
+ * Implements the method to handle requests as defined by the
+ * <code>ClickHandler</code> interface. The request is only handled here
+ * if the ALT key was pressed.
+ *
+ * @see ClickHandler
+ */
+
+ public void handleClick(Click click) {
+ System.out.println("Frame is asked to handle the request...");
+ if (click.hasAltMask()) {
+ System.out.println("Frame handles the request.");
+ } else {
+ if (successor == null) {
+ throw new RuntimeException("request unhandled (end of chain reached)");
+ } else {
+ successor.handleClick(click);
+ }
+ }
+ }
+}
+
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Main.java
new file mode 100644
index 000000000..fda1db4e3
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Main.java
@@ -0,0 +1,102 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a GUI-motivated example for the Chain Of Rspsonsibility design
+ * pattern.<p>
+ *
+ * Intent: <i>Avoid coupling the sender of a request to its receiver by giving
+ * more than one object a chance to handle the request. Chain the receiving
+ * objects and pass the request along the chain until an object handles it.
+ * </i><p>
+ *
+ * Participatng objects are a <code>Frame</code>, a <code>Panel</code>, and
+ * <code>Button</code>
+ *
+ * A click on the button triggers an event (request) that gets passed along
+ * the widget hierarchy (button -> panel -> frame).
+ *
+ * The <code>Handler</code> interface defines the <code>handleRequest()</code>
+ * method for asking an object if it is willing to handle the request.
+ *
+ * If an object chooses not to handle a click, the event gets forwarded to
+ * the the object's successor. If such a successor does not exist, an
+ * appropriate message is shown.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * In this version, it is not possible to extract the common code for
+ * the case that the object does not want to handle the click into the
+ * <code>ClickHandler</code> interface. The reason for this is that this would
+ * turn <code>ClickHandler</code> into an abstract class. Since Java
+ * does not support multiple inheritance and the individual <code>
+ * ConcreteHandlers</code> already extend other classes (GUI elements here),
+ * this would not work. The result is some code duplication in the
+ * implementation of the <code>handleClick(..)</code> methods.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ * @see Button
+ * @see Panel
+ * @see Frame
+ * @see Handler
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the chain of responisbility example.
+ * It creates a simple GUI consisting of a <code>Button</code> in a
+ * <code>Panel</code> in a <code>Frame</code>.
+ *
+ * Clicking the button will start a request, that gets passed on
+ * along the following chain: button, panel, frame. Depending on
+ * whether the ALT, SHIFT, or CTRL keys are pressed during the
+ * button click, a different object in the chain will handle the
+ * request:
+ *
+ * <ol>
+ * <li> If the SHIFT key is pressed, Button will handle the request
+ * <li> If the CTRL key is pressed, Panel will handle the request
+ * <li> If the ALT key is pressed, Frame will handle the request
+ * <li> If no keys are pressed, the request will not be handled and
+ * an exception will be raised.
+ * </ol>
+ */
+
+ public static void main(String[] args) {
+
+ Frame frame = new Frame("Chain of Responsibility");
+ Panel panel = new Panel(frame);
+ Button button = new Button("Click me to see the pattern in action! Use <SHIFT>, <CTRL>, and <ALT> during clicks to see different behavior", panel);
+
+ frame.getContentPane().add(panel);
+ panel.add(button);
+
+ frame.pack();
+ frame.setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Panel.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Panel.java
new file mode 100644
index 000000000..30ed13378
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/chainOfResponsibility/java/Panel.java
@@ -0,0 +1,81 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+
+/**
+ * Represents a regular GUI panel modified to play its role in the
+ * <i>Chain of Responisiblity</i> pattern, i.e. to handle requests and/or
+ * forward them to its successor in the chain.
+ *
+ * Requests are only handled if the CTRL key is pressed during a click.
+
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public class Panel extends JPanel implements ClickHandler {
+
+ /**
+ * the successor in the chain of responsibility
+ */
+
+ protected ClickHandler successor;
+
+ /**
+ * Creates a <code>Panel</code> with a given successor.
+ *
+ * @param successor The successor in the chain of responsibility
+ */
+
+ public Panel(ClickHandler successor) {
+ super();
+ this.successor = successor;
+ }
+
+
+ /**
+ * Implements the method to handle requests as defined by the
+ * <code>ClickHandler</code> interface. The request is only handled here.
+ * if the CTRL key was pressed.
+ *
+ * @see ClickHandler
+ */
+
+ public void handleClick(Click click) {
+ System.out.println("Panel is asked to handle the request...");
+ if (click.hasCtrlMask()) {
+ System.out.println("Panel handles the request.");
+ } else {
+ if (successor == null) {
+ throw new RuntimeException("request unhandled (end of chain reached)");
+ } else {
+ successor.handleClick(click);
+ }
+ }
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Button.java
new file mode 100644
index 000000000..4bdba0936
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Button.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Implements a simple extension of JButton that supplies its own
+ * ActionListener and calls its own <code>clicked()</code> method
+ * whenever the button is pressed.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ */
+
+public class Button extends JButton {
+
+ /**
+ * Creates a new button with the provided label
+ *
+ * @param name the label of the button
+ */
+
+ public Button(String label) {
+ super(label);
+ this.setActionCommand(label);
+ this.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ clicked();
+ }
+ });
+ }
+
+ /**
+ * Stub method that is called whenever the button is pressed.
+ */
+
+ public void clicked() {}
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand.java
new file mode 100644
index 000000000..573bcda5e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand.java
@@ -0,0 +1,52 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Command;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandReceiver;
+
+/**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand executed"</quote>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public class ButtonCommand implements Command {
+
+ private Printer printer = new Printer();
+
+ /**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand executed"</quote>.
+ */
+
+ public void executeCommand(CommandReceiver receiver ) {
+ printer.println("ButtonCommand executed");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand2.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand2.java
new file mode 100644
index 000000000..393c721eb
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommand2.java
@@ -0,0 +1,40 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample class that becomes a <i>Command</i> in the pattern
+ * context. Instead of implementing the <i>Command</i> interface directly,
+ * the pattern aspect assigns that role to this class and ensures
+ * implementation of the <code>executeCommand()</code> method.<p>
+ *
+ * This illustrates that any exisiting class can be turned into a <i>Command
+ * </i> without having to change the class itself.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public class ButtonCommand2 {}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommanding.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommanding.java
new file mode 100644
index 000000000..a53f98fa9
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/ButtonCommanding.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandProtocol;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Command;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandInvoker;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandReceiver;
+import java.io.PrintStream;
+
+/**
+ * Sets up the Command pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Button
+ */
+
+public aspect ButtonCommanding extends CommandProtocol {
+
+ declare parents: Button implements CommandInvoker;
+ declare parents: Printer implements CommandReceiver;
+ declare parents: ButtonCommand implements Command; // Unneccessay
+ declare parents: ButtonCommand2 implements Command; // "Making" a class
+ // a Command
+
+ /**
+ * Implements a sample <i>Command</i> for the ButtonCommand2 class.
+ * This one prints a short message to <code>System.out</code>
+ * whenever it executes. The message is
+ * <quote>"ButtonCommand number 2 executed"</quote>.
+ */
+
+ public void ButtonCommand2.executeCommand(CommandReceiver receiver) {
+ ((Printer) receiver).println("ButtonCommand number 2 executed");
+ }
+
+ /**
+ * The join points after which to execute the command.
+ * This replaces the normally scattered myCommand.execute() calls.
+ * In this example, a call to <code>Button.clicked()</code> triggers
+ * the execution of the command.
+ *
+ * @param invoker the object invoking the command
+ */
+
+ protected pointcut commandTrigger(CommandInvoker invoker):
+ call(void Button.clicked()) && target(invoker);
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Main.java
new file mode 100644
index 000000000..e3953d23d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Main.java
@@ -0,0 +1,104 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Command;
+
+/**
+ * Implements the driver for the command design pattern example.<p>
+ *
+ * Intent: <i>Encapsulate a request as an object, thereby letting you
+ * parameterize clients with different requests, queue or log requests,
+ * and support undoable operations.</i><p>
+ *
+ * Participating objects are <code>Button</code>s as <i>Invoker</i>s,
+ * and a <code>ButtonCommand</code> and <code>ButtonCommand2</code> as
+ * two <i>ConcreteCommand</i>s.
+ *
+ * This example creates a simple GUI with three buttons. Each button has a
+ * command associated with it that is executed when the button is pressed.
+ * Button1 and button3 have the same command, button2 has a different one.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * This version of the pattern lets the developer specify what should trigger
+ * a call to <code>executeCommand()</code>, without changing the <i>Invoker
+ * </i> code.
+ *
+ * Neither <i>Commands</i> nor <i>Invoker</i> have to know of their
+ * involvement in the pattern and can actually act as both.
+ * <code>ButtonCommanding2</code> is an example of a <i>Command</i> that
+ * is unaware of its role. In such cases, the concrete pattern instance
+ * aspect assigns the role and defines the <i>Command</i>'s behavior.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Button
+ * @see ButtonCommand
+ * @see Buttoncommand2
+ */
+
+public class Main extends JFrame {
+
+ /**
+ * This example creates a simple GUI with three buttons. Each
+ * button has a <i>Command</i> associated with it that is executed when
+ * the button is pressed. Button1 and button3 have the same command,
+ * button2 has a different one.
+ */
+
+ public static void main(String[] args) {
+ Button button1 = new Button("Button1");
+ Button button2 = new Button("Button2");
+ Button button3 = new Button("Button3");
+
+ Command com1 = new ButtonCommand();
+ Command com2 = new ButtonCommand2();
+
+ JPanel pane = new JPanel();
+ pane.add(button1);
+ ButtonCommanding.aspectOf().setCommand(button1, com1);
+
+ pane.add(button2);
+ ButtonCommanding.aspectOf().setCommand(button2, com2);
+ ButtonCommanding.aspectOf().setReceiver(com2, new Printer());
+
+ pane.add(button3);
+ ButtonCommanding.aspectOf().setCommand(button3, com1);
+
+ JFrame frame = new JFrame("Command Pattern Example");
+
+ frame.getContentPane().add(pane);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+ frame.pack();
+ frame.setVisible(true); }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Printer.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Printer.java
new file mode 100644
index 000000000..edc7d9d39
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/Printer.java
@@ -0,0 +1,38 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Helper class that is used as a receiver for the Command pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ */
+
+public class Printer {
+ public void println(String s) {
+ System.out.println(s);
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Button.java
new file mode 100644
index 000000000..3e5784fcd
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Button.java
@@ -0,0 +1,87 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Implements a simple extension of JButton that supplies its own
+ * ActionListener and calls its own <code>clicked()</code> method
+ * whenever the button is pressed. This method calls the <code>
+ * executeCommand()</code> method on the button's associated <i>Command</i>
+ * object.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+
+public class Button extends JButton {
+
+ /**
+ * the command object associated with this button
+ */
+
+ protected Command command;
+
+ /**
+ * Creates a new button with the provided label
+ *
+ * @param label the label of the button
+ */
+
+ public Button(String label) {
+ super(label);
+ this.setActionCommand(label);
+ this.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ clicked();
+ }
+ });
+ }
+
+ /**
+ * Calls <code>ececuteCommand()</code> on the associated
+ * command object. This method gets called whenever the
+ * button is pressed.
+ */
+
+ public void clicked() {
+ if (command != null) {
+ command.executeCommand();
+ }
+ }
+
+ /**
+ * Sets the associated command object for this button
+ *
+ * @param command the new <i>Command</i> object.
+ */
+
+ public void setCommand(Command command) {
+ this.command = command;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand.java
new file mode 100644
index 000000000..9d0bb69d1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand.java
@@ -0,0 +1,46 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand executed"</quote>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public class ButtonCommand implements Command {
+
+/**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand executed"</quote>.
+ */
+ public void executeCommand() {
+ System.out.println("ButtonCommand executed");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand2.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand2.java
new file mode 100644
index 000000000..3844bda1a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/ButtonCommand2.java
@@ -0,0 +1,47 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand number 2 executed"</quote>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public class ButtonCommand2 implements Command {
+
+/**
+ * Implements a sample command. This one prints a short message to
+ * <code>System.out</code> whenever it executes. The message is
+ * <quote>"ButtonCommand number 2 executed"</quote>.
+ */
+
+ public void executeCommand() {
+ System.out.println("ButtonCommand number 2 executed");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Command.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Command.java
new file mode 100644
index 000000000..d441f43ab
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Command.java
@@ -0,0 +1,40 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>Command</i> objects.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public interface Command {
+
+ /**
+ * Executes the command.
+ */
+
+ public void executeCommand();
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Main.java
new file mode 100644
index 000000000..3a81bda07
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/command/java/Main.java
@@ -0,0 +1,98 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.command.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/**
+ * Implements the driver for the command design pattern example.<p>
+ *
+ * Intent: <i>Encapsulate a request as an object, thereby letting you
+ * parameterize clients with different requests, queue or log requests,
+ * and support undoable operations.</i><p>
+ *
+ * Participating objects are <code>Button</code>s as <i>Invoker</i>s,
+ * and a <code>ButtonCommand</code> and <code>ButtonCommand2</code> as
+ * two <i>ConcreteCommand</i>s.
+ *
+ * This example creates a simple GUI with three buttons. Each button has a
+ * command associated with it that is executed when the button is pressed.
+ * Button1 and button3 have the same command, button2 has a different one.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Both commands and invoker have to have pattern-related code.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Button
+ * @see Command
+ * @see ButtonCommand
+ * @see Buttoncommand2
+ */
+
+public class Main {
+
+ /**
+ * This example creates a simple GUI with three buttons. Each button has a
+ * command associated with it that is executed when the button is pressed.
+ * Button1 and button3 have the same command, button2 has a different one.
+ */
+
+ public static void main(String[] args) {
+
+ Button button1 = new Button("Print Date");
+ Button button2 = new Button("Command 1");
+ Button button3 = new Button("Command 2");
+
+ Command com1 = new ButtonCommand();
+ Command com2 = new ButtonCommand2();
+
+ JPanel pane = new JPanel();
+ pane.add(button1);
+ button1.setCommand(com1);
+
+ pane.add(button2);
+ button2.setCommand(com2);
+
+ pane.add(button3);
+ button3.setCommand(com1);
+
+ // Note: Can not have two commands.
+ // That is within the pattern specification
+
+ JFrame frame = new JFrame("Command Pattern Example");
+
+ frame.getContentPane().add(pane);
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+ frame.pack();
+ frame.setVisible(true);
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Directory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Directory.java
new file mode 100644
index 000000000..d40f6363b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Directory.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>Composite</i>. Note that in this AspectJ version, the
+ * participants are decoupled from the pattern. Thus, this composite does
+ * not need to implement an interface or even keep track of its children.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Component
+ * @see File
+ */
+
+public class Directory {
+
+ /**
+ * stores the name of this Directory
+ */
+
+ protected String name;
+
+ /**
+ * Creates a new Directory with a given name
+ *
+ * @param name the name for the new Directory object
+ */
+
+ public Directory(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Overwrites the <code>toString()</code> method from <code>Object</code>
+ * to print information about this Directory
+ */
+
+ public String toString() {
+ return ("Directory: "+name);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/File.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/File.java
new file mode 100644
index 000000000..6231b140b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/File.java
@@ -0,0 +1,80 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>Leaf</i>. Note that in this AspectJ version, the
+ * participants are decoupled from the pattern. Thus, this leaf does
+ * not need to implement the <i>Component</i> interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Component
+ * @see Directory
+ */
+
+public class File {
+
+ /**
+ * stores the name for this File
+ */
+
+ protected String name;
+
+ /**
+ * stores the size for this File
+ */
+
+ protected int size;
+ /**
+ * Creates a new File with a given name and size
+ *
+ * @param name the name for the new File
+ * @param size the size for the new File
+ */
+
+ public File(String name, int size) {
+ this.name = name;
+ this.size = size;
+ }
+
+ /**
+ * Overwrites the <code>toString()</code> method from <code>Object</code>
+ * to print information about this object
+ */
+
+ public String toString() {
+ return ("File: "+name+" ("+size+" KB)");
+ }
+
+ /**
+ * Returns the size of this File
+ *
+ * @return the size of this File (on disk)
+ */
+ public int getSize() {
+ return size;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/FileSystemComposition.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/FileSystemComposition.java
new file mode 100644
index 000000000..559c84d78
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/FileSystemComposition.java
@@ -0,0 +1,180 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.io.PrintStream;
+import java.util.Enumeration;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CompositeProtocol;
+
+/**
+ * Implements a concrete instance of the Composite design pattern.<p>
+ *
+ * It maintains the mapping between <i>Composite</i>s and their children,
+ * defines the <i>Component</i>, <i>Composite</i>, and <i>Leaf</i> roles,
+ * and provides facilities to implement methods that work on the whole
+ * aggregate structure.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * This concrete subaspect does the following things: <UL>
+ * <LI> Defines which classes are Components and Leafs
+ * <LI> Defines methods that operate on the whole aggregate
+ * structure (using visitors)
+ * </UL>
+ *
+ * Note that implementing the two visitors is just done for fun. Similar
+ * implementations are possible in the OO case of course, although that would
+ * require changing the <i>Components</i>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public aspect FileSystemComposition extends CompositeProtocol {
+
+ /**
+ * Assigns the Composite role to <code>Directory</code>
+ */
+
+ declare parents: Directory implements Composite;
+
+ /**
+ * Assigns the Leaf role to <code>File</code>
+ */
+
+ declare parents: File implements Leaf;
+
+
+
+
+ // Test 1: Printing the stucture using a visitor
+
+ /**
+ * helper variable to store recursion depth for pretty printing
+ */
+
+ private static int indent = 0;
+
+ /**
+ * Print a number of spaces according to the current recursion depth
+ */
+
+ private static void indent() {
+ for (int i=0; i<indent; i++)
+ System.out.print(" ");
+ }
+
+ /**
+ * Provides a client-accessible method that pretty-prints the
+ * structure of the aggregate structure using a Visitor
+ *
+ * @param s the PrintStream to print to
+ */
+
+ public void Component.printStructure(PrintStream s) {
+ indent();
+ s.println("<Component>"+this);
+ }
+
+ /**
+ * Implements <code>printStructure</code> for Composites: The indent
+ * is appropriately updated and the method call is forwarded to all
+ * children.
+ *
+ * @param s the PrintStream to print to
+ */
+
+ public void Composite.printStructure(final PrintStream s) {
+ indent();
+ s.println("<Composite>"+this);
+ indent +=4;
+ FileSystemComposition.aspectOf().recurseOperation(this, new Visitor() {
+ public void doOperation(Component c) { c.printStructure(s); }
+ } );
+ indent -=4;
+ }
+
+ /**
+ * Implements <code>printStructure</code> for <i>Leaf</i>s.
+ *
+ * @param s the PrintStream to print to
+ */
+
+ public void Leaf.printStructure(PrintStream s) {
+ indent();
+ s.println("<Leaf>"+this);
+ }
+
+
+
+
+
+ // Test2: Collecting statistics on the structure (aggregation)
+
+ /**
+ * Provides a client-accessible method that pretty-prints the
+ * structure of the aggregate structure using a FunctionVisitor.
+ * Calculates the sum of all File (<i>Leaf</i>) sizes in the structure.
+ *
+ * @returns the sum of <i>Leaf</i> sizes of all elements in this structure
+ */
+
+ public int Component.subSum() {
+ return 0;
+ }
+
+ /**
+ * Implements <code>subSum()</code> for Composites: The method call
+ * is forwarded to all children, then the results are summed up.
+ *
+ * @returns the sum of leaf sizes of all elements in this structure
+ */
+
+ public int Directory.subSum() {
+ Enumeration enum = FileSystemComposition.aspectOf().recurseFunction(
+ this, new FunctionVisitor() {
+ public Object doFunction(Component c) {
+ return new Integer(c.subSum());
+ }
+ });
+
+ int sum = 0;
+ while (enum.hasMoreElements()) {
+ sum += ((Integer) enum.nextElement()).intValue();
+ }
+ return sum;
+ }
+
+ /**
+ * Implements <code>subSum()</code> for <i>Leaf</i>s: Simply returns
+ * the <i>Leaf</i>'s size.
+ *
+ * @returns the leaf id
+ */
+
+ public int File.subSum() {
+ return size;
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Main.java
new file mode 100644
index 000000000..820faa6c2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/Main.java
@@ -0,0 +1,141 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Enumeration;
+
+/**
+ * Implements the driver for the Composite design pattern example.<p>
+ *
+ * Intent: <i>Compose objects into tree structures to represent part-whole
+ * hierarchies. Composite lets clients treat individual objects and
+ * compositions of objects uniformly.</i><p>
+ *
+ * Participating classes are <code>Directory</code>s as <i>Composite</i>s,
+ * and <code>File</code>s as <i>Leaf</i>s. Both implement the
+ * <i>Component</i> interface.<p>
+ *
+ * This example creates a simple structure as follows: Composite directory1
+ * has three children: file1, directory2, and file3. directory2 has file2
+ * as a child.
+ *
+ * Compact notation: directory1(file1, directory2(file2), file3)
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * <i>Composite</i>s and <i>Leaf</i>s do not need to know about their
+ * role in the pattern.
+ *
+ * This example also illustrates how to define methods that collect
+ * information from the whole aggreagate structure (using visitors).
+ * One of them prints the composite structure, the other one collects the
+ * sum of the values of all leaves in the structure.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Directory
+ * @see File
+ */
+
+ public class Main {
+
+ /**
+ * helper variable to store recursion depth for pretty printing
+ */
+
+ static int indent = 0;
+
+ /**
+ * Print a number of spaces according to the current recursion depth
+ */
+
+ private static void indent() {
+ for (int i=0; i<indent; i++)
+ System.out.print(" ");
+ }
+
+ /**
+ * Pretty-prints a recursive composite structure
+ *
+ * @param comp the component denoting the entry point into the structure
+ */
+
+ private static void printStructure(FileSystemComposition.Component comp) {
+ indent();
+ System.out.println(comp);
+ indent +=4;
+ for (Enumeration enum =
+ FileSystemComposition.aspectOf().getAllChildren(comp);
+ enum.hasMoreElements();) {
+ printStructure(
+ (FileSystemComposition.Component) enum.nextElement());
+ }
+ indent -= 4;
+ }
+
+
+ /**
+ * This example creates a simple structure as follows: Composite directory1
+ * has three children: file1, directory2, and file3. directory2 has file2
+ * as a child.
+ *
+ * Also, this example illustrates how to define methods that collect
+ * information from the whole aggreagate structure (using visitors).
+ * One of them prints the compiste structure, the other one collects the
+ * sum of the values of all leaves in the structure.
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("\n<<< Sample AOP implementation of Composite pattern >>>\n");
+ System.out.print ("Creating Composite structure ...\n");
+
+ Directory directory1 = new Directory("Directory1");
+ Directory directory2 = new Directory("Directory2");
+ File file1 = new File("File1", 123);
+ File file2 = new File("File2", 4556);
+ File file3 = new File("File3", 16);
+
+ FileSystemComposition.aspectOf().addChild(directory1, file1);
+ FileSystemComposition.aspectOf().addChild(directory1, directory2);
+ FileSystemComposition.aspectOf().addChild(directory2, file2);
+ FileSystemComposition.aspectOf().addChild(directory1, file3);
+
+ System.out.println("done.");
+ System.out.println("This is the Structure:");
+
+ printStructure(directory1);
+
+ System.out.println("\nCalling printStructure(PrintStream) on Composition.Components ...");
+ directory1.printStructure(System.out);
+ System.out.println("... done.");
+
+ System.out.println("\nCalling subSum():int on the structure ...");
+ System.out.println("The total size of the file system is: "+directory1.subSum());
+ System.out.println("... done.");
+
+ System.out.println("\n<<< Test completed >>>\n");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Directory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Directory.java
new file mode 100644
index 000000000..dc9b300af
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Directory.java
@@ -0,0 +1,120 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.LinkedList;
+
+/**
+ * Implements a <i>Composite</i>. Children are stored in a linked list.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see File
+ */
+
+public class Directory implements FileSystemComponent {
+
+ /**
+ * stores the children for this Directory (files and subdirectories)
+ */
+
+ protected LinkedList children = new LinkedList(); // Component interface
+
+ /**
+ * stores the name of this Directory
+ */
+
+ protected String name;
+
+ /**
+ * Creates a new Directory with a given name
+ *
+ * @param name the name for the new Directory object
+ */
+
+ public Directory(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Overwrites the <code>toString()</code> method from <code>Object</code>
+ * to print information about this Directory
+ */
+
+ public String toString() {
+ return ("Directory: "+name);
+ }
+
+
+ /**
+ * Adds a child to the component
+ *
+ * @param component the child to add
+ */
+
+ public void add(FileSystemComponent component) {
+ this.children.add(component);
+ }
+
+ /**
+ * Removes a child from the component
+ *
+ * @param component the child to remove
+ */
+ public void remove(FileSystemComponent component) {
+ this.children.remove(component);
+ }
+
+ /**
+ * Returns a child of the Directory at the given position
+ *
+ * @param index the position of the child
+ */
+
+ public FileSystemComponent getChild(int index) {
+ return (FileSystemComponent) children.get(index);
+ }
+
+ /**
+ * Returns the number of chilren this Directory has
+ *
+ * @returns the number of children of this Directory
+ */
+
+ public int getChildCount() {
+ return children.size();
+ }
+
+ /**
+ * Returns the size of this Directory. For simplicity, we define that only
+ * files have a tangible size, so this method returns 0.
+ *
+ * @return the size of the component (on disk)
+ */
+ public int getSize() {
+ return 0;
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/File.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/File.java
new file mode 100644
index 000000000..1f71cf941
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/File.java
@@ -0,0 +1,120 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>Leaf</i>. Leafs have no children.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Directory
+ */
+
+public class File implements FileSystemComponent {
+
+ /**
+ * stores the name for this File
+ */
+
+ protected String name;
+
+ /**
+ * stores the size for this File
+ */
+
+ protected int size;
+ /**
+ * Creates a new File with a given name and size
+ *
+ * @param name the name for the new File
+ * @param size the size for the new File
+ */
+
+ public File(String name, int size) {
+ this.name = name;
+ this.size = size;
+ }
+
+ /**
+ * Overwrites the <code>toString()</code> method from <code>Object</code>
+ * to print information about this object
+ */
+
+ public String toString() {
+ return ("File: "+name+" ("+size+" KB)");
+ }
+
+
+ /**
+ * Adds a child to the Component. Since Files have no
+ * children, this method does nothing.
+ *
+ * @param component the child to add
+ */
+
+ public void add(FileSystemComponent component) {}
+
+ /**
+ * Removes a child from the Component. Since Files have no
+ * children, this method does nothing.
+ *
+ * @param component the child to add
+ */
+
+ public void remove(FileSystemComponent component) {}
+
+ /**
+ * Returns a child of the Component. Since Files are <i>Leaf</i>s, they
+ * don't have any children. Thus, this method returns null.
+ *
+ * @param index the position of the child
+ * @return always null, since Files do not have children
+ */
+
+ public FileSystemComponent getChild(int index) {
+ return null;
+ }
+
+ /**
+ * Returns the number of chilren this Component has. Since Files
+ * are <i>Leaf</i>s, they don't have any children. Thus, this method
+ * returns 0.
+ *
+ * @returns always 0, since Files do not have children
+ */
+
+ public int getChildCount() {
+ return 0;
+ }
+
+ /**
+ * Returns the size of this File
+ *
+ * @return the size of this File (on disk)
+ */
+ public int getSize() {
+ return size;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/FileSystemComponent.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/FileSystemComponent.java
new file mode 100644
index 000000000..1d70078a3
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/FileSystemComponent.java
@@ -0,0 +1,81 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the <i>Component</i> interface for the composite design pattern.<p>
+ * The implementation is anologuous to the one presented in GoF. Contemporary
+ * Java implementations would probably change the <code>getChild(int)</code>
+ * and <code>getChildCount()</code> methods to a single method that returns
+ * a <code>Collection</code>. The AspectJ version has an appropriate
+ * implementation.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Directory
+ * @see File
+ */
+
+public interface FileSystemComponent {
+
+ /**
+ * Adds a child to the component
+ *
+ * @param component the child to add
+ */
+
+ public void add(FileSystemComponent component);
+
+ /**
+ * Removes a child from the component
+ *
+ * @param component the child to remove
+ */
+
+ public void remove(FileSystemComponent component);
+
+ /**
+ * Returns the child of the component ath the given position
+ *
+ * @param index the position of the child
+ */
+
+ public FileSystemComponent getChild(int index);
+
+ /**
+ * Returns the number of chilren a component has
+ *
+ * @returns the number of children of this component
+ */
+
+ public int getChildCount();
+
+ /**
+ * Returns the size of this FileSystemComponent
+ *
+ * @return the size of the component (on disk)
+ */
+ public int getSize();
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Main.java
new file mode 100644
index 000000000..c36597e5f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/composite/java/Main.java
@@ -0,0 +1,119 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.composite.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Composite design pattern example.<p>
+ *
+ * Intent: <i>Compose objects into tree structures to represent part-whole
+ * hierarchies. Composite lets clients treat individual objects and
+ * compositions of objects uniformly.</i><p>
+ *
+ * Participating classes are <code>Directory</code>s as <i>Composite</i>s,
+ * and <code>File</code>s as <i>Leaf</i>s. Both implement the
+ * <i>Component</i> interface.<p>
+ *
+ * This example creates a simple structure as follows: Composite directory1
+ * has three children: file1, directory2, and file3. directory2 has file2
+ * as a child.
+ *
+ * Compact notation: directory1(file1, directory2(file2), file3)
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Every <i>Component</i> and every <i>Leaf</i> needs to know about the
+ * pattern and their in the pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ *
+ * @see Component
+ * @see Directory
+ * @see File
+ */
+
+public class Main {
+
+ /**
+ * helper variable to store recursion depth for pretty printing
+ */
+
+ private static int indent = 0;
+
+ /**
+ * Prints a number of spaces according to the current recursion depth
+ */
+
+ private static void indent() {
+ for (int i=0; i<indent; i++)
+ System.out.print(" ");
+ }
+
+ /**
+ * Pretty-prints a recursive composite structure
+ *
+ * @param comp the component denoting the entry point into the structure
+ */
+
+ private static void printStructure(FileSystemComponent comp) {
+ indent();
+ System.out.println(comp);
+ indent +=4;
+ for (int i=0; i<comp.getChildCount(); i++) {
+ printStructure(comp.getChild(i));
+ }
+ indent -= 4;
+ }
+
+
+ /**
+ * This example creates a simple structure as follows: Composite directory1
+ * has three children: file1, directory2, and file3. directory2 has file2
+ * as a child.
+ */
+
+
+ public static void main(String[] args) {
+ System.out.println("\n<<< Sample OOP implementation of Composite pattern >>>\n");
+ System.out.print ("Creating Composite structure ...\n");
+
+ Directory directory1 = new Directory("Directory1");
+ Directory directory2 = new Directory("Directory2");
+ File file1 = new File("File1", 123);
+ File file2 = new File("File2", 4556);
+ File file3 = new File("File3", 16);
+
+ directory1.add(file1);
+ directory1.add(directory2);
+ directory2.add(file2);
+ directory1.add(file3);
+
+ System.out.println("done.");
+ System.out.println("This is the Structure:");
+
+ printStructure(directory1);
+
+ System.out.println("\n<<< Test completed >>>\n");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/BracketDecorator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/BracketDecorator.java
new file mode 100644
index 000000000..1f60876f9
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/BracketDecorator.java
@@ -0,0 +1,56 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Adds brackets ("[", "]") before and after the string to decorate.
+ * Acts as a <i>ConcreteDecorator</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+
+public aspect BracketDecorator {
+
+ /**
+ * Identifies the execution points of interest: all calls to
+ * <code>ConcreteOutput.print(String)</code>.
+ */
+
+ protected pointcut printCall(String s):
+ call(public void ConcreteOutput.print(String)) && args(s);
+
+ /**
+ * Adds brackets before and after the argument string before passing
+ * the call on to the component this decorator aspect decorates.
+ *
+ * @param s the string to be decorated.
+ */
+
+ void around(String s): printCall(s) {
+ s = "[" + s + "]"; // Decorates the string
+ proceed(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/ConcreteOutput.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/ConcreteOutput.java
new file mode 100644
index 000000000..851830647
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/ConcreteOutput.java
@@ -0,0 +1,47 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a simple class that provides a <code>print(String)</code>
+ * method. In this AspectJ implementation, there is no need for a
+ * <i>Component</i> interface; this class is autonomous and does not need
+ * to have pattern-related code.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class ConcreteOutput {
+
+ /**
+ * Prints the argument string to <code>System.out</code>.
+ *
+ * @param s the string to be printed.
+ */
+
+ public void print(String s) {
+ System.out.print(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/Main.java
new file mode 100644
index 000000000..0cec41d93
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/Main.java
@@ -0,0 +1,78 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Decorator design pattern example.<p>
+ *
+ * Intent: <i>Attach additional responsibilities to an object dynamically.
+ * Decorators provide a flexible alternative to subclassing for extending
+ * functionality.</i><p>
+ *
+ * Participating classes are <code>Output</code>s as <i>Component</i>s,
+ * <code>ConcreteOutput</code> as <i>ConcreteComponent</i>. The decorators
+ * are <code>OutputDecorator</code> as <i>Decorator</i>, and <code>
+ * StarDecorator</code> and <code>BracketDecorator</code> as <i>
+ * ConcreteDecorator</i>s.<p>
+ *
+ * Experimental setup: The concrete decorator (ConcreteOutput) prints a
+ * string, Decorators (StarDecorator and BracketDecorator) wrap other
+ * output around it. Output should be: "[ *** <String> *** ]"
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * This version does not allow for dynamic composition of decorators.
+ * However, this version decouples <i>ConcreteComponent</i>s, clients
+ * and <i>Decorators</i>. Neither clients nor <i>ConcreteComponents</i>
+ * need to have pattern code in them.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see ConcreteOutput
+ * @see StarDecorator
+ * @see BracketDecorator
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Decorator design pattern example.<p>
+ *
+ * Experimental setup: Concrete decorator (ConcreteOutput) prints a
+ * string, Decorators (StarDecorator and BracketDecorator) wrap other
+ * output around it. Output should be: "[ *** <String> *** ]"
+ *
+ * @param args command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ ConcreteOutput original = new ConcreteOutput();
+
+ original.print("<String>");
+
+ System.out.println();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/StarDecorator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/StarDecorator.java
new file mode 100644
index 000000000..f7c85a768
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/StarDecorator.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a decorator that adds stars (" *** ") before and after the
+ * string to decorate. This aspect has precedence over BracketDecorator.
+ * The <code>precedence</code> keyword allows to describe the application
+ * order of decorator aspects.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+
+public aspect StarDecorator {
+
+ declare precedence: StarDecorator, BracketDecorator;
+
+ /**
+ * Identifies the execution points of interest: all calls to
+ * <code>ConcreteOutput.print(String)</code>.
+ */
+
+ protected pointcut printCall(String s):
+ call(public void ConcreteOutput.print(String)) && args(s);
+
+ /**
+ * Adds stars before and after the argument string before passing
+ * the call on to the component this decorator aspect decorates.
+ *
+ * @param s the string to be decorated.
+ */
+
+ void around(String s): printCall(s) {
+ s = " *** " + s + " *** "; // Decorates the string
+ proceed(s);
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/BracketDecorator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/BracketDecorator.java
new file mode 100644
index 000000000..4b381865e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/BracketDecorator.java
@@ -0,0 +1,56 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a decorator that adds brackets ("[", "]") before and after the
+ * string to decorate.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class BracketDecorator extends OutputDecorator {
+
+ /**
+ * Adds brackets before and after the argument string before passing
+ * the call on to the component this decorator decorates.
+ *
+ * @param s the string to be decorated.
+ */
+
+ public void print(String s) {
+ outputComponent.print("["+s+"]");
+ }
+
+ /**
+ * Creates a BracketDecorator for the given output component
+ *
+ * @param output the component to decorate.
+ */
+
+ public BracketDecorator(Output output) {
+ super(output);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/ConcreteOutput.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/ConcreteOutput.java
new file mode 100644
index 000000000..90d82b5be
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/ConcreteOutput.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>Component</i> interface to print strings to <code>
+ * System.out</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class ConcreteOutput implements Output {
+
+ /**
+ * Prints the argument string to <code>System.out</code>.
+ *
+ * @param s the string to be printed.
+ */
+
+ public void print(String s) {
+ System.out.print(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Main.java
new file mode 100644
index 000000000..fd0601599
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Main.java
@@ -0,0 +1,73 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Decorator design pattern example.<p>
+ *
+ * Intent: <i>Attach additional responsibilities to an object dynamically.
+ * Decorators provide a flexible alternative to subclassing for extending
+ * functionality.</i><p>
+ *
+ * Participating classes are <code>Output</code>s as <i>Component</i>s,
+ * <code>ConcreteOutput</code> as <i>ConcreteComponent</i>. The decorators
+ * are <code>OutputDecorator</code> as <i>Decorator</i>, and <code>
+ * StarDecorator</code> and <code>BracketDecorator</code> as <i>
+ * ConcreteDecorator</i>s.<p>
+ *
+ * Experimental setup: The concrete decorator (ConcreteOutput) prints a
+ * string, Decorators (StarDecorator and BracketDecorator) wrap other
+ * output around it. Output should be: "[ *** <String> *** ]"
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * This version allows for dynamic composition of decorators.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Decorator design pattern example.<p>
+ *
+ * Experimental setup: Concrete decorator (ConcreteOutput) prints a
+ * string, Decorators (StarDecorator and BracketDecorator) wrap other
+ * output around it. Output should be: "[ *** <String> *** ]"
+ *
+ * @param args command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ Output original = new ConcreteOutput();
+ Output bracketed= new BracketDecorator(original);
+ Output stared = new StarDecorator(bracketed);
+
+ stared.print("<String>");
+
+ System.out.println();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Output.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Output.java
new file mode 100644
index 000000000..49df113d4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/Output.java
@@ -0,0 +1,43 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines an interface for printing Strings. Acts as <i>Component</i>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public interface Output {
+
+ /**
+ * Prints the argument string to <code>System.out</code>.
+ *
+ * @param s the string to be printed.
+ */
+
+ public void print(String s);
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/OutputDecorator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/OutputDecorator.java
new file mode 100644
index 000000000..2966d1f20
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/OutputDecorator.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the <i>Decorator</i> interface. This is realized as an abstract
+ * class to allow for default implementations (set varible "output",
+ * provide default implementation for <code>print(String)</code>).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public abstract class OutputDecorator implements Output {
+
+ /**
+ * the <i>Component</i> to decorate
+ */
+
+ protected Output outputComponent;
+
+ /**
+ * Prints the argument string to <code>System.out</code>. This method is
+ * overwritten by concrete decorators. The default implementation
+ * forwards the method call to the decorated <i>Component</i>.
+ *
+ * @param s the string to be printed.
+ */
+
+ public void print(String s) {
+ outputComponent.print(s);
+ }
+
+ /**
+ * Defines the constructor signature. Also provides a default
+ * implementation so that concrete decorators don't have to
+ * re-implement it. Subclasses (<i>ConcreteDecorator</i>s) can just
+ * call <code>super(..)</code> and don't have
+ * to deal with setting the variable themselves.
+ *
+ * @param output the <i>Component</i> to decorate.
+ */
+
+ public OutputDecorator(Output output) {
+ this.outputComponent = output;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/StarDecorator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/StarDecorator.java
new file mode 100644
index 000000000..1e7cb393b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/decorator/java/StarDecorator.java
@@ -0,0 +1,59 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.decorator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a decorator that adds stars (" *** ") before and after the
+ * string to decorate.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+
+public class StarDecorator extends OutputDecorator {
+
+ /**
+ * Adds three stars before and after the argument string before passing
+ * the call on to the component this decorator decorates.
+ *
+ * @param s the string to be decorated.
+ */
+
+ public void print(String s) {
+ outputComponent.print(" *** " + s + " *** ");
+ }
+
+ /**
+ * Creates a StarDecorator for the given output component
+ *
+ * @param output the <i>Component</i> to decorate.
+ */
+
+ public StarDecorator(Output output) {
+ super(output);
+ }
+
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/Main.java
new file mode 100644
index 000000000..9d761685a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/Main.java
@@ -0,0 +1,52 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Facade design pattern example.<p>
+ *
+ * Intent: <i>Provide a unified interface to a set of interfaces in a
+ * subsystem. Facade defines a higher-level interface that makes the
+ * subsystem easier to use.</i><p>
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * For this pattern, both Java and AspectJ implementations are identical.
+ * The pattern introduces no crosscutting and is not abstractable. The
+ * java implementation is not duplicated here: All this class does is to
+ * print a message explaining that the versions are identical.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class Main {
+
+ public static void main(String[] args) {
+ System.out.println("For this pattern, the AspectJ implementation ");
+ System.out.println("is identical to the Java implementation. It is ");
+ System.out.println("not duplicated here. ");
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Decoration.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Decoration.java
new file mode 100644
index 000000000..8425bc762
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Decoration.java
@@ -0,0 +1,44 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a static method that returns a decorator string.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class Decoration {
+
+ /**
+ * Provides a decorator string consisting of stars ("*").
+ *
+ * @returns a decorator string made up of stars
+ */
+
+ public static String getDecoration() {
+ return "*******************************************";
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Main.java
new file mode 100644
index 000000000..471babb90
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/Main.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Facade design pattern example.<p>
+ *
+ * Intent: <i>Provide a unified interface to a set of interfaces in a
+ * subsystem. Facade defines a higher-level interface that makes the
+ * subsystem easier to use.</i><p>
+ *
+ * The <i>subsystem</i> consists of three classes that provide low-level
+ * string manipulation and output functionality: <code>RegularScreen</code>,
+ * <code>Decoration</code>, and <code>StringTransformer</code>. The <i>Facade
+ * </i> class <code>OutputFacade</code> procides a higher-level interface
+ * to output strings. This class calls methods on that higer-level interface.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class Main {
+
+ /**
+ * Tests the higher-level interface of <code>OutputFacade</code>.
+ */
+
+ public static void main(String[] args) {
+ OutputFacade facade = new OutputFacade();
+
+ System.out.println("Testing Facade...");
+ facade.printDecoration();
+
+ facade.printNormal("Facade: this is normal printing");
+ facade.printFancy ("Facade: this is fancy printing");
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/OutputFacade.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/OutputFacade.java
new file mode 100644
index 000000000..30c1bd8b5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/OutputFacade.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>Facade</i> role in the pattern by providing a
+ * higher-level interface to the operations provided by
+ * <code>RegularScreen</code>, <code>Decoration</code>,
+ * and <code>StringTransformer</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class OutputFacade {
+
+ /**
+ * Prints a string using <code>RegularScreen</code>.
+ *
+ * @param s the string to print
+ */
+
+ public void printNormal(String s) {
+ RegularScreen.print(s);
+ RegularScreen.newline();
+ }
+
+ /**
+ * Prints a two versions of string with decorations
+ * using <code>RegularScreen</code> and <code>Decoration</code>.
+ *
+ * @param s the string to print
+ */
+
+ public void printFancy(String s) {
+ printDecoration();
+
+ RegularScreen.print(StringTransformer.transformToUpper(s+" (uppercase)"));
+ RegularScreen.newline();
+
+ printDecoration();
+
+ RegularScreen.print(StringTransformer.transformToLower(s+" (lowercase)"));
+ RegularScreen.newline();
+
+ printDecoration();
+ }
+
+ /**
+ * Prints a decorator string.
+ */
+
+ public void printDecoration() {
+ RegularScreen.print(Decoration.getDecoration());
+ RegularScreen.newline();
+ RegularScreen.newline();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/RegularScreen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/RegularScreen.java
new file mode 100644
index 000000000..acd753598
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/RegularScreen.java
@@ -0,0 +1,52 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a low-level interface for printing to System.out.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class RegularScreen {
+
+ /**
+ * Prints a string to System.out.
+ *
+ * @param s the string to print
+ */
+
+ public static void print(String s) {
+ System.out.print(s);
+ }
+
+ /**
+ * Prints a newline to System.out.
+ */
+
+ public static void newline() {
+ System.out.println();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/StringTransformer.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/StringTransformer.java
new file mode 100644
index 000000000..1353cfaa4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/facade/java/StringTransformer.java
@@ -0,0 +1,56 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.facade.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements basic string manipulation facilities.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class StringTransformer {
+
+ /**
+ * Transforms a string to upper case
+ *
+ * @param s the string to transform
+ * @returns the transformed string
+ */
+
+ public static String transformToUpper(String s) {
+ return s.toUpperCase();
+ }
+
+ /**
+ * Transforms a string to lower case
+ *
+ * @param s the string to transform
+ * @returns the transformed string
+ */
+
+ public static String transformToLower(String s) {
+ return s.toLowerCase();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/ButtonCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/ButtonCreator.java
new file mode 100644
index 000000000..673023831
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/ButtonCreator.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Implements a <i>ConcreteCreator</i> that creates buttons.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see LabelCreator
+ */
+
+public class ButtonCreator implements GUIComponentCreator {
+
+ /**
+ * Factory method that creates a button with label and <code>
+ * ActionListener</code>.
+ *
+ * @returns the created button
+ */
+
+ public JComponent createComponent() {
+ final JButton button = new JButton("Click me!");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ button.setText("Thank you!");
+ }
+ });
+ return button;
+ }
+
+ /**
+ * Returns a title explaining this example.
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public String getTitle() {
+ return "Example 1: A JButton";
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/CreatorImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/CreatorImplementation.java
new file mode 100644
index 000000000..0e3692e72
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/CreatorImplementation.java
@@ -0,0 +1,76 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JComponent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.Point;
+
+/**
+ * Provides a default implementation for the <i>anOperation()</i>
+ * method <code>showFrame()</code>. The implementation is attached to the
+ * <code>GUIComponentCreator</code> interface. With this approach,
+ * <i>GUIComponentCreator</i> does not have to be an abstract class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see GUIComponentCreator
+ */
+
+public aspect CreatorImplementation {
+
+ /**
+ * the position for the next frame to be created (on the screen)
+ */
+
+ private static Point lastFrameLocation = new Point(0, 0);
+
+ /**
+ * Creates a <code>JFrame</code>, puts the <code>JComponent</code> that
+ * is created by the factory method into it and displays the frame. This
+ * Method also provides a <code>WindowListener</code>.
+ */
+
+ public final void GUIComponentCreator.showFrame() {
+ JFrame frame = new JFrame(getTitle());
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ JPanel panel = new JPanel();
+
+ panel.add(createComponent());
+
+ frame.getContentPane().add(panel);
+ frame.pack();
+ frame.setLocation(lastFrameLocation);
+ lastFrameLocation.translate(75, 75);
+ frame.setVisible(true);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/GUIComponentCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/GUIComponentCreator.java
new file mode 100644
index 000000000..a2287ef6a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/GUIComponentCreator.java
@@ -0,0 +1,66 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JComponent;
+
+/**
+ * Defines the <i>GUIComponentCreator</i> interface with the
+ * <i>factoryMethod()</i> method signature and the <i>anOperation()</i>
+ * method that uses it. For details, see GoF, page 108.<p>
+ *
+ * The factory method is <code>createComponent</code> and it creates
+ * A JComponent (a button and a label, repsectively). The <i>anOperation()</i>
+ * method is implemented by the aspect, allowing this type to be an interface,
+ * not an abstract class
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see ButtonCreator
+ * @see LabelCreator
+ */
+
+public interface GUIComponentCreator {
+
+ /**
+ * The factory method to create <code>JComponent</code>s, to be
+ * concretized by subclasses.
+ *
+ * @returns the created product
+ */
+
+ public JComponent createComponent();
+
+ /**
+ * Another factory method to create a title that explains the created
+ * component
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public String getTitle();
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/LabelCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/LabelCreator.java
new file mode 100644
index 000000000..200ec456d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/LabelCreator.java
@@ -0,0 +1,60 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JComponent;
+
+/**
+ * Implements a <i>ConcreteCreator</i> that creates labels.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see ButtonCreator
+ */
+
+public class LabelCreator implements GUIComponentCreator {
+
+ /**
+ * Factory method that creates a label
+ *
+ * @returns the created label
+ */
+
+ public JComponent createComponent() {
+ JLabel label = new JLabel("This is a JLabel.");
+ return label;
+ }
+
+ /**
+ * Returns a title explaining this example.
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public String getTitle() {
+ return "Example 2: A JLabel";
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/Main.java
new file mode 100644
index 000000000..8ae2a2f3a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/Main.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the FactoryMethod design pattern example.<p>
+ *
+ * Intent: <i>Define an interface for creating an object, but let subclasses
+ * decide which class to instantiate. Factory Method lets a class defer
+ * instantiation to subclasses.</i><p>
+ *
+ * Participating objects are <code>ButtonCreator</code> and
+ * <code>LabelCreator</code> as <i>ConcreteCreator</i>s. Both implement
+ * the <code>GUIComponentCreator</code> interface.<p>
+ *
+ * In this example, the factory method <code>createComponent</code> creates
+ * A JComponent (a button and a label, respectively). The <i>anOperation()</i>
+ * method <code>showFrame()</code> uses the factory method to show a little
+ * GUI. In one case, the created frame contains a button, in the other a
+ * simple label.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Since the implementation of the <i>anOperation()</i> method <code>
+ * showFrame()</code> is now realized by an aspect,
+ * <code>GUIComponentCreator</code> can now be an interface, allowing
+ * the <i>ConcreteCreator</i>s to be part of a different inheritance
+ * hierarchy.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see GUIComponentCreator
+ * @see ButtonCreator
+ * @see LabelCreator
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the FactoryMethod design pattern example.<p>
+ *
+ * In this example, the factory method <code>createComponent</code>
+ * creates a JComponent (a button and a label, repsectively). The
+ * <i>anOperation()</i> method <code>showFrame()</code> uses the factory
+ * methods to show a little GUI. In one case, the created frame contains
+ * a button, in the other a simple label.
+ */
+
+ public static void main(String[] args) {
+
+ GUIComponentCreator creator1 = new ButtonCreator();
+ GUIComponentCreator creator2 = new LabelCreator();
+
+ creator1.showFrame();
+ creator2.showFrame();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/ButtonCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/ButtonCreator.java
new file mode 100644
index 000000000..7346fdb09
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/ButtonCreator.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Implements a <i>ConcreteCreator</i> that creates buttons.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see LabelCreator
+ */
+
+public class ButtonCreator extends GUIComponentCreator {
+
+ /**
+ * Factory method that creates a button with label and <code>
+ * ActionListener</code>.
+ *
+ * @returns the created button
+ */
+
+ public JComponent createComponent() {
+ final JButton button = new JButton("Click me!");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ button.setText("Thank you!");
+ }
+ });
+ return button;
+ }
+
+ /**
+ * Returns a title explaining this example.
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public String getTitle() {
+ return "Example 1: A JButton";
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/GUIComponentCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/GUIComponentCreator.java
new file mode 100644
index 000000000..9a4b0101d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/GUIComponentCreator.java
@@ -0,0 +1,102 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JComponent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.Point;
+
+/**
+ * Defines the <i>GUIComponentCreator</i> interface with the
+ * <i>factoryMethod()</i> method signature and the <i>anOperation()</i>
+ * method that uses it. For details, see GoF, page 108.<p>
+ *
+ * The factory method is <code>createComponent</code> and it creates
+ * A JComponent (a button or a label, in this case). The <i>anOperation()</i>
+ * method <code>showFrame()</code> uses the factory method to show a small
+ * GUI.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see ButtonCreator
+ * @see LabelCreator
+ */
+
+public abstract class GUIComponentCreator {
+
+ /**
+ * The factory method to be concretized by subclasses.
+ *
+ * @returns the created <i>ConcreteProduct</i>
+ */
+
+ public abstract JComponent createComponent();
+
+ /**
+ * Another factory method to create a title for the GUI frame created
+ * by this class.
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public abstract String getTitle();
+
+ /**
+ * the position for the next frame to be created (on the screen). This
+ * variable is used to make sure new frames appear staggered and don't
+ * entirely overlap with existing frames.
+ */
+
+ private static Point lastFrameLocation = new Point(0, 0);
+
+ /**
+ * Creates a <code>JFrame</code>, puts the <code>JComponent</code> that
+ * is created by the factory method into it and displays the frame. This
+ * Method also provides a <code>WindowListener</code>.
+ */
+
+ public final void showFrame() {
+ JFrame frame = new JFrame(getTitle());
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ JPanel panel = new JPanel();
+
+ panel.add(createComponent());
+
+ frame.getContentPane().add(panel);
+ frame.pack();
+ frame.setLocation(lastFrameLocation);
+ lastFrameLocation.translate(75, 75);
+ frame.setVisible(true);
+ }
+}
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/LabelCreator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/LabelCreator.java
new file mode 100644
index 000000000..40bbd8b8c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/LabelCreator.java
@@ -0,0 +1,60 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JLabel;
+import javax.swing.JComponent;
+
+/**
+ * Implements a <i>ConcreteCreator</i> that creates labels.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see ButtonCreator
+ */
+
+public class LabelCreator extends GUIComponentCreator {
+
+ /**
+ * Factory method that creates a label.
+ *
+ * @returns the created label
+ */
+
+ public JComponent createComponent() {
+ JLabel label = new JLabel("This is a JLabel.");
+ return label;
+ }
+
+ /**
+ * Returns a title explaining this example.
+ *
+ * @returns the title for the GUI frame
+ */
+
+ public String getTitle() {
+ return "Example 2: A JLabel";
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/Main.java
new file mode 100644
index 000000000..a068f8f7d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/factoryMethod/java/Main.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the FactoryMethod design pattern example.<p>
+ *
+ * Intent: <i>Define an interface for creating an object, but let subclasses
+ * decide which class to instantiate. Factory Method lets a class defer
+ * instantiation to subclasses.</i><p>
+ *
+ * Participating objects are <code>ButtonCreator</code> and
+ * <code>LabelCreator</code> as <i>ConcreteCreator</i>s. Both implement
+ * the <code>GUIComponentCreator</code> interface.<p>
+ *
+ * In this example, the factory method <code>createComponent</code> creates
+ * A JComponent (a button and a label, respectively). The <i>anOperation()</i>
+ * method <code>showFrame()</code> uses the factory method to show a little
+ * GUI. In one case, the created frame contains a button, in the other a
+ * simple label.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Since the <i>anOperation()</i> method requires an implementation, <i>
+ * GUIComponentCreator</i> has to be an abstract class (as opposed to an
+ * interface). Consequently, all <i>ConcreteCreator</i>s have to be
+ * subclasses of that class and cannot belong to a different inheritance
+ * hierarchy.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see GUIComponentCreator
+ * @see ButtonCreator
+ * @see LabelCreator
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the FactoryMethod design pattern example.<p>
+ *
+ * In this example, the factory method <code>createComponent</code>
+ * creates a JComponent (a button and a label, repsectively). The
+ * <i>anOperation()</i> method <code>showFrame()</code> uses the factory
+ * methods to show a little GUI. In one case, the created frame contains
+ * a button, in the other a simple label.
+ */
+
+ public static void main(String[] args) {
+
+ GUIComponentCreator creator1 = new ButtonCreator();
+ GUIComponentCreator creator2 = new LabelCreator();
+
+ creator1.showFrame();
+ creator2.showFrame();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/CharacterFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/CharacterFlyweight.java
new file mode 100644
index 000000000..7e024edf8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/CharacterFlyweight.java
@@ -0,0 +1,64 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+/**
+ * A <i>ConcreteFlyweight</i> storing a single regular character
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class CharacterFlyweight implements PrintableFlyweight {
+
+ /**
+ * The character this <i>ConcreteFlyweight</i> represents
+ */
+
+ private char c;
+
+
+ /**
+ * Creates a new <i>ConcreteFlyweight</i> and sets it to represent a
+ * particular regular character
+ *
+ * @param c the character to represent
+ */
+
+ public CharacterFlyweight(char c) {
+ this.c = c;
+ }
+
+ /**
+ * Prints the stored character
+ *
+ * @param uppercase whether the character should be printed in
+ * uppercase
+ */
+
+ public void print(boolean uppercase) {
+ System.out.print(uppercase ? Character.toUpperCase(c) : c);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/FlyweightImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/FlyweightImplementation.java
new file mode 100644
index 000000000..f3ecc43a0
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/FlyweightImplementation.java
@@ -0,0 +1,89 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.FlyweightProtocol;
+
+/**
+ * Implements a concrete instance of the flyweight pattern using the
+ * abstract implementation found in <code>FlyweightProtocol</code>.
+ *
+ * It assigns the <i>Flyweight</i> pattern role to the participants and
+ * provides the implementation for creating <i>Flyweight</i>s.
+ *
+ * A concenience method is provided to utilize the abstract aspect's
+ * <i>getFlyweight(...)</i> implementation with an appropriate return type.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+
+public aspect FlyweightImplementation extends FlyweightProtocol {
+
+ /**
+ * Assigns the <i>Flyweight</i> role to CharacterFlyweight.
+ */
+
+ declare parents: CharacterFlyweight implements Flyweight;
+
+ /**
+ * Assigns the <i>Flyweight</i> role to WhitespaceFlyweight.
+ */
+
+ declare parents: WhitespaceFlyweight implements Flyweight;
+
+ /**
+ * Actually creates the <i>Flyweight</i> for a given <i>Key</i>. This
+ * method is called by <code>getFlyweight(Object)</code> if the
+ * flyweight does not already exist.
+ *
+ * @param key the key identifying the particular <i>Flyweight</i>
+ * @return the <i>Flyweight</i> representing the key
+ */
+
+ protected Flyweight createFlyweight(Object key) {
+ char c = ((Character) key).charValue();
+ Flyweight flyweight = null;
+ if (Character.isWhitespace(c)) {
+ flyweight = new WhitespaceFlyweight(c);
+ } else {
+ flyweight = new CharacterFlyweight(c);
+ }
+ return flyweight;
+ }
+
+ /**
+ * Provides a custom interface to access the <i>Flyweights</i>.
+ * Refers to the general <code>getFlyweight(Object)</code> method
+ * defined on the abstract aspect.
+ *
+ * @param c the character identifying the particular flyweight
+ * @return the flyweight representing the character
+ */
+
+ public PrintableFlyweight getPrintableFlyweight(char c) {
+ return (PrintableFlyweight) getFlyweight(new Character(c));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/Main.java
new file mode 100644
index 000000000..dce3cd0dd
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/Main.java
@@ -0,0 +1,114 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Flyweight design pattern example.<p>
+ *
+ * Intent: <i>Use sharing to support large numbers of fine-grained objects
+ * efficiently.</i><p>
+ *
+ * Participating <i>Flyweight</i> classes are <code>CharacterFlyweight</code>
+ * and <code>WhitespaceFlyweight</code>. Both implement the <code>
+ * PrintableFlyweight</code> interface. Flyweights are generated via the
+ * <code>PrintableFlyweightFactory</code>. <P>
+ *
+ * Intrinsic state: The character to print,
+ * Extrinsic state: Whether the char is upper case or lower case
+ *
+ * This example creates a sentence out of <code>PrintableFlyweight</i>s
+ * (characters and whitespaces).
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * The creation-on-demand functionality is performed by the abstract
+ * pattern aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweight
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Flyweight design pattern example.<p>
+ *
+ * This example creates a sentence out of <code>PrintableFlyweight</i>s
+ * (characters and whitespaces).
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("This is a test for the AspectJ version of the "
+ + "Flyweight pattern implementation.");
+ System.out.println("The client will use char flyweights to print "
+ + "the phrase");
+ System.out.println("\"This Is A Test\".\n");
+ System.out.println("Testing Pattern: Flyweight - STARTING\n");
+
+ PrintableFlyweight T =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('t');
+ PrintableFlyweight H =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('h');
+ PrintableFlyweight I =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('i');
+ PrintableFlyweight S =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('s');
+ PrintableFlyweight A =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('a');
+ PrintableFlyweight E =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight('e');
+ PrintableFlyweight Empty =
+ FlyweightImplementation.aspectOf().getPrintableFlyweight(' ');
+
+ // Printing: "This Is A Test"
+
+ T.print(true);
+ H.print(false);
+ I.print(false);
+ S.print(false);
+
+ Empty.print(true);
+
+ I.print(true);
+ S.print(false);
+
+ Empty.print(true);
+
+ A.print(true);
+
+ Empty.print(true);
+
+ T.print(true);
+ E.print(false);
+ S.print(false);
+ T.print(false);
+
+ System.out.println();
+
+ System.out.println("\nTesting Pattern: State - FINISHED");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/PrintableFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/PrintableFlyweight.java
new file mode 100644
index 000000000..35aba15e1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/PrintableFlyweight.java
@@ -0,0 +1,44 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the <i>Flyweight</i> interface. Here, the flyweights are
+ * characters that offer a single method: <code>print(boolean)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public interface PrintableFlyweight {
+
+ /**
+ * Defines the method signature for <i>Flyweights</i>'
+ * <code>print()</code> method
+ *
+ * @param uppercase whether the character is to be printed as uppercase
+ */
+
+ public void print(boolean uppercase);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/WhitespaceFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/WhitespaceFlyweight.java
new file mode 100644
index 000000000..0c4066223
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/WhitespaceFlyweight.java
@@ -0,0 +1,66 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * A <i>ConcreteFlyweight</i> storing a single whitespace
+ * character
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweightFactory
+ */
+
+public class WhitespaceFlyweight implements PrintableFlyweight {
+
+
+ /**
+ * The character this flyweight represents
+ */
+
+ private char c;
+
+ /**
+ * Creates a new flyweight and sets it to represent a particular
+ * whitespace character
+ *
+ * @param c the character to represent
+ */
+
+ public WhitespaceFlyweight(char c) {
+ this.c = c;
+ }
+
+ /**
+ * Prints the stored character
+ *
+ * @param uppercase whether the character should be printed in
+ * uppercase
+ */
+
+ public void print(boolean uppercase) {
+ System.out.print(uppercase ? Character.toUpperCase(c) : c);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/CharacterFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/CharacterFlyweight.java
new file mode 100644
index 000000000..6c61d4fd6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/CharacterFlyweight.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * A <i>ConcreteFlyweight</i> storing a single regular character
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweightFactory
+ */
+
+public class CharacterFlyweight implements PrintableFlyweight {
+
+ /**
+ * The character this <i>ConcreteFlyweight</i> represents
+ */
+
+ private char c;
+
+
+ /**
+ * Creates a new CharacterFlyweight and sets it to represent a
+ * particular character
+ *
+ * @param c the character to represent
+ */
+
+ public CharacterFlyweight(char c) {
+ this.c = c;
+ }
+
+ /**
+ * Prints the stored character.
+ *
+ * @param uppercase whether the character should be printed in
+ * uppercase
+ */
+
+ public void print(boolean uppercase) {
+ System.out.print(uppercase ? Character.toUpperCase(c) : c);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/Main.java
new file mode 100644
index 000000000..23be7e85e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/Main.java
@@ -0,0 +1,122 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Flyweight design pattern example.<p>
+ *
+ * Intent: <i>Use sharing to support large numbers of fine-grained objects
+ * efficiently.</i><p>
+ *
+ * Participating <i>Flyweight</i> classes are <code>CharacterFlyweight</code>
+ * and <code>WhitespaceFlyweight</code>. Both implement the <code>
+ * PrintableFlyweight</code> interface. Flyweights are generated via the
+ * <code>PrintableFlyweightFactory</code>. <P>
+ *
+ * These are the pattern roles: <UL>
+ *
+ * <LI> CharacterFlyweightFactory: FlyweightFactory
+ * <LI> PritableFlyweight: Flyweight
+ * <LI> CharacterFlyweight: ConcreteFlyweight
+ * <LI> WhitespaceFlyweight: ConcreteFlyweight
+ * <LI> Main: Client
+ * </UL>
+ *
+ * Intrinsic state: The character to print,
+ * Extrinsic state: Whether the char is upper case or lower case
+ *
+ * This example creates a sentence out of <code>PrintableFlyweight</i>s
+ * (characters and whitespaces).
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * This implementation is analoguous to the GoF book's description.
+ * For this version, we only use two classes for the flyweights,
+ * CharacterFlyweight and WhitespaceFlyweight. Plus, this implementation
+ * uses an optimized factory that keeps a hashtable of created Flyweights
+ * and employs creation of demand.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweight
+ * @see PrintableFlyweightFactory
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Flyweight design pattern example.<p>
+ *
+ * This example creates a sentence out of <code>PrintableFlyweight</i>s
+ * (characters and whitespaces).
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("This is a test for the java Flyweight pattern "
+ + "implementation.");
+ System.out.println("The client will use char flyweights to print the "
+ + "phrase");
+ System.out.println("\"This Is A Test\".\n");
+ System.out.println("Testing Pattern: Flyweight - STARTING\n");
+
+ PrintableFlyweightFactory pff = new PrintableFlyweightFactory();
+
+ PrintableFlyweight T = pff.getPrintableFlyweight('t');
+ PrintableFlyweight H = pff.getPrintableFlyweight('h');
+ PrintableFlyweight I = pff.getPrintableFlyweight('i');
+ PrintableFlyweight S = pff.getPrintableFlyweight('s');
+ PrintableFlyweight A = pff.getPrintableFlyweight('a');
+ PrintableFlyweight E = pff.getPrintableFlyweight('e');
+ PrintableFlyweight Empty = pff.getPrintableFlyweight(' ');
+
+ // Printing: "This Is A Test"
+
+ T.print(true);
+ H.print(false);
+ I.print(false);
+ S.print(false);
+
+ Empty.print(true);
+
+ I.print(true);
+ S.print(false);
+
+ Empty.print(true);
+
+ A.print(true);
+
+ Empty.print(true);
+
+ T.print(true);
+ E.print(false);
+ S.print(false);
+ T.print(false);
+
+ System.out.println();
+
+ System.out.println("\nTesting Pattern: State - FINISHED");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweight.java
new file mode 100644
index 000000000..89e8b8e8c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweight.java
@@ -0,0 +1,46 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the <i>Flyweight</i> interface. Here, the flyweights are
+ * characters that offer a single method: <code>print(boolean)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweightFactory
+ */
+
+public interface PrintableFlyweight {
+
+ /**
+ * Defines the method signature for <i>Flyweights</i>'
+ * <code>print()</code> method
+ *
+ * @param uppercase whether the character is to be printed as uppercase
+ */
+
+ public void print(boolean uppercase);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweightFactory.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweightFactory.java
new file mode 100644
index 000000000..56bfe74cc
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/PrintableFlyweightFactory.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Implements a <i>FlyweightFactory</i> that employs a creation-on-demand
+ * policy.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweight
+ */
+
+public class PrintableFlyweightFactory {
+
+ /**
+ * stores the existing flyweights by character they represent
+ */
+
+ private Hashtable printables = new Hashtable();
+
+ /**
+ * Returns the flyweight representing the argument character.
+ * If the appropriate flyweight does not yet exist, it is created
+ * on demand.
+ *
+ * @param c the character for which the the flyweight is returned
+ * @return the <i>Flyweight</i> representing the argument character
+ */
+
+ public PrintableFlyweight getPrintableFlyweight(char c) {
+
+ Character ch = new Character(c);
+
+ if (printables.containsKey(ch)) {
+ return (PrintableFlyweight) printables.get(ch);
+ } else {
+ PrintableFlyweight flyweight = null;
+ if (Character.isWhitespace(c)) {
+ flyweight = new WhitespaceFlyweight(c);
+ } else {
+ flyweight = new CharacterFlyweight(c);
+ }
+ printables.put(ch, flyweight);
+ return flyweight;
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/WhitespaceFlyweight.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/WhitespaceFlyweight.java
new file mode 100644
index 000000000..dfc1d4484
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/flyweight/java/WhitespaceFlyweight.java
@@ -0,0 +1,66 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * A <i>ConcreteFlyweight</i> storing a single whitespace
+ * character
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see PrintableFlyweightFactory
+ */
+
+public class WhitespaceFlyweight implements PrintableFlyweight {
+
+
+ /**
+ * The character this flyweight represents
+ */
+
+ private char c;
+
+ /**
+ * Creates a new flyweight and sets it to represent a particular
+ * whitespace character
+ *
+ * @param c the character to represent
+ */
+
+ public WhitespaceFlyweight(char c) {
+ this.c = c;
+ }
+
+ /**
+ * Prints the stored character.
+ *
+ * @param uppercase whether the character should be printed in
+ * uppercase
+ */
+
+ public void print(boolean uppercase) {
+ System.out.print(uppercase ? Character.toUpperCase(c) : c);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/AndExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/AndExpression.java
new file mode 100644
index 000000000..5ddb4fcf2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/AndExpression.java
@@ -0,0 +1,70 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements AND expressions for booleans. This is a concrete boolean
+ * <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class AndExpression implements BooleanExpression {
+
+ /**
+ * stores the first part of this AND <i>Expression</i>
+ */
+
+ protected BooleanExpression expression1;
+
+ /**
+ * stores the second part of this AND <i>Expression</i>
+ */
+
+ protected BooleanExpression expression2;
+
+ /**
+ * Creates a new AND <i>Expression</i> with the given parts
+ *
+ * @param op1 the first <i>Expression</i>
+ * @param op1 the second <i>Expression</i>
+ */
+
+ public AndExpression(BooleanExpression op1, BooleanExpression op2) {
+ this.expression1 = op1;
+ this.expression2 = op2;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (expression1.evaluate(c) && expression2.evaluate(c));
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanConstant.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanConstant.java
new file mode 100644
index 000000000..685595dba
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanConstant.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements boolean constants, a concrete boolean <i>TerminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class BooleanConstant implements BooleanExpression {
+
+ /**
+ * the value of this constant
+ */
+
+ protected boolean value;
+
+ /**
+ * Creates a new constant with the given value
+ *
+ * @param value the value this constant should represent
+ */
+
+ public BooleanConstant(boolean value) {
+ this.value = value;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>.
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return value;
+ }
+
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanExpression.java
new file mode 100644
index 000000000..3ec0fbf54
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanExpression.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the <i>AbstractExpression</i> interface for boolean expressions.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public abstract interface BooleanExpression {
+
+ /**
+ * Evaluates this expression in the given <i>VariableContext</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c);
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp);
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanInterpretation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanInterpretation.java
new file mode 100644
index 000000000..a3e5b809e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/BooleanInterpretation.java
@@ -0,0 +1,185 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements <code>replace(String, BooleanExpression)<code> and
+ * <code>copy()</code> methods for all concrete
+ * <code>BooleanExpression</code>s.
+ *
+ * The very nature of the interpreter pattern introduces coupling between all
+ * participants. Unfortunately, removing the pattern code from the
+ * participants does not work as nicely here as with other patterns. The
+ * reason is that the roles are defining, i.e., each participant's
+ * functionality is determined (only) by its role. If aspects were used
+ * to implement the entire pattern functionality, it would leave
+ * the <i>Expressions</i> etc. empty and would make the aspect a
+ * monolithic module. <p>
+ *
+ * However, it is still possible to augment or change the behaviour of the
+ * system without changing all participant classes. To show this, we
+ * assumed that <code>BooleanExpression.replace(String, BooleanExpression)
+ * </code> and <code>BooleanExpression.copy()</code> were added later.
+ * An aspect is used to implement those methods, so that other
+ * classes do not have to change (we only changed the interface, but
+ * even that was not necessary).<p>
+ *
+ * In general, however, this pattern does not lend itself nicely to
+ * aspectification.<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see BooleanExpression
+ */
+
+public aspect BooleanInterpretation {
+
+ // AndExpressionression
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression AndExpression.replace(String name, BooleanExpression exp) {
+ return new AndExpression(expression1.replace(name, exp), expression2.replace(name,exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression AndExpression.copy() {
+ return new AndExpression(expression1.copy(), expression2.copy());
+ }
+
+ // BooleanConstant
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ * Has no effect on constants.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return the unchanged expression
+ */
+
+ public BooleanExpression BooleanConstant.replace(String name, BooleanExpression exp) {
+ return this;
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression BooleanConstant.copy() {
+ return new BooleanConstant(value);
+ }
+
+ // OrExpression
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression OrExpression.replace(String name, BooleanExpression exp) {
+ return new OrExpression(expression1.replace(name, exp), expression2.replace(name,exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression OrExpression.copy() {
+ return new OrExpression(expression1.copy(), expression2.copy());
+ }
+
+ // VariableExpression
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression VariableExpression.replace(String name, BooleanExpression exp) {
+ if (name.equals(this.name)) {
+ return exp.copy();
+ } else {
+ return new VariableExpression(this.name);
+ }
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression VariableExpression.copy() {
+ return new VariableExpression(name);
+ }
+
+ // NotExpressionressionressionression
+
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression NotExpression.replace(String name, BooleanExpression exp) {
+ return new NotExpression(this.exp.replace(name, exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression NotExpression.copy() {
+ return new NotExpression(exp.copy());
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/ExpressionException.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/ExpressionException.java
new file mode 100644
index 000000000..61cda48ad
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/ExpressionException.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an exception that gets raised when the interpreter
+ * runs into errors.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class ExpressionException extends RuntimeException {
+
+ /**
+ * Creates a new ExpressionException with the given message
+ *
+ * @param s the exception message
+ */
+
+ public ExpressionException(String s) {
+ super(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/Main.java
new file mode 100644
index 000000000..3a0c6f232
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/Main.java
@@ -0,0 +1,131 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Intepreter design pattern example.<p>
+ *
+ * Intent: <i>Given a language, defeine a representation fro its grammar along
+ * with an interpreter that uses the representation to interpret sentences
+ * in the language.</i><p>
+ *
+ * Participating objects are <code>BooleanContant</code>, <code>VariableExpression
+ * </code>, <code>OrExpression</code>, <code>AndExpression</code>, and <code>NotExpression</code>
+ * as <i>Expressions</i>. The <i>AbstractExpression</i> interface is defined
+ * in <code>BooelanExp</i>.<p>
+ *
+ * This example implements an interpreter for a language of boolean
+ * expressions. As a sample expression, "((true & x) | (y & !x))" is
+ * interpreted for all possible boolean values for x and y. After that,
+ * y is replaced by another expression and the whole expression is
+ * evaluated again.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * The very nature of this pattern introduces coupling between all
+ * participants. Unfortunately, removing the pattern code from the
+ * participants does not work as nicely here as with other patterns. The
+ * reason is that the roles are defining, i.e., each participant's
+ * functionality is determined (only) by its role. Removing pattern
+ * specific code into an aspect would leave the <i>Expressions</i> etc.
+ * empty and would make the aspect a monolithic module. <p>
+ *
+ * However, it is still possible to augment or change the behaviour of the
+ * system without changing all participant classes. To show this, we
+ * assumed that <code>BooleanExpression.replace(String, BooleanExpression)</code> and
+ * <code>BooleanExpression.copy()</code> were added later. The methods are
+ * defined in an aspect, so that other classes did not have to change.<p>
+ *
+ * In general, however, this pattern does not lend itself nicely to
+ * aspectification.<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see BooleanExpression
+ */
+
+public class Main {
+
+ /**
+ * Assigns boolean values to two <code>VariableExpression</code>s and evaluates
+ * an expression in the given context.
+ *
+ * @param x a boolean variable expression
+ * @param xValue the value to assign to x
+ * @param y another boolean variable expression
+ * @param yValue the value to assign to y
+ * @param context the context to evaluate the expression in
+ * @param exp the expression to evaluate
+ */
+
+ private static void assignAndEvaluate( VariableExpression x, boolean xValue,
+ VariableExpression y, boolean yValue,
+ VariableContext context, BooleanExpression exp) {
+ context.assign(x, xValue);
+ context.assign(y, yValue);
+ boolean result = exp.evaluate(context);
+ System.out.println("The result for (x="+xValue+", y="+yValue+") is: "+result);
+ }
+
+ /**
+ * Implements the driver for the Intepreter design pattern example.<p>
+ *
+ * This example implements an interpreter for a language of boolean
+ * expressions. As a sample expression, "((true & x) | (y & !x))" is
+ * interpreted for all possible boolean values for x and y. After that,
+ * y is replaced by another expression and the whole expression is
+ * evaluated again.
+ *
+ * @args command-line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+ BooleanExpression exp = null;
+ VariableContext context = new VariableContext();
+
+ VariableExpression x = new VariableExpression("X");
+ VariableExpression y = new VariableExpression("Y");
+
+ exp = new OrExpression(new AndExpression(new BooleanConstant(true), x),
+ new AndExpression(y, new NotExpression(x)));
+
+ System.out.println("Testing Expr: ((true & x) | (y & !x))");
+
+ assignAndEvaluate(x, false, y, false, context, exp);
+ assignAndEvaluate(x, false, y, true, context, exp);
+ assignAndEvaluate(x, true, y, false, context, exp);
+ assignAndEvaluate(x, true, y, true, context, exp);
+
+ VariableExpression z = new VariableExpression("Z");
+ NotExpression notZ = new NotExpression(z);
+
+ BooleanExpression replacement = exp.replace("Y", notZ);
+ context.assign(z, false);
+ boolean result = replacement.evaluate(context);
+
+ System.out.println("The result for the replacement is: "+result);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/NotExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/NotExpression.java
new file mode 100644
index 000000000..817fd85f7
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/NotExpression.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements negation for booleans expressions. This is a concrete boolean
+ * <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class NotExpression implements BooleanExpression {
+
+ /**
+ * the <i>Expression</i> this <i>Expression</i> negates
+ */
+
+ protected BooleanExpression exp = null;
+
+ /**
+ * Creates a new NOT <i>Expression</i> negating the argument expression
+ *
+ * @param exp the <i>Expression</i> to negate
+ */
+
+ public NotExpression(BooleanExpression exp) {
+ this.exp = exp;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given
+ * <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (! exp.evaluate(c));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/OrExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/OrExpression.java
new file mode 100644
index 000000000..e8b7b6e0a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/OrExpression.java
@@ -0,0 +1,70 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an OR <i>Expression</i> for booleans.
+ * This is a concrete boolean <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class OrExpression implements BooleanExpression {
+
+ /**
+ * stores the first part of this OR <i>Expression</i>
+ */
+
+ protected BooleanExpression expression1;
+
+ /**
+ * stores the second part of this OR <i>Expression</i>
+ */
+
+ protected BooleanExpression expression2;
+
+ /**
+ * Creates a new OR <i>Expression</i> with the given parts
+ *
+ * @param op1 the first <i>Expression</i>
+ * @param op1 the second <i>Expression</i>
+ */
+
+ public OrExpression(BooleanExpression op1, BooleanExpression op2) {
+ this.expression1 = op1;
+ this.expression2 = op2;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (expression1.evaluate(c) || expression2.evaluate(c));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableContext.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableContext.java
new file mode 100644
index 000000000..51c2a3f54
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableContext.java
@@ -0,0 +1,71 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Implements a <i>VariableContext</i> for the interpretation of boolean
+ * expressions<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see BooleanExpression
+ */
+
+public class VariableContext {
+
+ /**
+ * stores the mapping between variable names and values
+ */
+
+ protected Hashtable assignments = new Hashtable();
+
+ /**
+ * Returns the current value for a variable
+ *
+ * @param name the name of the variable
+ * @returns the value of the variable
+ */
+
+ public boolean lookup(String name) {
+ Boolean value = (Boolean) assignments.get(name);
+ if (value == null) {
+ throw new ExpressionException("No variable \""+name+"\" declared.");
+ }
+ return value.booleanValue();
+ }
+
+ /**
+ * Assigns a boolean value to a <code>VariableExpression</code>
+ *
+ * @param varExp the varaible expression to assign a value to
+ * @param bool the boolean value to assign
+ */
+
+ public void assign(VariableExpression varExp, boolean bool) {
+ assignments.put(varExp.getName(), new Boolean(bool));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableExpression.java
new file mode 100644
index 000000000..48668bb6b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/VariableExpression.java
@@ -0,0 +1,73 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a variable expression for booleans. This is a concrete
+ * boolean <i>NonterminalExpression</i>
+ * expression
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class VariableExpression implements BooleanExpression {
+
+ /**
+ * the name of the variable this object represents
+ */
+
+ protected String name = null;
+
+ /**
+ * Creates a new variable <i>Expression</i> with a given name
+ *
+ * @param name the name of the new variable
+ */
+
+ public VariableExpression(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Accessor for the variable's name
+ *
+ * @return the name of the variable
+ */
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return c.lookup(name);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/AndExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/AndExpression.java
new file mode 100644
index 000000000..89b5243e6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/AndExpression.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements AND expressions for booleans. This is a concrete boolean
+ * <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class AndExpression implements BooleanExpression {
+
+ /**
+ * stores the first part of this AND <i>Expression</i>
+ */
+
+ protected BooleanExpression expression1;
+
+ /**
+ * stores the second part of this AND <i>Expression</i>
+ */
+
+ protected BooleanExpression expression2;
+
+ /**
+ * Creates a new AND <i>Expression</i> with the given parts
+ *
+ * @param expression1 the first <i>Expression</i>
+ * @param expression1 the second <i>Expression</i>
+ */
+
+ public AndExpression(BooleanExpression op1, BooleanExpression op2) {
+ this.expression1 = op1;
+ this.expression2 = op2;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given
+ * <code>VariableContext</code>
+ *
+ * @param c the <i>Context</i> to evaluate the <i>Expression</i> in
+ * @return the boolean value of this AND <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (expression1.evaluate(c) && expression2.evaluate(c));
+ }
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp) {
+ return new AndExpression(expression1.replace(name, exp), expression2.replace(name,exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @returns the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy() {
+ return new AndExpression(expression1.copy(), expression2.copy());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanConstant.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanConstant.java
new file mode 100644
index 000000000..8d6c13ab0
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanConstant.java
@@ -0,0 +1,84 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements boolean constants, a concrete boolean <i>TerminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class BooleanConstant implements BooleanExpression {
+
+ /**
+ * the value of this constant
+ */
+
+ protected boolean value;
+
+ /**
+ * Creates a new constant with the given value
+ *
+ * @param value the value this constant should represent
+ */
+
+ public BooleanConstant(boolean value) {
+ this.value = value;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>.
+ *
+ * @param c the <i>Context</i> to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return value;
+ }
+
+ /**
+ * Replaces a variable with an <i>Expression</i>.
+ * Has no effect on constants.
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return the unchanged constant
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp) {
+ return this;
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy() {
+ return new BooleanConstant(value);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanExpression.java
new file mode 100644
index 000000000..502be4c75
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/BooleanExpression.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the <i>AbstractExpression</i> interface for boolean expressions.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public interface BooleanExpression {
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>VariableContext</i>
+ *
+ * @param c the <i>Context</i> to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c);
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp);
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/ExpressionException.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/ExpressionException.java
new file mode 100644
index 000000000..faeeb984c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/ExpressionException.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an exception that gets raised when the interpreter
+ * runs into errors.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class ExpressionException extends RuntimeException {
+
+ /**
+ * Creates a new ExpressionException with the given message
+ *
+ * @param s the exception message
+ */
+
+ public ExpressionException(String s) {
+ super(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/Main.java
new file mode 100644
index 000000000..5cc790967
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/Main.java
@@ -0,0 +1,115 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Intepreter design pattern example.<p>
+ *
+ * Intent: <i>Given a language, define a representation for its grammar along
+ * with an interpreter that uses the representation to interpret sentences
+ * in the language.</i><p>
+ *
+ * Participating objects are: <code>BooleanContant</code> as
+ * <i>TerminalExpression</i>; <code>VariableExpression</code>,
+ * <code>OrExpression</code>, <code>AndExpression</code>, and
+ * <code>NotExpression</code> as <i>NonterminalExpressions</i>.
+ *
+ * The <i>AbstractExpression</i> interface is defined
+ * in <code>BooelanExp</i>.<p>
+ *
+ * This example implements an interpreter for a language of boolean
+ * expressions. As a sample expression, "((true & x) | (y & !x))" is
+ * interpreted for all possible boolean values for x and y. After that,
+ * y is replaced by another expression and the whole expression is
+ * evaluated again.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ *
+ * @see BooleanExpression
+ */
+
+public class Main {
+
+ /**
+ * Assigns boolean values to two <code>VariableExpression</code>s
+ * and evaluates an expression in the given context.
+ *
+ * @param x a boolean variable expression
+ * @param xValue the value to assign to x
+ * @param y another boolean variable expression
+ * @param yValue the value to assign to y
+ * @param context the context to evaluate the expression in
+ * @param exp the expression to evaluate
+ */
+
+ private static void assignAndEvaluate(
+ VariableExpression x,
+ boolean xValue,
+ VariableExpression y,
+ boolean yValue,
+ VariableContext context,
+ BooleanExpression exp) {
+ context.assign(x, xValue);
+ context.assign(y, yValue);
+ boolean result = exp.evaluate(context);
+ System.out.println("The result for (x="+xValue+", y="+yValue+") is: "+result);
+ }
+
+ /**
+ * Implements the driver for the Intepreter design pattern example.<p>
+ *
+ * @param command-line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+ BooleanExpression exp = null;
+ VariableContext context = new VariableContext();
+
+ VariableExpression x = new VariableExpression("X");
+ VariableExpression y = new VariableExpression("Y");
+
+ exp = new OrExpression(new AndExpression(new BooleanConstant(true), x),
+ new AndExpression(y, new NotExpression(x)));
+
+ System.out.println("Testing Expression: ((true & x) | (y & !x))");
+
+ assignAndEvaluate(x, false, y, false, context, exp);
+ assignAndEvaluate(x, false, y, true, context, exp);
+ assignAndEvaluate(x, true, y, false, context, exp);
+ assignAndEvaluate(x, true, y, true, context, exp);
+
+ VariableExpression z = new VariableExpression("Z");
+ NotExpression notZ = new NotExpression(z);
+
+ BooleanExpression replacement = exp.replace("Y", notZ);
+ context.assign(z, false);
+ boolean result = replacement.evaluate(context);
+
+ System.out.println("The result for the replacement is: "+result);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/NotExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/NotExpression.java
new file mode 100644
index 000000000..298d4e2ee
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/NotExpression.java
@@ -0,0 +1,85 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements negation for booleans expressions. This is a concrete boolean
+ * <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class NotExpression implements BooleanExpression {
+
+ /**
+ * the <i>Expression</i> this <i>Expression</i> negates
+ */
+
+ protected BooleanExpression exp = null;
+
+ /**
+ * Creates a new NOT <i>Expression</i> negating the
+ * argument <i>Expression</i>
+ *
+ * @param exp the <i>Expression</i> to negate
+ */
+
+ public NotExpression(BooleanExpression exp) {
+ this.exp = exp;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (! exp.evaluate(c));
+ }
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp) {
+ return new NotExpression(this.exp.replace(name, exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @returns the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy() {
+ return new NotExpression(exp.copy());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/OrExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/OrExpression.java
new file mode 100644
index 000000000..c2a3f2485
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/OrExpression.java
@@ -0,0 +1,92 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an OR <i>Expression</i> for booleans.
+ * This is a concrete boolean <i>NonterminalExpression</i>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class OrExpression implements BooleanExpression {
+
+ /**
+ * stores the first part of this OR <i>Expression</i>
+ */
+
+ protected BooleanExpression expression1;
+
+ /**
+ * stores the second part of this OR <i>Expression</i>
+ */
+
+ protected BooleanExpression expression2;
+
+ /**
+ * Creates a new OR <i>Expression</i> with the given parts
+ *
+ * @param expression1 the first <i>Expression</i>
+ * @param expression1 the second <i>Expression</i>
+ */
+
+ public OrExpression(BooleanExpression op1, BooleanExpression op2) {
+ this.expression1 = op1;
+ this.expression2 = op2;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @returns the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return (expression1.evaluate(c) || expression2.evaluate(c));
+ }
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @returns a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp) {
+ return new OrExpression(expression1.replace(name, exp), expression2.replace(name,exp));
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @returns the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy() {
+ return new OrExpression(expression1.copy(), expression2.copy());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableContext.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableContext.java
new file mode 100644
index 000000000..c9f59d0e4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableContext.java
@@ -0,0 +1,69 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Implements a <i>Context</i> for the interpretation of boolean
+ * expressions<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class VariableContext {
+
+ /**
+ * stores the mapping between variable names and values
+ */
+
+ protected Hashtable assignments = new Hashtable();
+
+ /**
+ * Returns the current value for a variable
+ *
+ * @param name the name of the variable
+ * @return the value of the variable
+ */
+
+ public boolean lookup(String name) {
+ Boolean value = (Boolean) assignments.get(name);
+ if (value == null) {
+ throw new ExpressionException("No variable \""+name+"\" known.");
+ }
+ return value.booleanValue();
+ }
+
+ /**
+ * Assigns a boolean value to a <code>VariableExpression</code>
+ *
+ * @param varExp the varaible <i>Expression</i> to assign a value to
+ * @param bool the boolean value to assign
+ */
+
+ public void assign(VariableExpression varExp, boolean bool) {
+ assignments.put(varExp.getName(), new Boolean(bool));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableExpression.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableExpression.java
new file mode 100644
index 000000000..caa429898
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/interpreter/java/VariableExpression.java
@@ -0,0 +1,99 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a variable expression for booleans. This is a concrete
+ * boolean <i>NonterminalExpression</i>
+ * expression
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public class VariableExpression implements BooleanExpression {
+
+ /**
+ * the name of the variable this object represents
+ */
+
+ protected String name = null;
+
+ /**
+ * Creates a new <code>VariableExpression</code> with the given name
+ *
+ * @param name the name of the new variable
+ */
+
+ public VariableExpression(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Accessor for the variable's name
+ *
+ * @return the name of the variable
+ */
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Evaluates this <i>Expression</i> in the given <i>Context</i>
+ *
+ * @param c the context to evaluate the <i>Expression</i> in
+ * @return the boolean value of the <i>Expression</i>
+ */
+
+ public boolean evaluate(VariableContext c) {
+ return c.lookup(name);
+ }
+
+ /**
+ * Replaces a variable with an <i>Expression</i>
+ *
+ * @param name the name of the variable
+ * @param exp the <i>Expression</i> to replace the variable
+ * @return a copy of this <i>Expression</i> with the variable replaced
+ */
+
+ public BooleanExpression replace(String name, BooleanExpression exp) {
+ if (name.equals(this.name)) {
+ return exp.copy();
+ } else {
+ return new VariableExpression(this.name);
+ }
+ }
+
+ /**
+ * Copies this <i>Expression</i>
+ *
+ * @return the copied <i>Expression</i>
+ */
+
+ public BooleanExpression copy() {
+ return new VariableExpression(name);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/Main.java
new file mode 100644
index 000000000..5afe1bc77
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/Main.java
@@ -0,0 +1,98 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Iterator;
+
+/**
+ * Implements the driver for the Iterator design pattern example.<p>
+ *
+ * Intent: <i>Provide a way to access the elements of an aggregate object
+ * sequentially without exposing its underlying representation.</i><p>
+ *
+ * Participating objects are <code>SimpleList</code> as <i>Aggregate</i>,
+ * <code>OpenList</code> as <i>ConcreteAggregate</i>, <code>
+ * java.util.Iterator</code> as <i>Iterator</i>, and <code>ReverseIterator
+ * </code> as <i>ConcreteIterator</i>.
+ *
+ * In this example, the concrete aggregate is a list that gets filled with
+ * five integer objects (1 to 5). The, the <code>ReverseIterator</code> is
+ * created and used to print all elements in reverse order.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see SimpleList
+ * @see OpenList
+ * @see java.util.Iterator
+ * @see OpenListIteration
+ */
+
+
+public class Main {
+
+ /**
+ * Prints all elements in the iterator to <code>System.out</code>.
+ *
+ * @param iter the iterator which elements are to be printed
+ */
+
+ private static void print(Iterator iter) {
+ while(iter.hasNext()) {
+ System.out.println(iter.next());
+ }
+ }
+
+ /**
+ * Implements the driver for the Iterator design pattern example.<p>
+ *
+ * In this example, the concrete aggregate is a list that gets filled with
+ * five integer objects (1 to 5). The, the <code>ReverseIterator</code> is
+ * created and used to print all elements in reverse order.
+ *
+ * @param args command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ OpenList openList = new OpenList();
+ openList.append(new Integer(1));
+ openList.append(new Integer(2));
+ openList.append(new Integer(3));
+ openList.append(new Integer(4));
+ openList.append(new Integer(5));
+
+ System.out.println("List created, containing int objects 1, 2, 3, 4, 5.");
+
+ Iterator iter = OpenListIteration.aspectOf().createIteratorFor(openList);
+
+ System.out.println("Using ReverseIterator to print list elements in reverse order...");
+
+ print(iter);
+
+ System.out.println("done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenList.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenList.java
new file mode 100644
index 000000000..7eb5d04a1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenList.java
@@ -0,0 +1,88 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Iterator;
+
+/**
+ * Implements a basic open list. This implementation is based on
+ * <code>java.util.LinkedList</code>. In essence, this class acts as an
+ * adapter for the Java class. <p>
+ *
+ * In this version, it is no longer necessary to implement the factory
+ * method here to create the iterator.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class OpenList implements SimpleList {
+
+ java.util.LinkedList list = new java.util.LinkedList();
+
+ /**
+ * Returns the number of elements in the list
+ *
+ * @return the number of elements in the list
+ */
+
+ public int count() {
+ return list.size();
+ }
+
+ /**
+ * Appends an object to the list. Since this is an open list, inserting
+ * elements is assumed to succeed.
+ *
+ * @param o the object to append
+ * @return true if successful, false otherwise
+ */
+
+ public boolean append(Object o) {
+ list.addLast(o);
+ return true;
+ }
+
+ /**
+ * Removes an object from the list
+ *
+ * @param o the object to remove
+ * @return true if successful, false otherwise
+ */
+
+ public boolean remove(Object o) {
+ return list.remove(o);
+ }
+
+ /**
+ * Returns an object from the list
+ *
+ * @param index the position of the object
+ * @return the object at position index
+ */
+
+ public Object get(int index) {
+ return list.get(index);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenListIteration.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenListIteration.java
new file mode 100644
index 000000000..0fc2b1724
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/OpenListIteration.java
@@ -0,0 +1,130 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.NoSuchElementException;
+import java.util.Iterator;
+
+/**
+ * Implements a concrete instance of the Iterator design pattern. This
+ * concrete aspect attaches a factory method to the <i>Aggregate</i> class
+ * and provides an implementation for the Iterator via an inner class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see SimpleList
+ * @see OpenList
+ */
+
+public aspect OpenListIteration {
+
+ /**
+ * Implements the factory method to create the reverse iterator for the
+ * OpenList class using the open classes mechanism.
+ */
+
+ Iterator OpenList.createReverseIterator() {
+ return new ReverseIterator(this);
+ }
+
+ /**
+ * Another possibility to define the factory method here. If we
+ * have the factory method on the aspect, multiple instances of the
+ * same pattern will not be confused an can use the same aggregate
+ * (multiple factory methods won't conflict that way, even if they
+ * have the same signature). This is the preferable implementation.
+ */
+
+ Iterator createIteratorFor(OpenList list) {
+ return new ReverseIterator(list);
+ }
+
+ /**
+ * Provides the implementation of the reverse iterator. Instead
+ * of defining an inner class, one could also instantiate
+ * <code>java.util.Iterator</code> as an anonymous class and overwrite
+ * the appropriate methods.
+ */
+
+ static class ReverseIterator implements Iterator {
+
+ /**
+ * the positition of the current element
+ */
+
+ protected int current;
+
+ /**
+ * the list this iterator operates on
+ */
+
+ protected SimpleList list;
+
+ /**
+ * Returns true if the iteration has more elements.
+ *
+ * @return true if the iteration has more elements
+ */
+
+ public boolean hasNext() {
+ return (current > 0);
+ }
+
+ /**
+ * This opional method is not implemented for this iterator.
+ */
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported");
+ }
+
+ /**
+ * Returns the next element in the iteration.
+ *
+ * @return the next element in the iteration.
+ */
+
+ public Object next() {
+ if (!hasNext()) {
+ throw new ArrayIndexOutOfBoundsException("Iterator out of Bounds");
+ } else {
+ return list.get(--current);
+ }
+ }
+
+ /**
+ * Creates a new ReverseIterator from the given list.
+ *
+ * @param list the list to generate an iterator from
+ */
+
+ public ReverseIterator(SimpleList list) {
+ super();
+ this.list = list;
+ current = list.count();
+ }
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/SimpleList.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/SimpleList.java
new file mode 100644
index 000000000..c8b7384c8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/SimpleList.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines an interface for a basic list.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see OpenList
+ */
+
+public interface SimpleList {
+
+ /**
+ * Returns the number of elements in the list
+ *
+ * @return the number of elements in the list
+ */
+
+ public int count();
+
+ /**
+ * Appends an object to the list
+ *
+ * @param o the object to append
+ * @return true if successful, false otherwise
+ */
+
+ public boolean append(Object o);
+
+ /**
+ * Removes an object from the list
+ *
+ * @param o the object to remove
+ * @return true if successful, false otherwise
+ */
+
+ public boolean remove(Object o);
+
+ /**
+ * Returns an object from the list
+ *
+ * @param index the position of the object
+ * @return the object at position index
+ */
+
+ public Object get(int index);
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/Main.java
new file mode 100644
index 000000000..03d378c91
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/Main.java
@@ -0,0 +1,97 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Iterator;
+
+/**
+ * Implements the driver for the Iterator design pattern example.<p>
+ *
+ * Intent: <i>Provide a way to access the elements of an aggregate object
+ * sequentially without exposing its underlying representation.</i><p>
+ *
+ * Participating objects are <code>SimpleList</code> as <i>Aggregate</i>,
+ * <code>OpenList</code> as <i>ConcreteAggregate</i>, <code>
+ * java.util.Iterator</code> as <i>Iterator</i>, and <code>ReverseIterator
+ * </code> as <i>ConcreteIterator</i>.
+ *
+ * In this example, the concrete aggregate is a list that gets filled with
+ * five integer objects (1 to 5). The, the <code>ReverseIterator</code> is
+ * created and used to print all elements in reverse order.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see SimpleList
+ * @see OpenList
+ * @see java.util.Iterator
+ * @see ReverseIterator
+ */
+
+public class Main {
+
+ /**
+ * Prints all elements in the iterator to <code>System.out</code>.
+ *
+ * @param iter the iterator which elements are to be printed
+ */
+
+ private static void print(Iterator iter) {
+ while(iter.hasNext()) {
+ System.out.println(iter.next());
+ }
+ }
+
+ /**
+ * Implements the driver for the Iterator design pattern example.<p>
+ *
+ * In this example, the concrete aggregate is a list that gets filled with
+ * five integer objects (1 to 5). The, the <code>ReverseIterator</code> is
+ * created and used to print all elements in reverse order.
+ *
+ * @param args command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ OpenList openList = new OpenList();
+ openList.append(new Integer(1));
+ openList.append(new Integer(2));
+ openList.append(new Integer(3));
+ openList.append(new Integer(4));
+ openList.append(new Integer(5));
+
+ System.out.println("List created, containing int objects 1, 2, 3, 4, 5.");
+
+ Iterator iter = openList.createReverseIterator();
+
+ System.out.println("Using ReverseIterator to print list elements in reverse order...");
+
+ print(iter);
+
+ System.out.println("done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/OpenList.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/OpenList.java
new file mode 100644
index 000000000..31fcf7b6d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/OpenList.java
@@ -0,0 +1,95 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Iterator;
+
+/**
+ * Implements a basic open list. This implementation is based on
+ * <code>java.util.LinkedList</code>. In essence, this class acts as an
+ * adapter for the Java class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class OpenList implements SimpleList {
+
+ java.util.LinkedList list = new java.util.LinkedList();
+
+ /**
+ * Returns the number of elements in the list
+ *
+ * @return the number of elements in the list
+ */
+
+ public int count() {
+ return list.size();
+ }
+
+ /**
+ * Appends an object to the list. Since this is an open list, inserting
+ * elements is assumed to succeed.
+ *
+ * @param o the object to append
+ * @return true if successful, false otherwise
+ */
+
+ public boolean append(Object o) {
+ list.addLast(o);
+ return true;
+ }
+
+ /**
+ * Removes an object from the list
+ *
+ * @param o the object to remove
+ * @return true if successful, false otherwise
+ */
+
+ public boolean remove(Object o) {
+ return list.remove(o);
+ }
+
+ /**
+ * Returns an object from the list
+ *
+ * @param index the position of the object
+ * @return the object at the specified index
+ */
+
+ public Object get(int index) {
+ return list.get(index);
+ }
+
+ /**
+ * Returns a reverse iterator for this list.
+ *
+ * @return the a reverse iterator for this list
+ */
+
+ public Iterator createReverseIterator() {
+ return new ReverseIterator(this);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/ReverseIterator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/ReverseIterator.java
new file mode 100644
index 000000000..160f8c77b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/ReverseIterator.java
@@ -0,0 +1,94 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Iterator;
+
+/**
+ * Implements a reverse iterator. This means that it will return elements in
+ * reverse order. We chose not to define our own <i>Iterator</i>, but to use
+ * Java's <code>java.util.Iterator</code> interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class ReverseIterator implements Iterator {
+
+ /**
+ * the positition of the current element
+ */
+
+ protected int current;
+
+ /**
+ * the list this iterator operates on
+ */
+
+ protected SimpleList list;
+
+ /**
+ * Returns true if the iteration has more elements.
+ *
+ * @return true if the iteration has more elements
+ */
+
+ public boolean hasNext() {
+ return (current > 0);
+ }
+
+ /**
+ * This opional method is not implemented for this iterator.
+ */
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported");
+ }
+
+ /**
+ * Returns the next element in the iteration.
+ *
+ * @return the next element in the iteration.
+ */
+
+ public Object next() {
+ if (!hasNext()) {
+ throw new ArrayIndexOutOfBoundsException("Iterator out of Bounds");
+ } else {
+ return list.get(--current);
+ }
+ }
+
+ /**
+ * Creates a new ReverseIterator from the given list.
+ *
+ * @param list the list to generate an iterator from
+ */
+
+ public ReverseIterator(SimpleList list) {
+ super();
+ this.list = list;
+ current = list.count();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/SimpleList.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/SimpleList.java
new file mode 100644
index 000000000..9fa573282
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/iterator/java/SimpleList.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.iterator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines an interface for a basic list.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see OpenList
+ */
+
+public interface SimpleList {
+
+ /**
+ * Returns the number of elements in the list
+ *
+ * @return the number of elements in the list
+ */
+
+ public int count();
+
+ /**
+ * Appends an object to the list
+ *
+ * @param o the object to append
+ * @return true if successful, false otherwise
+ */
+
+ public boolean append(Object o);
+
+ /**
+ * Removes an object from the list
+ *
+ * @param o the object to remove
+ * @return true if successful, false otherwise
+ */
+
+ public boolean remove(Object o);
+
+ /**
+ * Returns an object from the list at a given index
+ *
+ * @param index the position of the object
+ * @return the object at position index
+ */
+
+ public Object get(int index);
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Button.java
new file mode 100644
index 000000000..3ba0ee59f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Button.java
@@ -0,0 +1,57 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Basically a <code>JButton</code> with an <code>ActionListener</code>.
+ * The listener calls <code>clicked()</code> when the button gets pressed.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Button extends JButton {
+
+ /**
+ * Creates a new <code>Button</code> object with the provided label.
+ *
+ * @param name the label for the new <code>Button</code> object
+ */
+
+ public Button(String name) {
+ super(name);
+ this.setActionCommand(name);
+ this.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ clicked();
+ }
+ });
+ }
+
+ public void clicked() {}
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Label.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Label.java
new file mode 100644
index 000000000..d19f6bef2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Label.java
@@ -0,0 +1,46 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+
+/**
+ * Basically a JLabel. Acts as <i>Mediator</i>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Label extends JLabel {
+
+ /**
+ * Creates a new <code>Label</code> object with the provided name.
+ *
+ * @param s the tag for the new <code>Label</code> object
+ */
+
+ public Label(String s) {
+ super(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Main.java
new file mode 100644
index 000000000..605b6ed3f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/Main.java
@@ -0,0 +1,89 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * Implements the driver for the mediator design pattern example.<p>
+ *
+ * Intent: <i>Define an object that encapsulates how a set of objects
+ * interact. Mediator promotes loose coupling by keeping objects from
+ * referring to each other explicitly, and it lets you vary their interaction
+ * independently.</i><p>
+ *
+ * Participating objects are <code>Button</code>s as <i>Colleague</i>s,
+ * and a <code>Label</code> as <i>Mediator</i>.
+ *
+ * Every time an event of interest (a button click) occurs, the mediating
+ * <code>Label</code> is updated and it updates the calling button.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see Button
+ * @see Label
+ */
+
+public class Main {
+
+
+ static JFrame frame = new JFrame("Mediator Demo");
+ static Button button1 = new Button("Button1");
+ static Button button2 = new Button("Button2");
+ static Label label = new Label ("Click a button!");
+
+ /**
+ * Implements the driver for the mediator example. It creates a small
+ * GUI with a label and two buttons. The buttons are <i>Colleague</i>s,
+ * the label is the <i>Mediator</i>.
+ *
+ * Each button click causes the mediator to update itself and the
+ * calling button.
+ */
+
+ public static void main(String[] args) {;
+
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ JPanel panel = new JPanel();
+
+ panel.add(label);
+ panel.add(button1);
+ panel.add(button2);
+
+ frame.getContentPane().add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ MediatorImplementation.aspectOf().setMediator(button1, label);
+ MediatorImplementation.aspectOf().setMediator(button2, label);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/MediatorImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/MediatorImplementation.java
new file mode 100644
index 000000000..8a3a9e31b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/MediatorImplementation.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.MediatorProtocol;
+
+/**
+ * Concretizes the mediation relationship for <code>Button</code>
+ * (as <i>Colleague</i>) and <code>Label</code> (as <i>Mediator</i>).
+ * <code>Button</code> clicks trigger <code>Label</code> updates.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public aspect MediatorImplementation extends MediatorProtocol {
+
+ /**
+ * Assings the <i>Colleague</i> role to the <code>Button</code>
+ * class. Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Button implements Colleague;
+
+ /**
+ * Assings the <i>Mediator</i> role to the <code>Label</code>
+ * class. Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Label implements Mediator;
+
+ /**
+ * Defines what changes on Colleagues cause their <i>Mediator</i> to be
+ * notified (here: Button clicks)
+ *
+ * @param cs the colleague on which the change occured
+ */
+
+ protected pointcut change(Colleague c):
+ (call(void Button.clicked()) && target(c));
+
+ /**
+ * Defines how the <i>Mediator</i> is to be updated when a change
+ * to a <i>Colleague</i> occurs. Here, the label's text is set
+ * depending on which button was clicked. The appropriate button's label
+ * is also updated.
+ *
+ * @param c the colleague on which a change of interest occured
+ * @param m the mediator to be notifed of the change
+ */
+
+ protected void notifyMediator(Colleague c, Mediator m) {
+ Button button = (Button) c;
+ Label label = (Label) m;
+ if (button == Main.button1) {
+ label.setText("Button1 clicked");
+ } else if (button == Main.button2) {
+ label.setText("Button2 clicked");
+ }
+ button.setText("(Done)");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Button.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Button.java
new file mode 100644
index 000000000..6c6854033
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Button.java
@@ -0,0 +1,71 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.JButton;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+
+/**
+ * Basically a <code>JButton</code> with an <code>ActionListener</code>.
+ * The listener calls <code>clicked()</code> when the button gets pressed.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Button extends JButton implements GUIColleague {
+
+ private GUIMediator mediator;
+
+ /**
+ * Creates a new <code>Button</code> object with the provided label.
+ *
+ * @param name the label for the new <code>Button</code> object
+ */
+
+ public Button(String name) {
+ super(name);
+ this.setActionCommand(name);
+ this.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ clicked();
+ }
+ });
+ }
+
+ public void clicked() {
+ mediator.colleagueChanged(this);
+ }
+
+ /**
+ * Allows to set the <i>Mediator</i> for this <i>Colleague</i>
+ *
+ * @param mediator the new mediator
+ */
+
+ public void setMediator(GUIMediator mediator) {
+ this.mediator = mediator;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIColleague.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIColleague.java
new file mode 100644
index 000000000..69c281432
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIColleague.java
@@ -0,0 +1,44 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This interface is implemented by all types that the <i>Mediator</i>
+ * interacts with.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public interface GUIColleague {
+
+ /**
+ * Defines the method signature for setting a <i>Colleague</i>'s
+ * <i>Mediator</i>.
+ *
+ * @param mediator the new mediator
+ */
+
+ public void setMediator(GUIMediator mediator);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIMediator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIMediator.java
new file mode 100644
index 000000000..61efcfc84
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/GUIMediator.java
@@ -0,0 +1,45 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This is the <i>Mediator</i> interface. It defines a method for dealing
+ * with changes in <i>Colleague</i>s that require updates.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public interface GUIMediator {
+
+ /**
+ * Defines the method signature for notifying <i>Mediator</i>s of changes
+ * to <i>Colleague</i>s. This method is called by colleagues who
+ * pass themselves as an argument (push model).
+ *
+ * @param colleague the changing colleage
+ */
+
+ public void colleagueChanged(GUIColleague colleague);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Label.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Label.java
new file mode 100644
index 000000000..2146ff340
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Label.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+
+/**
+ * Basically a JLabel. Acts as <i>Mediator</i>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Label extends JLabel implements GUIMediator {
+
+ /**
+ * Creates a new <code>Label</code> object with the provided name.
+ *
+ * @param s the tag for the new <code>Label</code> object
+ */
+
+ public Label(String s) {
+ super(s);
+ }
+
+ /**
+ * Handles the event that a <i>colleague</i> chanbged.
+ *
+ * @param colleague the <i>Colleague</i> that caused the notification
+ */
+
+ public void colleagueChanged(GUIColleague colleague) {
+ Button button = (Button) colleague;
+
+ if (button == Main.button1) {
+ this.setText("Button1 clicked");
+ } else if (button == Main.button2) {
+ this.setText("Button2 clicked");
+ }
+ button.setText("(Done)");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Main.java
new file mode 100644
index 000000000..7fcf668f1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/mediator/java/Main.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.mediator.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * Implements the driver for the Mediator design pattern example.<p>
+ *
+ * Intent: <i>Define an object that encapsulates how a set of objects
+ * interact. Mediator promotes loose coupling by keeping objects from
+ * referring to each other explicitly, and it lets you vary their interaction
+ * independently.</i><p>
+ *
+ * Participating objects are <code>Button</code>s as <i>Colleague</i>s,
+ * and a <code>Label</code> as <i>Mediator</i>.
+ *
+ * Every time an event of interest (a button click) occurs, the mediating
+ * <code>Label</code> is updated and it in turn updates the respective
+ * calling button.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Both <i>Mediator</i> and <i>Colleague</i>s have to be aware of their role
+ * within the pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see Button
+ * @see Label
+ */
+
+public class Main {
+
+
+ static JFrame frame = new JFrame("Mediator Demo");
+ static Button button1 = new Button("Button1");
+ static Button button2 = new Button("Button2");
+ static Label label = new Label ("Click a button!");
+
+ /**
+ * Implements the driver for the mediator example. It creates a small
+ * GUI with a label and two buttons. The buttons are <i>Colleague</i>s,
+ * the label is the <i>Mediator</i>.
+ *
+ * Each button click causes the mediator to update itself and the
+ * calling button.
+ */
+
+ public static void main(String[] args) {;
+
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {System.exit(0);}
+ });
+
+ JPanel panel = new JPanel();
+
+ panel.add(label);
+ panel.add(button1);
+ panel.add(button2);
+
+ frame.getContentPane().add(panel);
+ frame.pack();
+ frame.setVisible(true);
+
+ button1.setMediator(label);
+ button2.setMediator(label);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Counter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Counter.java
new file mode 100644
index 000000000..f3f395338
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Counter.java
@@ -0,0 +1,58 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Originator</i> class. Objects of this particular
+ * <i>Originator</i> have state, an int representing the number of time
+ * the <code>increment()</code> method was called.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Counter {
+
+ /**
+ * the number of times <code>increment()</code> was called on this object
+ */
+
+ protected int currentValue = 0;
+
+ /**
+ * increments the counter (this <i>Originator</i>'s state) by one
+ */
+
+ public void increment() {
+ currentValue++;
+ }
+
+ /**
+ * Displays the state of this <i>Originator</i>
+ */
+
+ public void show() {
+ System.out.println("Originator value is " + currentValue);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/CounterMemento.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/CounterMemento.java
new file mode 100644
index 000000000..48fd6aa3b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/CounterMemento.java
@@ -0,0 +1,92 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Memento;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.MementoException;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.MementoProtocol;
+
+/**
+ * Implements an instance of the Memento design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see MyOriginator
+ */
+
+
+public aspect CounterMemento extends MementoProtocol {
+
+ /**
+ * Assigns the <i>Originator</i> role to <code>Counter</code>
+ */
+
+ declare parents: Counter implements Originator;
+
+ /**
+ * Creates a <i>Memento</i> object for an <i>Originator</i>. An anonymous
+ * class is used to realize the Memento
+ *
+ * @param o the originator to create a memento for
+ * @return the <i>Memento</i> storing the originator's state
+ */
+
+ public Memento createMementoFor(Originator o) {
+ if (o instanceof Counter) {
+ Memento m = new Memento() {
+ private Integer state;
+
+ public void setState(Object state) {
+ this.state = (Integer) state;
+ }
+
+ public Object getState() {
+ return state;
+ }
+ };
+ m.setState(new Integer(((Counter)o).currentValue));
+ return m;
+ } else {
+ throw new MementoException("Invalid originator");
+ }
+ }
+
+ /**
+ * Restores this <i>Originator</i> to former state using the
+ * <i>Memento</i> passed
+ *
+ * @param o the originator to restore
+ * @param m the memento that stores the prior state
+ */
+
+ public void setMemento(Originator o, Memento m) {
+ if (o instanceof Counter) {
+ Integer integer = (Integer) m.getState();
+ ((Counter)o).currentValue = integer.intValue();
+ } else {
+ throw new MementoException("Invalid originator");
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Main.java
new file mode 100644
index 000000000..ee2e2a85d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/Main.java
@@ -0,0 +1,85 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Memento;
+
+/**
+ * Implements the driver for the Memento design pattern example.<p>
+ *
+ * Intent: <i>Without violating encapsulation, capture and externalize an
+ * object's internal state so that the object can be restored to this state
+ * later</i><p>
+ *
+ * Participating objects are <code>Memento</code> and <code>Originator</code>
+ * <p>
+ *
+ * This example changes the state of the <i>Originator</i> five times, but
+ * creates a <i>Memento</i> of it after the third change. After the 5 changes
+ * are done, the <i>Memento</i> is used to restore the <i>Originator</i>'s
+ * state.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Memento and Originator are decoupled.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see StateMemento
+ * @see MyOriginator
+ */
+
+
+
+public class Main {
+
+ /**
+ * This example changes the state of the <i>Originator</i> five times, but
+ * creates a <i>Memento</i> of it after the third change. After the 5
+ * changes are done, the <i>Memento</i> is used to restore the
+ * <i>Originator</i>'s state.
+ *
+ * @param args command line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+
+ Memento storedState = null;
+ Counter counter = new Counter();
+
+ for (int i=1; i<=5; i++) {
+ counter.increment();
+ counter.show();
+ if (i==3) {
+ storedState =
+ CounterMemento.aspectOf().createMementoFor(counter);
+ }
+ }
+
+ System.out.println("\nTrying to reinstate state (3)...");
+ CounterMemento.aspectOf().setMemento(counter, storedState);
+ counter.show();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Counter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Counter.java
new file mode 100644
index 000000000..83aca53fe
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Counter.java
@@ -0,0 +1,78 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Originator</i> class. Objects of this particular
+ * <i>Originator</i> have state, an int representing the number of time
+ * the <code>increment()</code> method was called.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Counter {
+
+ /**
+ * the number of times <code>increment()</code> was called on this object
+ */
+
+ protected int currentValue = 0;
+
+ /**
+ * increments the counter (this <i>Originator</i>'s state) by one
+ */
+
+ public void increment() {
+ currentValue++;
+ }
+
+ /**
+ * Displays the state of this <i>Originator</i>
+ */
+
+ public void show() {
+ System.out.println("Originator value is " + currentValue);
+ }
+
+ /**
+ * Creates a <i>Memento</i> from this <i>Originator</i>, storing the
+ * current state
+ */
+
+ public CounterMemento createMemento() {
+ return new CounterMemento(currentValue);
+ }
+
+ /**
+ * Restores this <i>Originator</i> to former state stored by the
+ * memento passed
+ *
+ * @param memento the <i>Memento</i> that stores the prior state
+ */
+
+ public void setMemento(CounterMemento memento) {
+ currentValue = memento.getState();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/CounterMemento.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/CounterMemento.java
new file mode 100644
index 000000000..f2b6dba23
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/CounterMemento.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Memento</i> class. This particular one stores
+ * the counter of its <i>Originator</i> (an int value), and returns it
+ * upon request.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see Originator
+ */
+
+public class CounterMemento {
+
+ /**
+ * stores the <i>Originator</i>'s state
+ */
+
+ private int state;
+
+ /**
+ * Captures the <i>Originator</i>'s state and stores it
+ *
+ * @param newState the state to store
+ */
+
+ public void setState(int newState) {
+ state = newState;
+ }
+
+ /**
+ * Returns the stored <i>Originator</i> state
+ *
+ * @return the stored state
+ */
+
+ public int getState() {
+ return state;
+ }
+
+ /**
+ * Creates a <i>Memento</i> object with the give state
+ *
+ * @param init the initial state to store
+ */
+
+ public CounterMemento(int init) {
+ state = init;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Main.java
new file mode 100644
index 000000000..0827c6972
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/memento/java/Main.java
@@ -0,0 +1,75 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.memento.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the memento design pattern example.<p>
+ *
+ * Intent: <i>Without violating encapsulation, capture and externalize an
+ * object's internal state so that the object can be restored to this state
+ * later</i><p>
+ *
+ * Participating objects are <code>Memento</code> and <code>Originator</code>
+ * <p>
+ *
+ * This example changes the state of the <i>Originator</i> five times, but
+ * creates a <i>Memento</i> of it after the third change. After the 5 changes
+ * are done, the <i>Memento</i> is used to restore the <i>Originator</i>'s
+ * state.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Memento and Originator are tightly coupled.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public class Main {
+
+ /**
+ * This example changes the state of the <i>Originator</i> five times, but
+ * creates a <i>Memento</i> of it after the third change. After the 5
+ * changes are done, the <i>Memento</i> is used to restore the
+ * <i>Originator</i>'s state.
+ */
+
+ public static void main(String[] args) {
+
+ CounterMemento storedState = null;
+ Counter counter = new Counter();
+
+ for (int i=1; i<=5; i++) {
+ counter.increment();
+ counter.show();
+ if (i==3) {
+ storedState = counter.createMemento();
+ }
+ }
+
+ System.out.println("\nTrying to reinstate state (3)...");
+ counter.setMemento(storedState);
+ counter.show();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ColorObserver.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ColorObserver.java
new file mode 100644
index 000000000..5f06c7070
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ColorObserver.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.Color;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ObserverProtocol;
+
+/**
+ * Concretizes the observing relationship for <code>Point</code> (subject)
+ * and <code>Screen</code> (observer). Color changes trigger updates.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public aspect ColorObserver extends ObserverProtocol{
+
+ /**
+ * Assings the <i>Subject</i> role to the <code>Point</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Point implements Subject;
+
+ /**
+ * Assings the <i>Observer</i> role to the <code>Screen</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Screen implements Observer;
+
+ /**
+ * Specifies the join points that represent a change to the
+ * <i>Subject</i>. Captures calls to <code>Point.setColor(Color)
+ * </code>.
+ * @param subject the <code>Point</code> acting as <i>Subject</i>
+ */
+
+ protected pointcut subjectChange(Subject subject):
+ call(void Point.setColor(Color)) && target(subject);
+
+ /**
+ * Defines how <i>Observer</i>s are to be updated when a change
+ * to a <i>Subject</i> occurs.
+ * @param subject the <i>Subject</i> on which a change of interest occured
+ * @param observer the <i>bserver</i> to be notifed of the change
+ */
+
+ protected void updateObserver(Subject subject, Observer observer) {
+ ((Screen)observer).display("Screen updated "+
+ "(point subject changed color).");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/CoordinateObserver.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/CoordinateObserver.java
new file mode 100644
index 000000000..5b843e4ad
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/CoordinateObserver.java
@@ -0,0 +1,76 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ObserverProtocol;
+
+/**
+ * Concretizes the observing relationship for <code>Point</code> (subject)
+ * and <code>Screen</code> (observer). Coordinate changes trigger updates.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public aspect CoordinateObserver extends ObserverProtocol{
+
+
+ /**
+ * Assings the <i>Subject</i> role to the <code>Point</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Point implements Subject;
+
+ /**
+ * Assings the <i>Observer</i> role to the <code>Screen</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Screen implements Observer;
+
+ /**
+ * Specifies the join points that represent a change to the
+ * <i>Subject</i>. Captures calls to <code>Point.setX(int)
+ * </code> and <code>Point.setY(int)</code>.
+ * @param subject the <code>Point</code> acting as <i>Subject</i>
+ */
+
+ protected pointcut subjectChange(Subject subject):
+ (call(void Point.setX(int)) ||
+ call(void Point.setY(int)) ) && target(subject);
+
+ /**
+ * Defines how <i>Observer</i>s are to be updated when a change
+ * to a <i>Subject</i> occurs.
+ *
+ * @param subject the <i>Subject</i> on which a change of interest occured
+ * @param observer the <i>bserver</i> to be notifed of the change
+ */
+
+ protected void updateObserver(Subject subject, Observer observer) {
+ ((Screen)observer).display("Screen updated "+
+ "(point subject changed coordinates).");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Main.java
new file mode 100644
index 000000000..ee36569a7
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Main.java
@@ -0,0 +1,112 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.Color;
+
+/**
+ * Implements the driver for the Observer design pattern example.<p>
+ *
+ * Intent: <i>Define a one-to-many dependency between objects so that when one
+ * object changes state, all its dependents are notified and updated
+ * automatically</i><p>
+ *
+ * Participating objects are <code>Point</code> p and <code>Screen</code>
+ * s1, s2, s3, s4, and s5.<p>
+ *
+ * Three different kinds of observing relationships are realized: <UL>
+ * <LI> <code>Screen</code> s1 and s2 observe color changes of <code>Point
+ * </code> p.
+ * <LI> <code>Screen</code> s3 and s4 observe coordinate changes of <code>
+ * Point</code> p.
+ * <LI> <code>Screen</code> s5 observes the <code>display(String)</code>
+ * methods of <code>Screen</code> s2 and s4.
+ * </UL>
+ *
+ * Every time an event of interest occurs, the observing <code>Screen</code>
+ * prints an appropriate message to stdout. <p>
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Observer example. It creates five
+ * <code>Screen</code> objects and one <code>Point</code> object
+ * and sets the appropriate observing relationships (see above).
+ * After the setup, the color of the point is changed, then it's
+ * x-coordinate. <p>
+ * The following results should be expected: <OL>
+ * <LI> The color change should trigger s1 and s2 to each print an
+ * appropriate message.
+ * <LI> s2's message should trigger it's observer s5 to print
+ * a message.
+ * <LI> The coordinate change should trigger s3 and s4.
+ * <LI> s4's message should trigger it's observer s5 again.
+ * </OL>
+ */
+
+ public static void main(String argv[]) {
+
+ Point p = new Point(5, 5, Color.blue);
+
+ System.out.println("Creating Screen s1,s2,s3,s4,s5 and Point p");
+
+ Screen s1 = new Screen("s1");
+ Screen s2 = new Screen("s2");
+
+ Screen s3 = new Screen("s3");
+ Screen s4 = new Screen("s4");
+
+ Screen s5 = new Screen("s5");
+
+ System.out.println("Creating observing relationships:");
+ System.out.println("- s1 and s2 observe color changes to p");
+ System.out.println("- s3 and s4 observe coordinate changes to p");
+ System.out.println("- s5 observes s2's and s4's display() method");
+
+ ColorObserver.aspectOf().addObserver(p, s1);
+ ColorObserver.aspectOf().addObserver(p, s2);
+
+ CoordinateObserver.aspectOf().addObserver(p, s3);
+ CoordinateObserver.aspectOf().addObserver(p, s4);
+
+ ScreenObserver.aspectOf().addObserver(s2, s5);
+ ScreenObserver.aspectOf().addObserver(s4, s5);
+
+ System.out.println("Changing p's color:");
+
+ p.setColor(Color.red);
+
+ System.out.println("Changing p's x-coordinate:");
+
+ p.setX(4);
+
+ System.out.println("done.");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Point.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Point.java
new file mode 100644
index 000000000..908dc6d3e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Point.java
@@ -0,0 +1,112 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.Color;
+
+/**
+ * Represents a point with x and y coordinates and a color.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public class Point {
+
+ /**
+ * the point's x-coordinate
+ */
+
+ private int x;
+
+ /**
+ * the point's y-coordinate
+ */
+
+ private int y;
+
+ /**
+ * the point's current color
+ */
+
+ private Color color;
+
+ /**
+ * Creates a new point object based on x and y coordinates and color.
+ */
+
+ public Point(int x, int y, Color color) {
+ this.x=x;
+ this.y=y;
+ this.color=color;
+ }
+
+ /**
+ * Returns the point's current x-coordinate.
+ *
+ * @return the current x-coordinate
+ */
+
+ public int getX() { return x; }
+
+ /**
+ * Returns the point's current y-coordinate.
+ *
+ * @return the current y-coordinate
+ */
+
+ public int getY() { return y; }
+
+ /**
+ * Sets the current x-coordinate.
+ *
+ * @param x the new x-coordinate
+ */
+
+ public void setX(int x) { this.x=x; }
+
+ /**
+ * Sets the current y-coordinate.
+ *
+ * @param y the new y-coordinate
+ */
+
+ public void setY(int y) { this.y=y; }
+
+ /**
+ * Returns the point's current color.
+ *
+ * @return the current color
+ */
+
+ public Color getColor() { return color; }
+
+ /**
+ * Sets the current color.
+ *
+ * @param color the new color
+ */
+
+ public void setColor(Color color) { this.color=color; }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Screen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Screen.java
new file mode 100644
index 000000000..bad74f3fa
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/Screen.java
@@ -0,0 +1,63 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Provides a means to output messages. Objects of this class act as
+ * output devices.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public class Screen {
+
+ /**
+ * the individual name of this screen object
+ */
+
+ private String name;
+
+ /**
+ * creates a new <code>Screen</code> object with the provided name.
+ *
+ * @param name the name for the new <code>Screen</code> object
+ */
+
+ public Screen(String s) {
+ this.name = s;
+ }
+
+
+ /**
+ * Prints the name of the <code>Screen</code> object and the argument
+ * string to stdout.
+ *
+ * @param s the string to print
+ */
+
+ public void display (String s) {
+ System.out.println(name + ": " + s);
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ScreenObserver.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ScreenObserver.java
new file mode 100644
index 000000000..ce5405797
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/ScreenObserver.java
@@ -0,0 +1,77 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ObserverProtocol;
+
+/**
+ * Concretizes the observing relationship for <code>Screen</code> (subject)
+ * and <code>Screen</code> (observer). Calls of <code>Screen.display(String)
+ * </code> trigger updates.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public aspect ScreenObserver extends ObserverProtocol{
+
+ /**
+ * Assings the <i>Subject</i> role to the <code>Screen</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Screen implements Subject;
+
+ /**
+ * Assings the <i>Observer</i> role to the <code>Screen</code> class.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ declare parents: Screen implements Observer;
+
+ /**
+ * Specifies the join points that represent a change to the
+ * <i>Subject</i>. Captures calls to <code>Screen.display(String)
+ * </code>.
+ *
+ * @param subject the <code>Point</code> acting as <i>Subject</i>
+ */
+
+ protected pointcut subjectChange(Subject subject):
+ call(void Screen.display(String)) && target(subject);
+
+ /**
+ * Defines how <i>Observer</i>s are to be updated when a change
+ * to a <i>Subject</i> occurs.
+ *
+ * @param subject the <i>Subject</i> on which a change of interest occured
+ * @param observer the <i>bserver</i> to be notifed of the change
+ */
+
+ protected void updateObserver(Subject subject, Observer observer) {
+ ((Screen)observer).display("Screen updated " +
+ "(screen subject displayed message).");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeObserver.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeObserver.java
new file mode 100644
index 000000000..073156b72
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeObserver.java
@@ -0,0 +1,43 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the method used to update <i>Observer<i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public interface ChangeObserver {
+
+ /**
+ * Updates an <i>Observer</i>. Uses the <i>push</i> strategy (i.e. the
+ * subject triggering the update passes itself as an argument).
+ *
+ * @param s the <i>Subject</i> triggering the update
+ */
+
+ public void update(ChangeSubject s);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeSubject.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeSubject.java
new file mode 100644
index 000000000..60fb491b8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/ChangeSubject.java
@@ -0,0 +1,57 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares methods to attach and detach <i>Observer<i>s to/from
+ * <i>Subject</i>s, and the <code>notifyObservers()</code> method.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public interface ChangeSubject {
+
+ /**
+ * Attaches an <i>Observer</i> to this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to attach
+ */
+
+ public void attach(ChangeObserver o);
+
+ /**
+ * Detaches an <i>Observer</i> from this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to detach
+ */
+
+ public void detach(ChangeObserver o);
+
+ /**
+ * Notifies all <i>Observer</i>s.
+ */
+
+ public void notifyObservers();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Main.java
new file mode 100644
index 000000000..fbd1bc0a3
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Main.java
@@ -0,0 +1,141 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.Color;
+
+/**
+ * Implements the driver for the Observer design pattern example.<p>
+ *
+ * Intent: <i>Define a one-to-many dependency between objects so that when one
+ * object changes state, all its dependents are notified and updated
+ * automatically</i><p>
+ *
+ * Participating objects are <code>Point</code> p and <code>Screen</code>
+ * s1, s2, s3, s4, and s5.<p>
+ *
+ * Three different kinds of observing relationships are realized: <UL>
+ * <LI> <code>Screen</code> s1 and s2 observe color changes of <code>Point
+ * </code> p.
+ * <LI> <code>Screen</code> s3 and s4 observe coordinate changes of <code>
+ * Point</code> p.
+ * <LI> <code>Screen</code> s5 observes the <code>display(String)</code>
+ * methods of <code>Screen</code> s2 and s4.
+ * </UL>
+ *
+ * Every time an event of interest occurs, the observing <code>Screen</code>
+ * prints an appropriate message to stdout. <p>
+ *
+ * <p>This is the Java version.</i><p>
+ *
+ * The example illustrates that it is hard to
+ * cleanly modularize the different observing relationships. The following
+ * implementation issues have to be considered for the Java version:
+ * <UL>
+ * <LI> Observer and Subject can only be interfaces (as opposed to abstract
+ * classes) if we do not want to restrict inhertance and thus code
+ * reuse of existing classes completely.
+ * <LI> As interfaces, we cannot attach default implementations for methods
+ * like <i>attach(Observer)</i>, <i>notify()</i>, etc. Note that
+ * these two problems only apply because Java does not offer multiple
+ * inheritance.
+ * <LI> Some implementation constraints are made implicit and are thus not
+ * enforced: I.e., each <i>Subject</i> needs a field to store its
+ * <i>Observer</i>s
+ * <LI> The classes that become <i>Subject</i> and <i>Observer</i> in the
+ * pattern context need to be modified. In particular, <i>Subject</i>s
+ * need to store the mapping, implement the appropriate procedures.
+ * <i>Observer</i>s need to
+ * implement <i>update()</i>
+ * <LI> If a particular class takes part in more than one observing
+ * relationship (as in this example), it is difficult to have both
+ * notify/update mechanisms go through the same interface and yet
+ * separate them cleanly.
+ * </UL>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see Point
+ * @see Adaptee
+ * @see Observer
+ * @see Subject
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Observer example. It creates five
+ * <code>Screen</code> objects and one <code>Point</code> object
+ * and sets the appropriate observing relationships (see above).
+ * After the setup, the color of the point is changed, then it's
+ * x-coordinate. <p>
+ * The following results should be expected: <OL>
+ * <LI> The color change should trigger s1 and s2 to each print an
+ * appropriate message.
+ * <LI> s2's message should trigger it's observer s5 to print
+ * a message.
+ * <LI> The coordinate change should trigger s3 and s4.
+ * <LI> s4's message should trigger it's observer s5 again.
+ */
+
+ public static void main(String argv[]) {
+
+ Point p = new Point(5, 5, Color.blue);
+
+ System.out.println("Creating Screen s1,s2,s3,s4,s5 and Point p");
+
+ Screen s1 = new Screen("s1");
+ Screen s2 = new Screen("s2");
+
+ Screen s3 = new Screen("s3");
+ Screen s4 = new Screen("s4");
+
+ Screen s5 = new Screen("s5");
+
+ System.out.println("Creating observing relationships:");
+ System.out.println("- s1 and s2 observe color changes to p");
+ System.out.println("- s3 and s4 observe coordinate changes to p");
+ System.out.println("- s5 observes s2's and s4's display() method");
+
+ p.attach(s1);
+ p.attach(s2);
+
+ p.attach(s3);
+ p.attach(s4);
+
+ s2.attach(s5);
+ s4.attach(s5);
+
+ System.out.println("Changing p's color:");
+
+ p.setColor(Color.red);
+
+ System.out.println("Changing p's x-coordinate:");
+
+ p.setX(4);
+
+ System.out.println("done.");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Point.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Point.java
new file mode 100644
index 000000000..94060fce1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Point.java
@@ -0,0 +1,161 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.awt.Color;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Represents a point with x and y coordinates and a color.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public class Point implements ChangeSubject {
+
+ /**
+ * stores the <i>Observer</i>s for this point (<i>Subject</i>)
+ */
+
+ private HashSet observers;
+
+ /**
+ * the point's x-coordinate
+ */
+
+ private int x;
+
+ /**
+ * the point's y-coordinate
+ */
+
+ private int y;
+
+ /**
+ * the point's current color
+ */
+
+ private Color color;
+
+ /**
+ * Creates a new point object based on x and y coordinates and color.
+ */
+
+ public Point(int x, int y, Color color) {
+ this.x=x;
+ this.y=y;
+ this.color=color;
+ this.observers = new HashSet();
+ }
+
+ /**
+ * Returns the point's current x-coordinate.
+ *
+ * @return the current x-coordinate
+ */
+
+ public int getX() { return x; }
+
+ /**
+ * Returns the point's current y-coordinate.
+ *
+ * @return the current y-coordinate
+ */
+
+ public int getY() { return y; }
+
+ /**
+ * Sets the current x-coordinate.
+ *
+ * @param x the new x-coordinate
+ */
+
+ public void setX(int x) {
+ this.x=x;
+ notifyObservers();
+ }
+
+ /**
+ * Sets the current y-coordinate.
+ *
+ * @param y the new y-coordinate
+ */
+
+ public void setY(int y) {
+ this.y=y;
+ notifyObservers();
+ }
+
+ /**
+ * Returns the point's current color.
+ *
+ * @return the current color
+ */
+
+ public Color getColor() { return color; }
+
+ /**
+ * Sets the current color.
+ *
+ * @param color the new color
+ */
+
+ public void setColor(Color color) {
+ this.color=color;
+ notifyObservers();
+ }
+
+
+ /**
+ * Attaches an <i>Observer</i> to this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to attach
+ */
+
+ public void attach(ChangeObserver o) {
+ this.observers.add(o);
+ }
+
+ /**
+ * Detaches an <i>Observer</i> from this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to detach
+ */
+
+ public void detach(ChangeObserver o) {
+ this.observers.remove(o);
+ }
+
+ /**
+ * Notifies all <i>Observer</i>s.
+ */
+
+ public void notifyObservers() {
+ for (Iterator e = observers.iterator() ; e.hasNext() ;) {
+ ((ChangeObserver)e.next()).update(this);
+ }
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Screen.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Screen.java
new file mode 100644
index 000000000..9259d01a7
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/observer/java/Screen.java
@@ -0,0 +1,123 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.observer.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Provides a means to output messages. Objects of this class act as
+ * output devices.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public class Screen implements ChangeSubject, ChangeObserver {
+
+ /**
+ * stores the <i>Observer</i>s for this screen (<i>Subject</i>)
+ */
+
+ private HashSet observers;
+
+
+ /**
+ * the individual name of this screen object
+ */
+
+ private String name;
+
+ /**
+ * creates a new <code>Screen</code> object with the provided name.
+ *
+ * @param name the name for the new <code>Screen</code> object
+ */
+
+ public Screen(String s) {
+ this.name = s;
+ observers = new HashSet();
+ }
+
+
+ /**
+ * Prints the name of the <code>Screen</code> object and the argument
+ * string to stdout.
+ *
+ * @param s the string to print
+ */
+
+ public void display (String s) {
+ System.out.println(name + ": " + s);
+ notifyObservers();
+ }
+
+ /**
+ * Attaches an <i>Observer</i> to this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to attach
+ */
+
+ public void attach(ChangeObserver o) {
+ this.observers.add(o);
+ }
+
+ /**
+ * Detaches an <i>Observer</i> from this <i>Subject</i>.
+ *
+ * @param o the <i>Observer</i> to detach
+ */
+
+ public void detach(ChangeObserver o) {
+ this.observers.remove(o);
+ }
+
+ /**
+ * Notifies all <i>Observer</i>s.
+ */
+
+ public void notifyObservers() {
+ for (Iterator e = observers.iterator() ; e.hasNext() ;) {
+ ((ChangeObserver)e.next()).update(this);
+ }
+ }
+
+ /**
+ * Updates an <i>Observer</i>. Uses the <i>push</i> strategy (i.e. the
+ * subject triggering the update passes itself as an argument).
+ *
+ * This particular method prints a message showing what object caused
+ * the update
+ *
+ * @param s the <i>Subject</i> triggering the update
+ */
+
+ public void update(ChangeSubject s) {
+ String subjectTypeName = s.getClass().getName();
+ subjectTypeName = subjectTypeName.substring(
+ subjectTypeName.lastIndexOf(".")+1, subjectTypeName.length());
+ display("update received from a "+subjectTypeName+" object");
+ }
+
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/Main.java
new file mode 100644
index 000000000..81c4584a9
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/Main.java
@@ -0,0 +1,105 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Prototype design pattern example.<p>
+ *
+ * Intent: <i>Specify the kinds of objects to create using a prototypical
+ * instance, and create new objects by copying this prototype.</i><p>
+ *
+ * Participatng objects are <code>StringPrototypeA</code> and
+ * <code>StringPrototypeB</code> as <i>Prototype</i>s.<p>
+ *
+ * In this example, both StringPrototypeA and StringPrototypeB implement cloneable
+ * classes emulating limited String behavior. This driver creates an
+ * object of each class and clones it. Both originals and clones are
+ * manipulated to show that they are different objects.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Java's <code>Cloneable</code> interface is used internally. In this
+ * version, a standard implementation for <code>createClone()</code> is
+ * provided by the abstract pattern aspect. Each concrete pattern instance
+ * aspect can define special behavior by overwriting the appropriate
+ * methods. Consequently, the participants are freed of the pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeA
+ * @see StringPrototypeB
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Prototype design pattern example.<p>
+ *
+ * In this example, both StringPrototypeA and StringPrototypeB implement cloneable
+ * classes emulating limited String behavior. This driver creates an
+ * object of each class and clones it. Both originals and clones are
+ * manipulated to show that they are different objects.
+ *
+ * @param args the command line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Testing the Prototype design pattern implementation...");
+
+ StringPrototypeA originalA;
+ StringPrototypeB originalB;
+ StringPrototypeA copyA1, copyA2;
+ StringPrototypeB copyB1;
+
+ originalA = new StringPrototypeA(" This is Prototype 1");
+ originalB = new StringPrototypeB(" This is Prototype 2");
+
+ System.out.println("These are the two prototypes:");
+ System.out.println(originalA);
+ System.out.println(originalB);
+
+ copyA1 = (StringPrototypeA) StringPrototypes.aspectOf().cloneObject(originalA);
+ copyB1 = (StringPrototypeB) StringPrototypes.aspectOf().cloneObject(originalB);
+
+ System.out.println("These are copies of the prototypes:");
+ System.out.println(copyA1);
+ System.out.println(copyB1);
+
+ System.out.println("Now prototype 1 is changed. Here are prototype 1 and its former copy:");
+ originalA.setText(" This is Prototype 1 (changed)");
+ System.out.println(originalA);
+ System.out.println(copyA1);
+
+ System.out.println("This is a clone of the changed prototype 1 and a changed copy of prototype 2:");
+ copyA2 = (StringPrototypeA) StringPrototypes.aspectOf().cloneObject(originalA);
+ copyB1.setText(" This is a changed copy of prototype 2");
+ System.out.println(copyA2);
+ System.out.println(copyB1);
+
+
+ System.out.println("... done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeA.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeA.java
new file mode 100644
index 000000000..a0ac669f1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeA.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Prototype</i> that imitates a simple String
+ * class. The clone method is now implemented by the aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeB
+ */
+
+public class StringPrototypeA implements Cloneable {
+
+ /**
+ * the string that this object encapsulates
+ */
+
+ protected String text;
+
+ /**
+ * Creates a new StringPrototypeA object with the given string
+ *
+ * @param init the initial String for this object
+ */
+
+ public StringPrototypeA(String init) {
+ text = init;
+ }
+
+ /**
+ * Changes the string this object encapsulates
+ *
+ * @param newText the new text for this object.
+ */
+
+ public void setText(String newText) {
+ text = newText;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return a string representation of this object.
+ */
+
+ public String toString() {
+ return "MyString: "+ text;
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeB.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeB.java
new file mode 100644
index 000000000..600d0b901
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypeB.java
@@ -0,0 +1,73 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Prototype</i> that imitates a simple String
+ * class. The clone method is now implemented by the aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeA
+ */
+
+public class StringPrototypeB implements Cloneable {
+
+ /**
+ * the string that this object encapsulates
+ */
+
+ protected String text;
+
+ /**
+ * Creates a new StringPrototypeA object with the given string
+ *
+ * @param init the initial String for this object
+ */
+
+ public StringPrototypeB(String init) {
+ text = init;
+ }
+
+ /**
+ * Changes the string this object encapsulates
+ *
+ * @param newText the new text for this object.
+ */
+
+ public void setText(String newText) {
+ text = newText;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return a string representation of this object.
+ */
+
+ public String toString() {
+ return "AnotherString: " + text;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypes.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypes.java
new file mode 100644
index 000000000..00bbe30f4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/StringPrototypes.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.PrototypeProtocol;
+
+/**
+ * Concretizes the abstract Prototype design pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public aspect StringPrototypes extends PrototypeProtocol {
+
+ /**
+ * Assigns the <i>Prototype</i> role to </code>StringPrototypeA</code>
+ */
+
+ declare parents: StringPrototypeA implements Prototype;
+
+ /**
+ * Assigns the <code>Prototype</code> role to </code>StringPrototypeB</code>
+ */
+
+ declare parents: StringPrototypeB implements Prototype;
+
+ /**
+ * Provides an alternative method for cases when the default
+ * <code>clone()</code> method fails: Clones objects "by hand".
+ *
+ * @param object the prototype object to clone
+ * @return a copy of the object
+ */
+
+ protected Object createCloneFor(Prototype object) {
+ if (object instanceof StringPrototypeB) {
+ return new StringPrototypeB(((StringPrototypeB)object).toString());
+ } else {
+ return null;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/tut-source-compile-error.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/tut-source-compile-error.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/aspectj/tut-source-compile-error.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/Main.java
new file mode 100644
index 000000000..3552ac567
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/Main.java
@@ -0,0 +1,108 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Prototype design pattern example.<p>
+ *
+ * Intent: <i>Specify the kinds of objects to create using a prototypical
+ * instance, and create new objects by copying this prototype.</i><p>
+ *
+ * Participating objects are <code>StringPrototypeA</code> and
+ * <code>StringPrototypeB</code> as <i>Prototype</i>s.<p>
+ *
+ * In this example, both StringPrototypeA and StringPrototypeB
+ * implement cloneable classes emulating limited String behavior.
+ * This driver creates an object of each class and clones it.
+ * Both originals and clones are manipulated to show that they are
+ * different objects.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Java's <code>Cloneable</code> interface is used.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeA
+ * @see StringPrototypeB
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Prototype design pattern example.<p>
+ *
+ * In this example, both StringPrototypeA and StringPrototypeB implement cloneable
+ * classes emulating limited String behavior. This driver creates an
+ * object of each class and clones it. Both originals and clones are
+ * manipulated to show that they are different objects.
+ *
+ * @param args the command line parameters, unused.
+ */
+
+ public static void main(String[] args) {
+
+ try {
+
+ System.out.println("Testing the Prototype design pattern implementation...");
+
+ StringPrototypeA originalA;
+ StringPrototypeB originalB;
+ StringPrototypeA copyA1, copyA2;
+ StringPrototypeB copyB1;
+
+ originalA = new StringPrototypeA(" This is Prototype 1");
+ originalB = new StringPrototypeB(" This is Prototype 2");
+
+ System.out.println("These are the two prototypes:");
+ System.out.println(originalA);
+ System.out.println(originalB);
+
+ copyA1 = (StringPrototypeA) originalA.clone();
+ copyB1 = (StringPrototypeB) originalB.clone();
+
+ System.out.println("These are copies of the prototypes:");
+ System.out.println(copyA1);
+ System.out.println(copyB1);
+
+ System.out.println("Now prototype 1 is changed. Here are prototype 1 and its former copy:");
+ originalA.setText(" This is Prototype 1 (changed)");
+ System.out.println(originalA);
+ System.out.println(copyA1);
+
+ System.out.println("This is a clone of the changed prototype 1 and a changed copy of prototype 2:");
+ copyA2 = (StringPrototypeA) originalA.clone();
+ copyB1.setText(" This is a changed copy of prototype 2");
+ System.out.println(copyA2);
+ System.out.println(copyB1);
+
+
+ System.out.println("... done.");
+
+ } catch (CloneNotSupportedException ex) {
+ System.err.println("Can't clone prototype objects"+ex);
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeA.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeA.java
new file mode 100644
index 000000000..6019d416d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeA.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Prototype</i> that imitates a simple String
+ * class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeB
+ */
+
+public class StringPrototypeA implements Cloneable {
+
+ /**
+ * the string that this object encapsulates
+ */
+
+ protected String text;
+
+ /**
+ * Creates a new StringPrototypeA object with the given string
+ *
+ * @param init the initial String for this object
+ */
+
+ public StringPrototypeA(String init) {
+ text = init;
+ }
+
+ /**
+ * Changes the string this object encapsulates
+ *
+ * @param newText the new text for this object.
+ */
+
+ public void setText(String newText) {
+ text = newText;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @returns a string representation of this object.
+ */
+
+ public String toString() {
+ return "StringPrototypeA: "+ text;
+ }
+
+ /**
+ * Returns a copy of this object. Does only work this way if the
+ * superclass implements <code>clone()</code>.
+ */
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeB.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeB.java
new file mode 100644
index 000000000..2c6f23954
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/prototype/java/StringPrototypeB.java
@@ -0,0 +1,82 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.prototype.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Prototype</i> that imitates a simple String
+ * class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ *
+ * @see StringPrototypeA
+ */
+
+public class StringPrototypeB implements Cloneable {
+
+ /**
+ * the string that this object encapsulates
+ */
+
+ protected String text;
+
+ /**
+ * Creates a new StringPrototypeA object with the given string
+ *
+ * @param init the initial String for this object
+ */
+
+ public StringPrototypeB(String init) {
+ text = init;
+ }
+
+ /**
+ * Changes the string this object encapsulates
+ *
+ * @param newText the new text for this object.
+ */
+
+ public void setText(String newText) {
+ text = newText;
+ }
+
+ /**
+ * Returns a string representation of this object.
+ *
+ * @return a string representation of this object.
+ */
+
+ public String toString() {
+ return "StringPrototypeB: " + text;
+ }
+
+ /**
+ * Returns a copy of this object. Does only work this way if the
+ * superclass implements <code>clone()</code>.
+ */
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/AlternateOutputImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/AlternateOutputImplementation.java
new file mode 100644
index 000000000..89ecd27d8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/AlternateOutputImplementation.java
@@ -0,0 +1,47 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This class will serve as a Delegate for OutputImplementation. Note that no
+ * interfaces need to be implemented. This is not a <i>Subject</i> and does in
+ * fact play no role in the pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class AlternateOutputImplementation {
+
+ /**
+ * Prints the argument string to
+ * <code>System.out</code>
+ *
+ * @param s the string to print
+ */
+
+ public void alternateRequest(String s) {
+ System.out.println("[AlternateSubject.safeRequest()]: "+s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/Main.java
new file mode 100644
index 000000000..3081d8b01
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/Main.java
@@ -0,0 +1,99 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Proxy design pattern example.<p>
+ *
+ * Intent: <i>Provide a surrogate or placeholder for another object to control
+ * access to it.</i><p>
+ *
+ * Participating objects are <code>OutputImplementation</code>s and
+ * <code>AlternateOutputImplementation</code>.
+ *
+ * The former acts as a <i>RealSubject</i>.
+ *
+ * Experimental setup:
+ * <code>Main</code> issues three different kinds of requests to
+ * the <i>RealSubject</i> (<code>OutputImplementation</code>) twice.
+ * <UL>
+ * <LI> SAFE requests are delegated to a different object
+ * (delegation proxy)
+ * <LI> REGULAR request are counted
+ * <LI> UNSAFE requests are blocked entirely.
+ * </UL>
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Each concrete aspect defines exactly what requests it is interested
+ * in. For those requests, it declares how to deal with the request.
+ *
+ * The proxy implementation is localized. Even clients need not set
+ * or remove proxies.
+ *
+ * Please note that the AspectJ version includes an additional proxy
+ * that delegates safe request to a different object. An OO implementation
+ * would be similar to the other OO proxies.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Creates a new Main object and runs the test suite.
+ */
+
+ public Main() {
+
+ /**
+ * The <i>RealSubject</i> that the client sends all requests to
+ */
+
+ OutputImplementation real = new OutputImplementation();
+
+ System.out.println("\n===> Issuing SAFE request...");
+ real.safeRequest ("Safe Reqeust");
+ System.out.println("\n===> Issuing REGULAR request...");
+ real.regularRequest("Normal Request");
+ System.out.println("\n===> Issuing UNSAFE request...");
+ real.unsafeRequest ("Unsafe Request");
+
+ System.out.println("\n===> Issuing SAFE request...");
+ real.safeRequest ("Safe Reqeust");
+ System.out.println("\n===> Issuing REGULAR request...");
+ real.regularRequest("Normal Request");
+ System.out.println("\n===> Issuing UNSAFE request...");
+ real.unsafeRequest ("Unsafe Request");
+ }
+
+ /**
+ * Implements the driver for the proxy design pattern example.
+ */
+
+ public static void main (String[] args) {
+ Main main = new Main();
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/OutputImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/OutputImplementation.java
new file mode 100644
index 000000000..2023025d0
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/OutputImplementation.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Represents a <i>RealSubject</i> according to GoF.
+ * Note that it does not have to implement any interface in the AspectJ
+ * version.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class OutputImplementation {
+
+ /**
+ * A type of <i>request(..)</i>. Prints the argument string to
+ * <code>System.out</code>
+ *
+ * @param s the string to print
+ */
+
+ public void safeRequest(String s) {
+ System.out.println("[OutputImplementation.safeRequest()]: "+s);
+ }
+
+ /**
+ * A type of <i>request(..)</i>.
+ * <code>System.out</code>
+ *
+ * @param s the string to print
+ */
+
+ public void regularRequest(String s) {
+ System.out.println("[OutputImplementation.regularRequest()]: "+s);
+ }
+
+ /**
+ * A type of <i>request(..)</i>.
+ *
+ * @param s the string to print
+ */
+
+ public void unsafeRequest(String s) {
+ System.out.println("[OutputImplementation.unsafeRequest()]: "+s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestBlocking.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestBlocking.java
new file mode 100644
index 000000000..d157d44eb
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestBlocking.java
@@ -0,0 +1,78 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ProxyProtocol;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * Implements a concrete Proxy pattern instance. Here, all unsafe requests
+ * from <code>Main</code> <code>OutputImplementation</code>
+ * are blocked.<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public aspect RequestBlocking extends ProxyProtocol {
+
+ /**
+ * Assigns the <i>Subject</i> role to <code>OutputImplementation</code>.
+ */
+
+ declare parents: OutputImplementation implements Subject;
+
+ /**
+ * Captures all accesses to the <i>Subject</i> that should be protected by
+ * this proxy. Here: All calls to <code>
+ * OutputImplementation.unsafeRequest(..)</code>.
+ */
+
+ protected pointcut requests():
+ call(* OutputImplementation.unsafeRequest(..));
+
+ /**
+ * Checks whether the access needs to be handled by the proxy or not.
+ * Here: All accesses that come from <code>Main</code> objects are
+ * denied.
+ *
+ * @param caller the object responsible for the protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the protected access
+ *
+ * @return true if the access is from a Main object, false otherwise
+ */
+
+ protected boolean isProxyProtected(Object caller,
+ Subject subject,
+ JoinPoint joinPoint) {
+ if (joinPoint.getThis() instanceof Main) {
+ System.out.println("[RequestBlocking] intercepting unsafe " +
+ "requests from Main");
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestCounting.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestCounting.java
new file mode 100644
index 000000000..da91e003a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestCounting.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ProxyProtocol;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * Implements a concrete proxy pattern instance. Here, all method calls from
+ * <code>Main</code> to <code>OutputImplementation.print(String)</code> are blocked.<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public aspect RequestCounting extends ProxyProtocol {
+
+ /**
+ * An internal counter for the number of calls to <code>
+ * print(String)</code>.
+ */
+
+ private int regularRequests = 0;
+
+
+ /**
+ * Assigns the <i>OutputSubject</i> role to <code>OutputImplementation</code>.
+ */
+
+ declare parents: OutputImplementation implements Subject;
+
+ /**
+ * Captures all accesses to the subject that should be protected by
+ * this pattern instance. Here: All calls to <code>
+ * OutputImplementation.print(..)</code>.
+ */
+
+ protected pointcut requests():
+ call(* OutputImplementation.regularRequest(..));
+
+ /**
+ * Checks whether the access should be denied or not. Here: All accesses
+ * that come from <code>Main</code> objects are denied.
+ *
+ * @param caller the object responsible for the protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the protected access
+ *
+ * @return true if the access is from a Main object, false otherwise
+ */
+
+ protected boolean isProxyProtected(Object caller,
+ Subject subject,
+ JoinPoint joinPoint) {
+ if (joinPoint.getThis() instanceof Main) {
+ regularRequests++;
+ System.out.println("[RequestCounter:] That was regular request nr. " +
+ regularRequests);
+ }
+ return false;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestDelegation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestDelegation.java
new file mode 100644
index 000000000..053c5564a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/RequestDelegation.java
@@ -0,0 +1,105 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.ProxyProtocol;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * Implements a concrete proxy pattern instance. Here, all method calls from
+ * <code>Main</code> to <code>OutputImplementation.print(String)</code> are blocked.<p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public aspect RequestDelegation extends ProxyProtocol {
+
+ /**
+ * Assigns the <i>Subject</i> role to <code>OutputImplementation
+ * </code>.
+ */
+
+ declare parents: OutputImplementation implements Subject;
+
+ private AlternateOutputImplementation alternateSubject =
+ new AlternateOutputImplementation();
+
+ /**
+ * Captures all accesses to the subject that should be protected by
+ * this pattern instance. Here: All calls to <code>
+ * OutputImplementation.safeRequest(..)</code>.
+ */
+
+ protected pointcut requests():
+ call(* OutputImplementation.safeRequest(..));
+
+
+ /**
+ * Checks whether the request should be handled by the Proxy or not.
+ * Here: All accesses matched by the <code>protectedAccesses()</code>
+ * joinpoint.
+ *
+ * @param caller the object responsible for the protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the protected access
+ *
+ * @return true if the access is covered by the proxy, false otherwise
+ */
+
+ protected boolean isProxyProtected(Object caller,
+ Subject subject,
+ JoinPoint joinPoint) {
+ System.out.println("[RequestDelegation] delegating a safe request " +
+ "to a different type of object");
+ return true;
+ }
+
+ /**
+ * For delegation: Provides an alternative return value if access
+ * is proxy protected. A default implementation is supplied so that
+ * concrete subaspects are not forced to implement the method.
+ * Here, it also calls an appropriate method on a delegate
+ * (to illustrate how delegation would work).
+ *
+ * @param caller the object responsible for the proxy protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the proxy protected
+ * access
+ *
+ * @return an alternative return value
+ */
+
+ protected Object handleProxyProtection(Object caller,
+ Subject subject,
+ JoinPoint joinPoint) {
+ Object[] args = joinPoint.getArgs();
+ if (args != null) {
+ alternateSubject.alternateRequest((String)args[0]);
+ } else {
+ alternateSubject.alternateRequest("");
+ }
+ return null;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/Main.java
new file mode 100644
index 000000000..e4e91283b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/Main.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the RequestCounter design pattern example.<p>
+ *
+ * Intent: <i>Provide a surrogate or placeholder for another object to control
+ * access to it.</i><p>
+ *
+ * Participating objects are <code>OutputImplementation</code> and
+ * <code>RequestCounter</code> as <i>RealSubject</i> and <i>Proxy</i>,
+ * respectively.
+ *
+ * Both implement the <code>OutputSubject</code> interface, which represents
+ * the <i>Subject</i> interface.
+ *
+ * Experimental setup:
+ * <code>Main</code> issues three different kinds of requests to
+ * the <i>RealSubject</i> (<code>OutputImplementation</code>) twice.
+ * <UL>
+ * <LI> SAFE requests are not affected
+ * <LI> REGULAR request are counted
+ * <LI> UNSAFE requests are blocked entirely.
+ * </UL>
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * <i>Proxy</i>s needs to implement all methods of
+ * <code>OutputSubject</code>, even those it is not interested in.
+ * They need to be aware of their role in the pattern.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the proxy design pattern. <p>
+ */
+
+ public static void main (String[] args) {
+ OutputSubject real = new OutputImplementation();
+ OutputSubject countingProxy = new RequestCounter(real);
+ OutputSubject blockingProxy = new RequestBlocker(countingProxy);
+
+ System.out.println("\n===> Issuing SAFE request...");
+ blockingProxy.safeRequest ("Safe Reqeust");
+ System.out.println("\n===> Issuing REGULAR request...");
+ blockingProxy.regularRequest("Normal Request");
+ System.out.println("\n===> Issuing UNSAFE request...");
+ blockingProxy.unsafeRequest ("Unsafe Request");
+
+ System.out.println("\n===> Issuing SAFE request...");
+ blockingProxy.safeRequest ("Safe Reqeust");
+ System.out.println("\n===> Issuing REGULAR request...");
+ blockingProxy.regularRequest("Normal Request");
+ System.out.println("\n===> Issuing UNSAFE request...");
+ blockingProxy.unsafeRequest ("Unsafe Request");
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputImplementation.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputImplementation.java
new file mode 100644
index 000000000..dab1bedd1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputImplementation.java
@@ -0,0 +1,67 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Acts as <i>RealSubject</i> according to GoF. It implements the
+ * <code>OutputSubject</code> interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class OutputImplementation implements OutputSubject {
+
+ /**
+ * A type of <i>request(..)</i>. Prints the argument string to
+ * <code>System.out</code>
+ *
+ * @param s the string to print
+ */
+
+ public void safeRequest(String s) {
+ System.out.println("[RealSubject.safeRequest()]: "+s);
+ }
+
+ /**
+ * A type of <i>request(..)</i>.
+ * <code>System.out</code>
+ *
+ * @param s the string to print
+ */
+
+ public void regularRequest(String s) {
+ System.out.println("[RealSubject.regularRequest()]: "+s);
+ }
+
+ /**
+ * A type of <i>request(..)</i>.
+ *
+ * @param s the string to print
+ */
+
+ public void unsafeRequest(String s) {
+ System.out.println("[RealSubject.unsafeRequest()]: "+s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputSubject.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputSubject.java
new file mode 100644
index 000000000..a6f9cf362
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/OutputSubject.java
@@ -0,0 +1,60 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the <i>Subject</i> interface that is implemented by both
+ * <code>RequestCounter</code> and <code>OutputImplementation</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface OutputSubject {
+
+ /**
+ * A type of <i>request(..)</i>.
+ *
+ * @param s the string to print
+ */
+
+ public void safeRequest(String s);
+
+ /**
+ * A type of <i>request(..)</i>.
+ *
+ * @param s the string to print
+ */
+
+ public void regularRequest(String s);
+
+ /**
+ * A type of <i>request(..)</i>.
+ *
+ * @param s the string to print
+ */
+
+ public void unsafeRequest(String s);
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestBlocker.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestBlocker.java
new file mode 100644
index 000000000..be562498f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestBlocker.java
@@ -0,0 +1,94 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Acts as <i>Proxy</i> according to GoF. It implements the
+ * <code>OutputSubject</code> interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class RequestBlocker implements OutputSubject {
+
+ /**
+ * a reference to the <i>Subject</i> (used to forward requests to)
+ */
+
+ private OutputSubject realSubject;
+
+ /**
+ * Creates a new <code>RequestBlocker</code> with the given
+ * <i>Subject</i>.
+ *
+ * @param subject The <i>Subject</i> to forward method calls to
+ */
+
+ public RequestBlocker(OutputSubject subject) {
+ this.realSubject = subject;
+ }
+
+ /**
+ * Forwards the request to its subject. We are not interested in
+ * this kind of request, but must implement the method (and the
+ * request forwarding) anyway since the method is part of the
+ * <code>RequestBlocker</code> interface.
+ *
+ * @param s the string to print
+ */
+
+ public void safeRequest(String s) {
+ realSubject.safeRequest(s);
+ System.out.println("[RequestBlocker:] Not interested in safe requests," +
+ " but must implement anyway");
+ }
+
+ /**
+ * Forwards the request to its subject. We are not interested in
+ * this kind of request, but must implement the method (and the
+ * request forwarding) anyway since the method is part of the
+ * <code>RequestBlocker</code> interface.
+ *
+ * @param s the string to print
+ */
+
+ public void regularRequest(String s) {
+ realSubject.regularRequest(s);
+ System.out.println("[RequestBlocker:] Not interested in regular requests," +
+ " but must implement anyway");
+ }
+
+ /**
+ * Blocks unsafe requests.
+ *
+ * @param s the string to print
+ */
+
+ public void unsafeRequest(String s) {
+ realSubject.unsafeRequest(s);
+ System.out.println("[RequestBlocker:] " + s + " blocked.");
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestCounter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestCounter.java
new file mode 100644
index 000000000..ba55bc0ea
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/proxy/java/RequestCounter.java
@@ -0,0 +1,104 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.proxy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Acts as <i>Proxy</i> according to GoF. It implements the
+ * <code>OutputSubject</code> interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class RequestCounter implements OutputSubject {
+
+ /**
+ * a reference to the <i>Subject</i> (used to forward requests to)
+ */
+
+ private OutputSubject realSubject;
+
+ /**
+ * An internal counter for the number of calls to <code>
+ * print(String)</code>.
+ */
+
+ private int regularRequests = 0;
+
+ /**
+ * Creates a new <code>RequestCounter</code> with the given
+ * <i>Subject</i>.
+ *
+ * @param subject The <i>Subject</i> to forward method calls to
+ */
+
+ public RequestCounter(OutputSubject subject) {
+ this.realSubject = subject;
+ }
+
+ /**
+ * Forwards the request to its subject. We are not interested in
+ * this kind of request, but must implement the method (and the
+ * request forwarding) anyway since the method is part of the
+ * <code>RequestBlocker</code> interface.
+ *
+ * @param s the string to print
+ */
+
+ public void safeRequest(String s) {
+ realSubject.safeRequest(s);
+ System.out.println("[RequestCounter:] Not interested in safe " +
+ "requests, but must implement anyway");
+ }
+
+ /**
+ * Forwards the request to its subject and prints
+ * out how many times the <i>request()</i> has been called so far.
+ *
+ * @param s the string to print
+ */
+
+ public void regularRequest(String s) {
+ regularRequests++;
+ realSubject.regularRequest(s);
+ System.out.println("[RequestCounter:] That was regular request nr. " +
+ regularRequests);
+ }
+
+ /**
+ * Forwards the request to its subject. We are not interested in
+ * this kind of request, but must implement the method (and the
+ * request forwarding) anyway since the method is part of the
+ * <code>RequestBlocker</code> interface.
+ *
+ * @param s the string to print
+ */
+
+ public void unsafeRequest(String s) {
+ realSubject.unsafeRequest(s);
+ System.out.println("[RequestCounter:] Not interested in unsafe requests," +
+ " but must implement anyway");
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Main.java
new file mode 100644
index 000000000..18c258e66
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Main.java
@@ -0,0 +1,158 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Singleton design pattern example.<p>
+ *
+ * Intent: <i>Ensure that a class has only one instance and provide a global
+ * point of access to it.</i><p>
+ *
+ * Participating objects are <code>Printer</code> printer1, printer2, printer3 and
+ * <code>PrinterSubclass</code> ps1, ps2, ps3.<p>
+ *
+ * Three different objects of both Printer and PrinterSubclass are
+ * instantiated and compared.
+ *
+ * This Implementation treats the singleton property as a non-inherited
+ * property. This meant that <i>Singleton</i> classes can still be subclassed
+ * and these subclasses can access the <i>Singleton</i> constructor normally.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ *
+ * @see Printer
+ * @see PrinterSubclass
+ */
+
+public class Main {
+
+ /**
+ * the three object references to instances of the <i>Singleton</i> class.
+ */
+
+ private static Printer printer1, printer2, printer3;
+
+ // Experimental setup: Main creates three Printer objects.
+ // The Printer implementation gives each object a unique ID
+ // which is printed when print() is called. If the Singleton
+ // implementation works, all three objects should be the same.
+ //
+ // Implementation: AOP5 - One (concrete) aspect defines the behavior
+ // of the pattern, creating a generic getInstance() method that
+ // is attached to the Singleton interface. Another aspect assigns
+ // the role to a particular class.
+ //
+ // The general description of the pattern is reusable.
+ //
+ // Considers different signatures for the constructor.
+ //
+ // Clients don't have to type-cast, they just use new(..)
+ //
+ // Subclasses are automatically Singletons, too, unless
+ // explicitly declared as non-singletons
+
+
+ /**
+ * Implements the first test case. Creates 3 references to the
+ * <i>Singleton</i> by using the regular constructor. That should
+ * create three identical objects.
+ */
+
+ private static void test1() {
+ System.out.println("\nTest 1: All three printers should have the "
+ + "same ID");
+
+ printer1 = new Printer();
+ printer2 = new Printer();
+ printer3 = new Printer();
+
+ printer1.print();
+ printer2.print();
+ printer3.print();
+ }
+
+
+
+ /**
+ * Implements the second test case. Tests if the 3 objects from test 1 are
+ * in fact identical
+ */
+
+ private static void test2() {
+ System.out.println("\nTest 2: All three objects should be identical");
+
+ System.out.print("\tThey are ");
+ if ((printer1 == printer2) && (printer1 == printer3)) {
+ System.out.println("identical");
+ }
+ else {
+ System.out.println("not identical");
+ }
+ }
+
+
+ /**
+ * Implements the third test case. Creates 3 instances of the <i>Singleton
+ * </i>'s subclass. These objects should be different.
+ */
+
+ private static void test3() {
+ System.out.println("\nTest 3: Ensuring that subclasses can access the"
+ + "constructor");
+ System.out.println(" (All three outputs should be different)");
+
+ printer1 = new PrinterSubclass();
+ printer2 = new PrinterSubclass();
+ printer3 = new PrinterSubclass();
+
+ printer1.print();
+ printer2.print();
+ printer3.print();
+ }
+
+
+ /**
+ * This is the driver for the <code>Singleton</code> case. It performes
+ * three tests:
+ *
+ * <OL>
+ * <LI> Creates 3 references to the <i>Singleton</i> by using the
+ * regular constructor. That should create three identical objects.
+ * <LI> Tests if the above 3 objects are in fact identical
+ * <LI> Creates 3 instances of a <i>Singleton</i>'s subclass. These
+ * objects should be different.
+ * </OL>
+ */
+
+ public static void main (String[] args) {
+ System.out.println("Testing SINGLETON pattern (aspectj) ...");
+ test1();
+ test2();
+ test3();
+ System.out.println("\n... done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Printer.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Printer.java
new file mode 100644
index 000000000..867b34b73
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/Printer.java
@@ -0,0 +1,75 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample class that will be assigned the <i>Singleton</i> role
+ * in this example. The class's functionality
+ * is to store an instance-specific ID and provide a <code>print()</code>
+ * method that shows an object's ID.
+ *
+ * Note that in this implementation the class does not have to know
+ * that it is a <i>Singleton</i> (i.e. has no pattern code in it).
+ *
+ * Note further that instead of assigning the <i>Singleton</i> property
+ * via the <code>declare parents</code> construct in the aspect, it is
+ * possible to just add a <code>implements Singleton</doce> here. However,
+ * that would introduce pattern-related code into this type.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ */
+
+public class Printer {
+
+ /**
+ * counts the instances of this class
+ */
+
+ protected static int objectsSoFar = 0;
+
+ /**
+ * each instance has an ID to distinguish them.
+ */
+
+ protected int id;
+
+ /**
+ * Creates a <code>Printer</code> object. Note that the constructor
+ * is not protected; the protection is realized by the aspect.
+ */
+
+ public Printer() {
+ id = ++ objectsSoFar;
+ }
+
+ /**
+ * Prints the instance's ID to <code>System.out</code>.
+ */
+
+ public void print() {
+ System.out.println("\tMy ID is "+id);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/PrinterSubclass.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/PrinterSubclass.java
new file mode 100644
index 000000000..8ec000bc5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/PrinterSubclass.java
@@ -0,0 +1,46 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample subclass of the <i>Singleton</i> class. This class is
+ * to test whether subclasses can still access the Singleton's constructor.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ *
+ * @see PrinterSingleton
+ */
+
+
+public class PrinterSubclass extends Printer {
+
+ /**
+ * Creates an instance of this class by calling <code>super()</code>.
+ */
+
+ public PrinterSubclass() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/SingletonInstance.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/SingletonInstance.java
new file mode 100644
index 000000000..d87e6373c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/SingletonInstance.java
@@ -0,0 +1,60 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.SingletonProtocol;
+
+/**
+ * Implements a concrete instance of the <i>Singleton</i> pattern. It declares
+ * Printer to be Singleton and defines an exception to the constructor
+ * protection: PrinterSubclass (a subclass of the Singleton) can still
+ * access Printer's constructor.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ *
+ * @see Printer
+ * @see PrinterSubclass
+ */
+
+
+public aspect SingletonInstance extends SingletonProtocol {
+
+ /**
+ * Assigns the Singleton to <code>Printer</code>. This is all that is
+ * necessary to provide <code>Printer</i>'s constructor with the
+ * Singleton protection.
+ */
+
+ declare parents: Printer implements Singleton;
+
+ /**
+ * This declaration allows <code>PrinterSubclass</code> (and all its
+ * subclasses) to access <code>Printer</code>'s constructor within
+ * its constructor (to allow for <code>super(..)</code> calls).
+ */
+
+ protected pointcut protectionExclusions():
+ call((PrinterSubclass+).new(..));
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/Main.java
new file mode 100644
index 000000000..a03707666
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/Main.java
@@ -0,0 +1,157 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Singleton design pattern example.<p>
+ *
+ * Intent: <i>Ensure that a class has only one instance and provide a global
+ * point of access to it.</i><p>
+ *
+ * Participating objects are <code>PrinterSingleton</code> printer1, printer2, printer3 and
+ * <code>PrinterSubclass</code> ps1, ps2, ps3.<p>
+ *
+ * Three different objects of both PrinterSingleton and PrinterSubclass are
+ * instantiated and compared.
+ *
+ * This Implementation treats the singleton property as a non-inherited
+ * property. This meant that <i>Singleton</i> classes can still be subclassed
+ * and these subclasses can access the <i>Singleton</i> constructor normally.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Making the singleton property non-inherited requires to make the
+ * constructor of the <i>Singleton</i> protected (so subtypes can still
+ * invoke <code>super(..)</code> in their constructor).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ *
+ * @see PrinterSingleton
+ * @see PrinterSubclass
+ */
+
+class Main {
+
+ /**
+ * the three object references to instances of the <i>Singleton</i> class.
+ */
+
+ private static PrinterSingleton printer1, printer2, printer3;
+
+ /**
+ * Implements the first test case. Creates 3 references to the
+ * <i>Singleton</i> by (a) using the regular constructor and then by (b)
+ * using a factory method. (a) should fail (but does not, since this
+ * <code>Main</code> class is in the same package and can access the
+ * protected constructor), (b) should create three identical objects.
+ */
+
+ private static void test1() {
+ System.out.println("\nTest 1a: Try to call regular constructor. "
+ + "This should fail.");
+
+ printer1 = new PrinterSingleton();
+ printer2 = new PrinterSingleton();
+ printer3 = new PrinterSingleton();
+
+ printer1.print();
+ printer2.print();
+ printer3.print();
+
+ System.out.println("\t=> OO Problem: Classes in the same package can "
+ + "access the protected constructor.");
+
+ System.out.println("\nTest 1b: Using instance() instead. This hould "
+ + "create three identical objects.");
+
+ printer1 = PrinterSingleton.instance();
+ printer2 = PrinterSingleton.instance();
+ printer3 = PrinterSingleton.instance();
+
+ printer1.print();
+ printer2.print();
+ printer3.print();
+ }
+
+
+ /**
+ * Implements the second test case. Tests if the 3 objects from test 1 are
+ * in fact identical
+ */
+
+ private static void test2() {
+ System.out.println("\nTest 2: All three objects should be identical");
+
+ System.out.print("\tThey are ");
+ if ((printer1 == printer2) && (printer1 == printer3)) {
+ System.out.println("identical");
+ }
+ else {
+ System.out.println("not identical");
+ }
+ }
+
+
+ /**
+ * Implements the third test case. Creates 3 instances of the <i>Singleton
+ * </i>'s subclass. These objects should be different.
+ */
+
+ private static void test3() {
+ System.out.println("\nTest 3: Ensuring that subclasses can access the"
+ + " constructor");
+ System.out.println(" (All three outputs should be different)");
+
+ printer1 = new PrinterSubclass();
+ printer2 = new PrinterSubclass();
+ printer3 = new PrinterSubclass();
+
+ printer1.print();
+ printer2.print();
+ printer3.print();
+ }
+
+ /**
+ * This is the driver for the <code>Singleton</code> case. It performes
+ * three tests:
+ *
+ * <OL>
+ * <LI> Creates 3 references to the <i>Singleton</i> by (a) using the
+ * regular constructor and then by (b) using a factory method.
+ * (a) should fail, (b) should create three identical objects.
+ * <LI> Tests if the above 3 objects are in fact identical
+ * <LI> Creates 3 instances of a <i>Singleton</i>'s subclass. These
+ * objects should be different.
+ * </OL>
+ */
+
+ public static void main (String[] args) {
+ System.out.println("Testing SINGLETON pattern (java) ...");
+ test1();
+ test2();
+ test3();
+ System.out.println("\n... done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSingleton.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSingleton.java
new file mode 100644
index 000000000..ee3d090e3
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSingleton.java
@@ -0,0 +1,100 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample <i>Singleton</i> class. The class's functionality
+ * is to store an instance-specific ID and provide a <code>print()</code>
+ * method that shows an object's ID.
+ *
+ * Note that in this implementation the <i>Singleton</i> class has to know
+ * that it implements the pattern (i.e. has to have appropriate code in it).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ */
+
+
+public class PrinterSingleton {
+
+ /**
+ * counts the instances of this class
+ */
+
+ protected static int objectsSoFar = 0;
+
+ /**
+ * stores this <i>Singleton</i>'s only instance
+ */
+
+ protected static PrinterSingleton onlyInstance = null;
+
+ /**
+ * each instance has an ID to distinguish them.
+ */
+
+ protected int id;
+
+ /**
+ * Creates a new <code>PrinterSingleton</code>. The new instance gets
+ * an ID equal to the total number of instances created of that type.
+ * This constructor is protected to disallow it being called from other
+ * places but the factory method and this type's subtypes.
+ *
+ * Unfortunately, this still allows other types in the same package
+ * to access the constructor.
+ *
+ * Choosing to make it <code>private</code> would prevent that problem,
+ * but would make it impossible to subclass the type properly
+ * (as subtypes then could not use <code>super(..)</code> in their
+ * constructor.
+ */
+
+ protected PrinterSingleton() {
+ id = ++ objectsSoFar;
+ }
+
+ /**
+ * Factory method that provides access to the <i>Singleton</i> instance.
+ * Uses creation-on-demand.
+ *
+ * @return the unique <i>Singleton</i> instance
+ */
+
+ public static PrinterSingleton instance() {
+ if(onlyInstance == null) {
+ onlyInstance = new PrinterSingleton();
+ }
+ return onlyInstance;
+ }
+
+ /**
+ * Prints the instance's ID to <code>System.out</code>.
+ */
+
+ public void print() {
+ System.out.println("\tMy ID is "+id);
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSubclass.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSubclass.java
new file mode 100644
index 000000000..218f99206
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/singleton/java/PrinterSubclass.java
@@ -0,0 +1,43 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.singleton.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a sample subclass of the <i>Singleton</i> class. This class is
+ * to test whether subclasses can still access the Singleton's constructor.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ */
+
+public class PrinterSubclass extends PrinterSingleton {
+
+ /**
+ * Creates an instance of this class by calling <code>super()</code>.
+ */
+
+ public PrinterSubclass() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Main.java
new file mode 100644
index 000000000..4009e3291
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Main.java
@@ -0,0 +1,138 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the State design pattern example.<p>
+ *
+ * Intent: <i>Allow an object to alter its behavior when its internal state
+ * changes. The object will appear to change its class</i><p>
+ *
+ * Participating objects are <code>Queue</code> as <i>Context</i>, and
+ * <code>QueueNormal</code>, <code>QueueEmpty</code>, and <code>QueueFull
+ * </code> as <i>ConcreteState</i>s. The <i>State</i> interface is defined in
+ * <code>QueueState</code>.
+ * <p>
+ *
+ * This example of the State design pattern models a Queue ADT with
+ * a limited capacity that has three different states:
+ * <UL>
+ * <LI>Empty: The queue is empty
+ * <LI>Normal: The queue is neither empty nor full
+ * <LI>Full: The queue is full (# of elements = capacity)
+ * </UL>
+ * The queue stores Objects. The following operations are defined on Queue:
+ * <UL>
+ * <LI><code>insert(Object)</code> Inserts a new Object into the queue
+ * <LI><code>getFirst():Object</code> Returns the first element in the queue
+ * <LI><code>removeFirst()</code> Removes the first elelemts from the queue
+ * </UL>
+ * These are the pattern roles:
+ * <UL>
+ * <LI>Queue: Context
+ * <LI>QueueState: State interface
+ * <LI>QueueEmpty: ConcreteState1
+ * <LI>QueueNormal: ConcreteState2
+ * <LI>QueueFull: ConcreteState3
+ * </UL>
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * This implementation uses a concrete aspect to take care of all the state
+ * transitions in the system. States are no longer tangled with each other
+ * as they do not have to know about their successor states. All state
+ * transitions are localized in the aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see Queue
+ * @see QueueState
+ * @see QueueEmpty
+ * @see QueueNormal
+ * @see QueueFull
+ * @see QueueStateAspect
+ */
+
+public class Main {
+
+ /**
+ * Implements insertion into a queue. Prints out status messages.
+ *
+ * @param queue the queue to insert into
+ * @param s the string to insert into the queue
+ */
+
+ public static void testInsert(Queue queue, String s) {
+ System.out.print(" Trying to insert ["+s+"] into the queue ... ");
+ boolean status = queue.insert(s);
+ if (status == true) {
+ System.out.println("successful");
+ } else {
+ System.out.println("NOT successful, queue probably full");
+ }
+ }
+
+ /**
+ * Implements deletion from a queue. Prints out status messages.
+ *
+ * @param queue the queue to delete items from
+ */
+
+ public static void testRemove(Queue queue) {
+ System.out.print(" Trying to remove 1st element of the queue ... ");
+ String item = (String) queue.getFirst();
+ boolean status = queue.removeFirst();
+ if (status == true) {
+ System.out.println("successful: "+item);
+ } else {
+ System.out.println("NOT successful: "+item);
+ }
+ }
+
+ /**
+ * Implements the driver for the State design pattern example.<p>
+ *
+ * @param args the command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Testing Pattern: State - STARTING\n");
+
+ Queue queue = new Queue();
+ testInsert(queue, "This ");
+ testInsert(queue, "is ");
+ testInsert(queue, "a ");
+ testInsert(queue, "test");
+ System.out.println();
+ testRemove(queue);
+ testRemove(queue);
+ testRemove(queue);
+ testRemove(queue);
+
+ System.out.println("\nTesting Pattern: State - FINISHED");
+
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Queue.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Queue.java
new file mode 100644
index 000000000..c5709666d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/Queue.java
@@ -0,0 +1,85 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>context</i> of the queue example. This is effectively
+ * a queue with limited capacity. Requests are forwarded to the current state
+ * object.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Queue {
+
+ /**
+ * the current state of this context
+ */
+
+ protected QueueState state = new QueueEmpty();
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(Object arg) {
+ return state.insert(arg);
+ }
+
+ /**
+ * Returns the first item in the queue
+ *
+ * @return the first item in the queue
+ */
+
+ public Object getFirst() {
+ return state.getFirst();
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst() {
+ return state.removeFirst();
+ }
+
+ /**
+ * Sets the state of the context to the arguments state.
+ *
+ * @param state the new state for the context object.
+ */
+
+ public void setState(QueueState state) {
+ this.state = state;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueEmpty.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueEmpty.java
new file mode 100644
index 000000000..579bea67e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueEmpty.java
@@ -0,0 +1,76 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "empty" for the queue example.
+ * Removing items is impossible if the queue is empty.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueNormal
+ * @see QueueFull
+ */
+
+public class QueueEmpty implements QueueState {
+
+ /**
+ * Tries to insert an object into the queue. Returns true since it is
+ * always possible to insert items into an empty queue. The appropriate
+ * state transitions are implemented by the aspect.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return true.
+ */
+
+ public boolean insert(Object arg) {
+ return true;
+ }
+
+ /**
+ * Returns the first item in the queue. Returns null since the queue is
+ * empty.
+ *
+ * @return null.
+ */
+
+ public Object getFirst() {
+ return null;
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns false (queue is
+ * empty).
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return false.
+ */
+
+ public boolean removeFirst(){
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueFull.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueFull.java
new file mode 100644
index 000000000..bf9b4e8b3
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueFull.java
@@ -0,0 +1,85 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "full" for the queue example.
+ * Inserting items is impossible if the queue is full.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueEmpty
+ * @see QueueNormal
+ */
+
+public class QueueFull implements QueueState {
+
+ /**
+ * stores the items in the queue
+ */
+
+ protected Object[] items;
+
+ /**
+ * stores the index of the first item in the queue.
+ */
+
+ protected int first;
+
+ /**
+ * Tries to insert an object into the queue. Returns false since the
+ * queue is full.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return false.
+ */
+
+ public boolean insert(Object arg) {
+ return false;
+ }
+
+ /**
+ * Returns the first item in the queue.
+ *
+ * @return the first item in the queue.
+ */
+
+ public Object getFirst() {
+ return items[first];
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese. The state transition to "normal" is implemented by
+ * the aspect.
+ *
+ * @return true since it is always possible to delete an item from a
+ * full queue
+ */
+
+ public boolean removeFirst(){
+ return true;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueNormal.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueNormal.java
new file mode 100644
index 000000000..f719d8f6a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueNormal.java
@@ -0,0 +1,94 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "normal" for the queue example.
+ * Inserting and deleting items is possible in this state.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueEmpty
+ * @see QueueFull
+ */
+
+public class QueueNormal implements QueueState {
+
+ /**
+ * stores the items in the queue
+ */
+
+ protected Object[] items = new Object[3];
+
+ /**
+ * stores the index of the first item in the queue
+ */
+
+ protected int first = 0;
+
+ /**
+ * stores the index of the last item in the queue
+ */
+
+ protected int last = 0;
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese. Potential state changes to "full" are facilitated
+ * by the aspect.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(Object arg) { // Inserts a new Object into the queue
+ items[(last)%items.length] = arg;
+ last = (last+1) % items.length;
+ return true;
+ }
+
+ /**
+ * Returns the first item in the queue.
+ *
+ * @returns null.
+ */
+
+ public Object getFirst() { // Returns the first element in the queue
+ return items[first];
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese. Potential state changes to "empty" are facilitated
+ * by the aspect.
+ *
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst(){ // Removes the first element from the queue
+ first = (first + 1) % items.length;
+ return true;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueState.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueState.java
new file mode 100644
index 000000000..32de7a10c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueState.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>State</i>s within this queue example. The
+ * operations provided are <code>insert(..)</code>, <code>getFirst(..)</code>,
+ * and <code>removeFirst(..)</code>. This verison
+ * does not require passing the context as an argument to these functions.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface QueueState {
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(Object arg);
+
+ /**
+ * Returns the first item in the queue
+ *
+ * @return the first item in the queue
+ */
+
+ public Object getFirst();
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst();
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueStateAspect.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueStateAspect.java
new file mode 100644
index 000000000..bfdcae8e4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/QueueStateAspect.java
@@ -0,0 +1,114 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the state transitions for this state design pattern example.
+ * State transitions are realizied as <code>after</code> advice. The
+ * joinpoints are the calls from the context to its state object.<p>
+ *
+ * Exisiting states are reused without a employing a flyweight mechanism or
+ * (inflexibly) modularizing the transitions in the context.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ */
+
+
+public aspect QueueStateAspect {
+
+ /**
+ * the queue's "empty" state
+ */
+
+ protected QueueEmpty empty = new QueueEmpty();
+
+ /**
+ * the queue's "normal" state
+ */
+
+ protected QueueNormal normal = new QueueNormal();
+
+ /**
+ * the queue's "full" state
+ */
+
+ protected QueueFull full = new QueueFull();
+
+
+ /**
+ * Sets the initial state of the queue to empty.
+ *
+ * @param queue the queue context that is initialized.
+ */
+
+
+ after(Queue queue): initialization(new()) && target(queue) {
+ queue.setState(empty);
+ }
+
+ /**
+ * Updates the queue context's state after each call from it to the
+ * <code>insert(Object)</code> method if its current state.
+ *
+ * @param queue the queue context that makes the call.
+ * @param qs the current QueueState that receives the call
+ * @param arg the object to be inserted.
+ */
+
+ after(Queue queue, QueueState qs, Object arg): call(boolean QueueState+.insert(Object)) && target(qs) && args(arg) && this(queue) {
+ if (qs == empty) {
+ normal.insert(arg);
+ queue.setState(normal);
+ } else if (qs == normal) {
+ if (normal.first == normal.last) {
+ full.items = normal.items;
+ full.first = normal.first;
+ queue.setState(full);
+ }
+ }
+ }
+
+ /**
+ * Updates the queue context's state after each call from it to the
+ * <code>removeFirst()</code> method if its current state.
+ *
+ * @param queue the queue context that makes the call.
+ * @param qs the current QueueState that receives the call
+ */
+
+ after(Queue queue, QueueState qs): call(boolean QueueState+.removeFirst()) && target(qs) && this(queue) {
+ if (qs == full) {
+ normal.items = full.items;
+ normal.last = full.first;
+ normal.first = (full.first +1) % normal.items.length;
+ queue.setState(normal);
+ } else if (qs == normal) {
+ if (normal.first == normal.last) {
+ queue.setState(empty);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Main.java
new file mode 100644
index 000000000..423feb302
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Main.java
@@ -0,0 +1,147 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the State design pattern example.<p>
+ *
+ * Intent: <i>Allow an object to alter its behavior when its internal state
+ * changes. The object will appear to change its class</i><p>
+ *
+ * Participating objects are <code>Queue</code> as <i>Context</i>, and
+ * <code>QueueNormal</code>, <code>QueueEmpty</code>, and <code>QueueFull
+ * </code> as <i>ConcreteState</i>s. The <i>State</i> interface is defined in
+ * <code>QueueState</code>. This version implements an update-on-demand
+ * logic (see GoF, implementation 1, page 308). The logic requires passing
+ * the context to calls to methods defined on the state interface, and an
+ * interface for context objects. The interface is defined in
+ * <code>QueueContext</code>.
+ * <p>
+ *
+ * This example of the State design pattern models a Queue ADT with
+ * a limited capacity that has three different states:
+ * <UL>
+ * <LI>Empty: The queue is empty
+ * <LI>Normal: The queue is neither empty nor full
+ * <LI>Full: The queue is full (# of elements = capacity)
+ * </UL>
+ * The queue stores Objects. The following operations are defined on Queue:
+ * <UL>
+ * <LI><code>insert(Object)</code> Inserts a new Object into the queue
+ * <LI><code>getFirst():Object</code> Returns the first element in the queue
+ * <LI><code>removeFirst()</code> Removes the first elelemts from the queue
+ * </UL>
+ * These are the pattern roles:
+ * <UL>
+ * <LI>Queue: Context
+ * <LI>QueueState: State interface
+ * <LI>QueueEmpty: ConcreteState1
+ * <LI>QueueNormal: ConcreteState2
+ * <LI>QueueFull: ConcreteState3
+ * </UL>
+ * This implementation passes the context as an argument to its method
+ * calls to state objects, thus allowing for update on demand and removing
+ * the constraint that Queue has to ask the states for the successor state
+ * after each call.
+ *
+ * According to GoF, this implementation is generally more flexible than
+ * having the state transitions fixed in the context object. Note however
+ * that this approach results in a tight coupling of <i>ConcreteState</i>s
+ * and <i>Context</i> objects.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueContext
+ * @see Queue
+ * @see QueueState
+ * @see QueueEmpty
+ * @see QueueNormal
+ * @see QueueFull
+ */
+
+
+public class Main {
+
+ /**
+ * Implements insertion into a queue. Prints out status messages.
+ *
+ * @param queue the queue to insert into
+ * @param s the string to insert into the queue
+ */
+
+ private static void testInsert(Queue queue, String s) {
+ System.out.print(" Trying to insert ["+s+"] into the queue ... ");
+ boolean status = queue.insert(s);
+ if (status == true) {
+ System.out.println("successful");
+ } else {
+ System.out.println("NOT successful, queue probably full");
+ }
+ }
+
+ /**
+ * Implements deletion from a queue. Prints out status messages.
+ *
+ * @param queue the queue to delete items from
+ */
+
+ private static void testRemove(Queue queue) {
+ System.out.print(" Trying to remove 1st element of the queue ... ");
+ String item = (String) queue.getFirst();
+ boolean status = queue.removeFirst();
+ if (status == true) {
+ System.out.println("successful: "+item);
+ } else {
+ System.out.println("NOT successful: "+item);
+ }
+ }
+
+ /**
+ * Implements the driver for the State design pattern example.<p>
+ *
+ * @param args the command line paramters, unused
+ */
+
+ public static void main(String[] args) {
+
+ System.out.println("Testing Pattern: State - STARTING\n");
+
+ Queue queue = new Queue();
+ testInsert(queue, "This ");
+ testInsert(queue, "is ");
+ testInsert(queue, "a ");
+ testInsert(queue, "test");
+ System.out.println();
+ testRemove(queue);
+ testRemove(queue);
+ testRemove(queue);
+ testRemove(queue);
+
+ System.out.println("\nTesting Pattern: State - FINISHED");
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Queue.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Queue.java
new file mode 100644
index 000000000..141a76560
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/Queue.java
@@ -0,0 +1,85 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>context</i> of the queue example. This is effectively
+ * a queue with limited capacity. Requests are forwarded to the current state
+ * object.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Queue implements QueueContext {
+
+ /**
+ * the current <i>State</i> of this <i>Context</i>
+ */
+
+ protected QueueState state = new QueueEmpty();
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(Object arg) {
+ return state.insert(this, arg);
+ }
+
+ /**
+ * Returns the first item in the queue
+ *
+ * @return the first item in the queue
+ */
+
+ public Object getFirst() {
+ return state.getFirst(this);
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwise.
+ *
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst() { // Removes the first element from the queue
+ return state.removeFirst(this);
+ }
+
+ /**
+ * Sets the state of the context to the arguments state.
+ *
+ * @param state the new state for the context object.
+ */
+
+ public void setState(QueueState state) {
+ this.state = state;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueContext.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueContext.java
new file mode 100644
index 000000000..09ce140cb
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueContext.java
@@ -0,0 +1,43 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>Context</i>s within this queue example. The
+ * operation provided is <code>setState(QueueState)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface QueueContext {
+
+ /**
+ * Sets the state of the context to the arguments state.
+ *
+ * @param state the new state for the context object.
+ */
+
+ public void setState(QueueState state);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueEmpty.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueEmpty.java
new file mode 100644
index 000000000..a914dffd5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueEmpty.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "empty" for the queue example.
+ * Removing items is impossible if the queue is empty. Inserting items will
+ * trigger a state change to "normal".
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueNormal
+ * @see QueueFull
+ */
+
+public class QueueEmpty implements QueueState {
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese. The state of the context
+ * is changed to "normal" (queue is no longer empty).
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(QueueContext context, Object arg) {
+ QueueNormal nextState = new QueueNormal();
+ context.setState(nextState);
+ return nextState.insert(context, arg);
+ }
+
+ /**
+ * Returns the first item in the queue. Returns null since the queue is
+ * empty.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return null.
+ */
+
+ public Object getFirst(QueueContext context) {
+ return null;
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns false (queue is
+ * empty).
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return false.
+ */
+
+ public boolean removeFirst(QueueContext context){
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueFull.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueFull.java
new file mode 100644
index 000000000..1e5f677d4
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueFull.java
@@ -0,0 +1,105 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "full" for the queue example.
+ * Inserting items is impossible if the queue is full. Removing items will
+ * trigger a state change to "normal".
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueEmpty
+ * @see QueueNormal
+ */
+
+public class QueueFull implements QueueState {
+
+ /**
+ * stores the items in the queue
+ */
+
+ protected Object[] items;
+
+ /**
+ * stores the index of the first item in the queue.
+ */
+
+ protected int first;
+
+ /**
+ * Creates a new QueueFull state object with the given set of elements
+ * and the given index.
+ *
+ * @param items the content of the full queue
+ * @param first the index of the first item in the queue
+ */
+
+ public QueueFull(Object[] items, int first) {
+ this.items = items;
+ this.first = first;
+ }
+
+ /**
+ * Tries to insert an object into the queue. Returns false since the
+ * queue is full.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @param arg the object to be inserted into the queue
+ * @return false.
+ */
+
+ public boolean insert(QueueContext context, Object arg) {
+ return false;
+ }
+
+ /**
+ * Returns the first item in the queue.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return the first item in the queue.
+ */
+
+ public Object getFirst(QueueContext context) {
+ return items[first];
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese. The state of the context is changed to "normal".
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst(QueueContext context){
+ QueueState nextState = new QueueNormal(items, first, first);
+ context.setState(nextState);
+ return nextState.removeFirst(context);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueNormal.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueNormal.java
new file mode 100644
index 000000000..cb006cf40
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueNormal.java
@@ -0,0 +1,129 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the <i>ConcreteState</i> "normal" for the queue example.
+ * Inserting and deleting items is possible in this state.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see QueueEmpty
+ * @see QueueFull
+ */
+
+public class QueueNormal implements QueueState {
+
+ /**
+ * stores the items in the queue
+ */
+
+ protected Object[] items = new Object[3];
+
+ /**
+ * stores the index of the first item in the queue
+ */
+
+ protected int first = 0;
+
+ /**
+ * stores the index of the last item in the queue
+ */
+
+ protected int last = 0;
+
+ /**
+ * Creates a new QueueNormal state object with the given set of elements
+ * and the given indices for first and last object.
+ *
+ * @param items the content of the full queue
+ * @param first the index of the first item in the queue
+ * @param last the index of the last item in the queue
+ */
+
+ public QueueNormal(Object[] items, int first, int last) {
+ this.items = items;
+ this.first = first;
+ this.last = last;
+ }
+
+ /**
+ * Alternate constructor that uses preset values for object variables.
+ */
+
+ public QueueNormal() {
+ }
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese. If the queue is full
+ * after the insertion, the state of the context is changed to "full".
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(QueueContext context, Object arg) {
+ items[(last)%items.length] = arg;
+ last = (last+1) % items.length;
+ if (first == last) {
+ context.setState(new QueueFull(items, first));
+ }
+ return true;
+ }
+
+ /**
+ * Returns the first item in the queue.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return the first item in the queue.
+ */
+
+ public Object getFirst(QueueContext context) {
+ return items[first];
+ }
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese. If the removed item was
+ * the last one in the queue, the state of the context is changed to
+ * "empty".
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst(QueueContext context){
+ first = (first + 1) % items.length;
+ if (first == last) {
+ context.setState(new QueueEmpty());
+ }
+ return true;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueState.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueState.java
new file mode 100644
index 000000000..7be872fc1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/state/java/QueueState.java
@@ -0,0 +1,70 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.state.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>State</i>s within this queue example. The
+ * operations provided are <code>insert(..)</code>, <code>getFirst(..)</code>,
+ * and <code>removeFirst(..)</code>.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface QueueState {
+
+ /**
+ * Tries to insert an object into the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @param arg the object to be inserted into the queue
+ * @return true if insertion was successful, false otherwise.
+ */
+
+ public boolean insert(QueueContext context, Object arg);
+
+ /**
+ * Returns the first item in the queue
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return the first item in the queue
+ */
+
+ public Object getFirst(QueueContext context);
+
+ /**
+ * Tries to remove an object from the queue. Returns true if successful,
+ * false otherwiese.
+ *
+ * @param context the <i>Context</i> for this design pattern (for update
+ * on demand)
+ * @return true if deletion was successful, false otherwise.
+ */
+
+ public boolean removeFirst(QueueContext context);
+
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/BubbleSort.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/BubbleSort.java
new file mode 100644
index 000000000..be404119f
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/BubbleSort.java
@@ -0,0 +1,67 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the bubblesort sorting strategy for int arrays.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class BubbleSort {
+
+ /**
+ * Helper method that exchanges two values in an int array
+ *
+ * @param numbers the int array
+ * @param pos1 the position of the first element
+ * @param pos2 the position of the second element
+ */
+
+ private void exchange(int[] numbers, int pos1, int pos2) {
+ int tmp = numbers[pos1];
+ numbers[pos1] = numbers[pos2];
+ numbers[pos2] = tmp;
+ }
+
+ /**
+ * Sorts an int array using basic bubblesort
+ *
+ * @param numbers the int array to sort
+ */
+
+ public void sort(int[] numbers) {
+ System.out.print("Sorting by BubbleSort...");
+ for (int end = numbers.length; end > 1; end --) {
+ for (int current = 0; current < end - 1; current ++) {
+ if (numbers[current] > numbers[current+1]) {
+ exchange(numbers, current, current+1);
+ }
+ }
+ }
+ System.out.println("done.");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/LinearSort.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/LinearSort.java
new file mode 100644
index 000000000..fa7d5f4d6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/LinearSort.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the linear sort sorting strategy for int arrays.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class LinearSort {
+
+ /**
+ * Helper method that exchanges two values in an int array
+ *
+ * @param numbers the int array
+ * @param pos1 the position of the first element
+ * @param pos2 the position of the second element
+ */
+
+ private void exchange(int[] numbers, int pos1, int pos2) {
+ int tmp = numbers[pos1];
+ numbers[pos1] = numbers[pos2];
+ numbers[pos2] = tmp;
+ }
+
+
+ /**
+ * Sorts an int array
+ *
+ * @param numbers the int array to sort
+ */
+
+ public void sort(int[] numbers) {
+ System.out.print("Sorting by LinearSort...");
+ int lowest = 0;
+
+ for (int start = 0; start < numbers.length; start ++) {
+ lowest = start;
+
+ for (int current = start; current < numbers.length; current ++) {
+ if (numbers[current] < numbers[lowest]) {
+ lowest = current;
+ }
+ }
+ exchange(numbers, start, lowest);
+ }
+ System.out.println("done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Main.java
new file mode 100644
index 000000000..c219af7fe
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Main.java
@@ -0,0 +1,96 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the strategy design pattern example.<p>
+ *
+ * Intent: <i>Define a family of algorithms, encapsulate each one, and make
+ * them interchangeable. Strategy lets the algorithm vary independently from
+ * clients that use it.</i><p>
+ *
+ * Participating objects are <code>LinearSort</code> and <i>BubbleSort</i>
+ * as <i>Strategies</i>, and <code>Sorter</code> as <i>Context</i>.
+ *
+ * In this example, an array of 10 numbers is to be sorted. Depending on the
+ * number of arguments of the call to <code>Main</code>, linear sort or
+ * bubblesort are used as sorting algorithms. The interface for the strategies
+ * is defined in <code>SortingStrategy</code>.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see LinearSort
+ * @see BubbleSort
+ */
+
+public class Main {
+
+ /**
+ * Returns the content of the int array in a string
+ *
+ * @param numbers the int array to display
+ * @returns a string with all the ints from the array
+ */
+
+ private static String show(int[] numbers) {
+ String out = "";
+ for (int i=0; i<numbers.length; i++) {
+ out += (numbers[i] + " ");
+ }
+ return out;
+ }
+
+ /**
+ * Implements the driver for the strategy example. If called with more
+ * than zero arguments, bubblesort is used to sort the array of ten
+ * numbers; otherwise linear sort.
+ */
+
+ public static void main(String[] args) {
+ int[] numbers = {3, 2, 9, 8, 1, 5, 6, 4, 7, 0};
+
+ LinearSort sort1 = new LinearSort();
+ BubbleSort sort2 = new BubbleSort();
+
+ Sorter sorter = new Sorter();
+
+
+ if (args.length == 0) {
+ SortingStrategy.aspectOf().setConcreteStrategy(sorter, sort1);
+ }
+ else {
+ SortingStrategy.aspectOf().setConcreteStrategy(sorter, sort2);
+ }
+
+ System.out.println("\nPreparing sort...");
+ System.out.println("original: "+show(numbers));
+ numbers = sorter.sort(numbers);
+ System.out.println("sorted: "+show(numbers));
+ }
+}
+
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Sorter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Sorter.java
new file mode 100644
index 000000000..0827addb5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/Sorter.java
@@ -0,0 +1,39 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This class represents the <i>Context</i> of the pattern. Note that
+ * it does not have to have pattern-related code in it.
+ *
+ * It will sort an int array with a provided sorting strategy. The
+ * implementation of the <code>sort(int[])</code> method is provided
+ * by the aspect. The aspect also chooses the proper strategy to
+ * perform the sorting.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Sorter {} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/SortingStrategy.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/SortingStrategy.java
new file mode 100644
index 000000000..9657f08f6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/SortingStrategy.java
@@ -0,0 +1,106 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.StrategyProtocol;
+
+/**
+ * This aspect defines the mechanics for executing the <i>Strategy</i>'s
+ * algorithm. In this case, an around advice is utilized to execute the
+ * proper code.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see LinearSort
+ * @see BubbleSort
+ */
+
+
+public aspect SortingStrategy extends StrategyProtocol {
+
+
+ /**
+ * Assignes the <i>Context</i> role to <code>Sorter</code>
+ */
+
+ declare parents: Sorter implements Context;
+
+ /**
+ * Assignes the <i>Strategy</i> role to <code>LinearSort</code>
+ */
+
+ declare parents: LinearSort implements Strategy;
+
+ /**
+ * Assignes the <i>Strategy</i> role to <code>BubbleSort</code>
+ */
+
+ declare parents: BubbleSort implements Strategy;
+
+
+ /**
+ * Sorts the array. This is merely a method stub. The actual
+ * implementation can either be realized here or in an
+ * <code>around</code> advice as illustrated below.
+ *
+ * This method acts as <i>ContextInterface()</code>.
+ *
+ * @param numbers
+ * @return
+ */
+
+ public int[] Sorter.sort(int[] numbers) {
+ return numbers;
+ }
+
+
+
+ /**
+ * Invokes the appropriate strategy's sort() method when the
+ * Sorter needs to sort. Using around advice is only one way
+ * of realizing this (see above).
+ *
+ * The around advice solution is more useful if the <i>Context</i>
+ * itself defines the <i>ContextInterface()</i> (not the case here).
+ *
+ * This particular implementation was chosen to illustrate the
+ * alternatives.
+ */
+
+ int[] around(Sorter s, int[] numbers):
+ call(int[] Sorter.sort(int[])) && target(s) && args(numbers) {
+
+ Strategy strategy = getConcreteStrategy(s);
+
+ if (strategy instanceof BubbleSort) {
+ ((BubbleSort)strategy).sort(numbers);
+ } else if (strategy instanceof LinearSort) {
+ ((LinearSort) strategy).sort(numbers);
+ } else {
+ // Invalid strategy: could throw an exception here
+ }
+ return numbers;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/BubbleSort.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/BubbleSort.java
new file mode 100644
index 000000000..3009d9fd0
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/BubbleSort.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the bubblesort sorting strategy for int arrays.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ */
+
+public class BubbleSort implements SortingStrategy {
+
+ /**
+ * Helper method that exchanges two values in an int array
+ *
+ * @param numbers the int array
+ * @param pos1 the position of the first element
+ * @param pos2 the position of the second element
+ */
+
+ private void exchange(int[] numbers, int pos1, int pos2) {
+ int tmp = numbers[pos1];
+ numbers[pos1] = numbers[pos2];
+ numbers[pos2] = tmp;
+ }
+
+ /**
+ * Sorts an int array using basic bubble sort
+ *
+ * @param numbers the int array to sort
+ */
+
+ public void sort(int[] numbers) {
+ System.out.print("Sorting by BubbleSort...");
+ for (int end = numbers.length; end > 1; end --) {
+ for (int current = 0; current < end - 1; current ++) {
+ if (numbers[current] > numbers[current+1]) {
+ exchange(numbers, current, current+1);
+ }
+ }
+ }
+ System.out.println("done.");
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/LinearSort.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/LinearSort.java
new file mode 100644
index 000000000..0fa44cae1
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/LinearSort.java
@@ -0,0 +1,72 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the linear sort sorting strategy for int arrays.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class LinearSort implements SortingStrategy{
+
+ /**
+ * Helper method that exchanges two values in an int array
+ *
+ * @param numbers the int array
+ * @param pos1 the position of the first element
+ * @param pos2 the position of the second element
+ */
+
+ private void exchange(int[] numbers, int pos1, int pos2) {
+ int tmp = numbers[pos1];
+ numbers[pos1] = numbers[pos2];
+ numbers[pos2] = tmp;
+ }
+
+
+ /**
+ * Sorts an int array
+ *
+ * @param numbers the int array to sort
+ */
+
+ public void sort(int[] numbers) {
+ System.out.print("Sorting by LinearSort...");
+ int lowest = 0;
+
+ for (int start = 0; start < numbers.length; start ++) {
+ lowest = start;
+
+ for (int current = start; current < numbers.length; current ++) {
+ if (numbers[current] < numbers[lowest]) {
+ lowest = current;
+ }
+ }
+ exchange(numbers, start, lowest);
+ }
+ System.out.println("done.");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Main.java
new file mode 100644
index 000000000..10df445f6
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Main.java
@@ -0,0 +1,75 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Strategy design pattern example.<p>
+ *
+ * Intent: <i>Define a family of algorithms, encapsulate each one, and make
+ * them interchangeable. Strategy lets the algorithm vary independently from
+ * clients that use it.</i><p>
+ *
+ * Participating objects are <code>LinearSort</code> and <code>BubbleSort
+ * </code> as <i>Strategies</i>, and <code>Sorter</code> as <i>Context</i>.
+ *
+ * In this example, an array of 10 numbers is to be sorted. Depending on the
+ * number of arguments of the call to <code>Main.main(..)</code>, linear sort
+ * or bubblesort are used as sorting algorithms. The interface for the
+ * <i>strategies</i> is defined in <code>SortingStrategy</code>.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see LinearSort
+ * @see BubbleSort
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the strategy example. If called with more
+ * than zero arguments, bubblesort is used to sort the array of ten
+ * numbers; otherwise linear sort is used.
+ */
+
+ public static void main(String[] args) {
+ int[] numbers = {3, 2, 9, 8, 1, 5, 6, 4, 7, 0};
+
+ SortingStrategy sort1 = new LinearSort();
+ SortingStrategy sort2 = new BubbleSort();
+
+ Sorter sorter;
+
+ if (args.length == 0) {
+ sorter = new Sorter(sort1, numbers);
+ }
+ else {
+ sorter = new Sorter(sort2, numbers);
+ }
+ }
+}
+
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Sorter.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Sorter.java
new file mode 100644
index 000000000..4a53ffc39
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/Sorter.java
@@ -0,0 +1,69 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Sorts an int array with a provided sorting strategy.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see LinearSort
+ * @see BubbleSort
+ */
+
+public class Sorter {
+
+ /**
+ * Shows the original (unsorted) array, sorts it and shows the new
+ * (sorted) array.
+ *
+ * @param sort the sorting strategy
+ * @param numbers the array of int to sort
+ */
+
+ public Sorter(SortingStrategy sort, int[] numbers) {
+ System.out.println("\nPreparing sort...");
+ System.out.println("original: "+show(numbers));
+ sort.sort(numbers);
+ System.out.println("sorted: "+show(numbers));
+ System.out.println("Done sorting.");
+ }
+
+ /**
+ * Returns the content of the int array in a string
+ *
+ * @param numbers the int array to display
+ * @returns a string with all the ints from the array
+ */
+
+ private static String show(int[] numbers) {
+ String out = "";
+ for (int i=0; i<numbers.length; i++)
+ {
+ out += (numbers[i] + " ");
+ }
+ return out;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/SortingStrategy.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/SortingStrategy.java
new file mode 100644
index 000000000..e5d647549
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/strategy/java/SortingStrategy.java
@@ -0,0 +1,36 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.strategy.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the interface for sorting strategies
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+
+public interface SortingStrategy {
+ public void sort(int[] numbers);
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/DecoratedStringGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/DecoratedStringGenerator.java
new file mode 100644
index 000000000..bededc15a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/DecoratedStringGenerator.java
@@ -0,0 +1,69 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for creators. In this example, it acts as the <i>
+ * AbstractClass</i>. T
+ *
+ * Note that the template method <code>generate(String)</code>
+ * (which uses all other methods defined in this abstract class) is
+ * implemented by the aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface DecoratedStringGenerator {
+
+ /**
+ * Prepares a string for decoration.
+ *
+ * @param s the string to filter
+ * @return the prepared string
+ */
+
+ public String prepare (String s);
+
+ /**
+ * Filters a string.
+ *
+ * @param s the string to filter
+ * @return the filtered string
+ */
+
+ public String filter (String s);
+
+ /**
+ * Finalizes a string. This is the last step in the template method.
+ *
+ * @param s the string to finalize
+ * @returns the finalized string
+ */
+
+ public String finalize (String s);
+}
+
+
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/FancyGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/FancyGenerator.java
new file mode 100644
index 000000000..2903a7191
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/FancyGenerator.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteClass</i> that decorates strings by turnung all
+ * characters into lowercase and then capitalizing the consonants. It also
+ * adds an explanation at the end.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class FancyGenerator implements DecoratedStringGenerator {
+
+ /**
+ * Prepares a string for decoration. Turns the string into lowercase.
+ *
+ * @param s the string to filter
+ * @return the prepared string
+ */
+
+ public String prepare (String s) {
+ return s.toLowerCase();
+ }
+
+ /**
+ * Filters a string. Capitalizes all consonants.
+ *
+ * @param s the string to filter
+ * @return the filtered string
+ */
+
+ public String filter (String s) {
+ s = s.replace('a', 'A');
+ s = s.replace('e', 'E');
+ s = s.replace('i', 'I');
+ s = s.replace('o', 'O');
+ s = s.replace('u', 'U');
+ return s;
+ }
+
+ /**
+ * Finalizes a string by adding an explanation to it.
+ *
+ * @param s the string to finalize
+ * @return the finalized string
+ */
+
+ public String finalize (String s) {
+ return (s+".\n(all consonants identified)");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Generating.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Generating.java
new file mode 100644
index 000000000..aa7d6be80
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Generating.java
@@ -0,0 +1,51 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an instance of the Template Method design pattern.
+ * Attaches the template method and its implementation to the
+ * <i>AbstractClass</i>, thereby allowing it to be an interface.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public aspect Generating {
+
+ /**
+ * Defines the implementation of the <i>TemplateMethod()</i>.
+ * Generates a string with certain decorations.
+ *
+ * @param s the string to be used to generate a decorated string from
+ */
+
+ public String DecoratedStringGenerator.generate(String s) {
+ s = prepare(s);
+ s = filter(s);
+ s = finalize(s);
+ return s;
+ }
+}
+ \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Main.java
new file mode 100644
index 000000000..fa4d447f2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/Main.java
@@ -0,0 +1,75 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Template Method design pattern example.<p>
+ *
+ * Intent: <i>Define the skeleton of an algorithm in an operation, deferring
+ * some steps to subclasses. Template Method lets subclasses redefine certain
+ * steps of an algorithm without changing the algorithm's structure</i><p>
+ *
+ * Participating objects are <code>SimpleGenerator</code> and
+ * <code>FancyGenerator</code> as <i>ConcreteClass</i>es. The
+ * <i>AbstractClass</i> is <code>DecoratedStringGenerator</code>.
+ * <p>
+ *
+ * In this example, the template method <code>generate(String)</code>
+ * modifies a string in three steps and returns the result. While the
+ * SimpleGenerator does not change the string much, the
+ * FancyGenerator turns the string to lowercase, then capitalizes all
+ * consonants and adds an explanantion to it.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Note that <i>AbstractClass</i> is an interface. The implementation of the
+ * template method is provided by the aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Template Method design
+ * pattern example.<p>
+ *
+ * @param args the command line parameters, unused
+ */
+
+ public static void main(String[] args) {
+ String original = "This Is The Original String To Be Processed";
+
+ DecoratedStringGenerator c1 = new SimpleGenerator();
+ DecoratedStringGenerator c2 = new FancyGenerator();
+
+ System.out.println("<Original>");
+ System.out.println(original);
+ System.out.println("<SimpleGenerator>");
+ System.out.println(c1.generate(original));
+ System.out.println("<FancyGenerator>");
+ System.out.println(c2.generate(original));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/SimpleGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/SimpleGenerator.java
new file mode 100644
index 000000000..c63a93ad9
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/SimpleGenerator.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteClass</i> that decorates strings by adding a
+ * period at the end of them.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class SimpleGenerator implements DecoratedStringGenerator {
+
+ /**
+ * Prepares a string for decoration. Does nothing.
+ *
+ * @param s the string to filter
+ * @return the passed string
+ */
+
+ public String prepare (String s) {
+ return s;
+ }
+
+ /**
+ * Filters a string. Does nothing.
+ *
+ * @param s the string to filter
+ * @return the passed string
+ */
+
+ public String filter (String s) {
+ return s;
+ }
+
+ /**
+ * Finalizes a string by adding a period to it.
+ *
+ * @param s the string to finalize
+ * @return the finalized string
+ */
+
+ public String finalize (String s) {
+ return s+".";
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/DecoratedStringGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/DecoratedStringGenerator.java
new file mode 100644
index 000000000..55a520687
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/DecoratedStringGenerator.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for generating decorated strings.
+ * In this example, it acts as the <i>AbstractClass</i>.
+ *
+ * The template method is <code>generate(String)</code>,
+ * which uses all other methods defined in this abstract class.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public abstract class DecoratedStringGenerator {
+
+ /**
+ * Decorates a string. This is the <i>TemplateMethod()</i>.
+ *
+ * @param s the string to decorate
+ * @return the decorated string
+ */
+
+ public String generate(String s) {
+ s = prepare(s);
+ s = filter(s);
+ s = finalize(s);
+ return s;
+ }
+
+ /**
+ * Prepares a string for decoration.
+ *
+ * @param s the string to filter
+ * @return the prepared string
+ */
+
+ public abstract String prepare (String s);
+
+ /**
+ * Filters a string.
+ *
+ * @param s the string to filter
+ * @return the filtered string
+ */
+
+ public abstract String filter (String s);
+
+ /**
+ * Finalizes a string. This is the last step in the template method.
+ *
+ * @param s the string to finalize
+ * @return the finalized string
+ */
+
+ public abstract String finalize (String s);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/FancyGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/FancyGenerator.java
new file mode 100644
index 000000000..d55129bee
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/FancyGenerator.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteClass</i> that decorates strings by turnung all
+ * characters into lowercase and then capitalizing the consonants. It also
+ * adds an explanation at the end.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class FancyGenerator extends DecoratedStringGenerator {
+
+ /**
+ * Prepares a string for decoration. Turns the string into lowercase.
+ *
+ * @param s the string to filter
+ * @return the prepared string
+ */
+
+ public String prepare (String s) {
+ return s.toLowerCase();
+ }
+
+ /**
+ * Filters a string. Capitalizes all consonants.
+ *
+ * @param s the string to filter
+ * @return the filtered string
+ */
+
+ public String filter (String s) {
+ s = s.replace('a', 'A');
+ s = s.replace('e', 'E');
+ s = s.replace('i', 'I');
+ s = s.replace('o', 'O');
+ s = s.replace('u', 'U');
+ return s;
+ }
+
+ /**
+ * Finalizes a string by adding an explanation to it.
+ *
+ * @param s the string to finalize
+ * @return the finalized string
+ */
+
+ public String finalize (String s) {
+ return (s+".\n(all consonants capitalized)");
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/Main.java
new file mode 100644
index 000000000..a9245b69b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/Main.java
@@ -0,0 +1,76 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Template Method design pattern example.<p>
+ *
+ * Intent: <i>Define the skeleton of an algorithm in an operation, deferring
+ * some steps to subclasses. Template Method lets subclasses redefine certain
+ * steps of an algorithm without changing the algorithm's structure</i><p>
+ *
+ * Participating objects are <code>SimpleGenerator</code> and
+ * <code>FancyGenerator</code> as <i>ConcreteClass</i>es. The
+ * <i>AbstractClass</i> is <code>DecoratedStringGenerator</code>.
+ * <p>
+ *
+ * In this example, the template method <code>generate(String)</code>
+ * modifies a string in three steps and returns the result. While the
+ * SimpleGenerator does not change the string much, the
+ * FancyGenerator turns the string to lowercase, then capitalizes all
+ * consonants and adds an explanantion to it.
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Note that <i>AbstractClass</i> does in fact have to be an abstract
+ * class (as opposed to an interface), to make it possible to define
+ * a default implementation for the template method.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Template Method design
+ * pattern example.<p>
+ *
+ * @param args the command line parameters, unused
+ */
+
+ public static void main(String[] args) {
+ String original = "This Is The Original String To Be Processed";
+
+ DecoratedStringGenerator c1 = new SimpleGenerator();
+ DecoratedStringGenerator c2 = new FancyGenerator();
+
+ System.out.println("<Original>");
+ System.out.println(original);
+ System.out.println("<SimpleGenerator>");
+ System.out.println(c1.generate(original));
+ System.out.println("<FancyGenerator>");
+ System.out.println(c2.generate(original));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/SimpleGenerator.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/SimpleGenerator.java
new file mode 100644
index 000000000..425dcc9cd
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/templateMethod/java/SimpleGenerator.java
@@ -0,0 +1,68 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteClass</i> that decorates strings by adding a
+ * period at the end of them.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class SimpleGenerator extends DecoratedStringGenerator {
+
+ /**
+ * Prepares a string for decoration. Does nothing.
+ *
+ * @param s the string to filter
+ * @return the passed string
+ */
+
+ public String prepare (String s) {
+ return s;
+ }
+
+ /**
+ * Filters a string. Does nothing.
+ *
+ * @param s the string to filter
+ * @return the passed string
+ */
+
+ public String filter (String s) {
+ return s;
+ }
+
+ /**
+ * Finalizes a string by adding a period to it.
+ *
+ * @param s the string to finalize
+ * @return the finalized string
+ */
+
+ public String finalize (String s) {
+ return s+".";
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeLeaf.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeLeaf.java
new file mode 100644
index 000000000..24dad0e39
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeLeaf.java
@@ -0,0 +1,61 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteElement</i> of the aggregate strcuture. This is a
+ * terminal binary tree element (leaf).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class BinaryTreeLeaf implements Visitable {
+
+ /**
+ * the value stored in this leaf
+ */
+
+ protected int value;
+
+ /**
+ * Creates a new Leaf with the given value.
+ *
+ * @param value the value of the leaf
+ */
+
+ public BinaryTreeLeaf(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Accessor for the leaf's value
+ *
+ * @return the leaf's value
+ */
+
+ public int getValue() {
+ return value;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeNode.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeNode.java
new file mode 100644
index 000000000..84b87122c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/BinaryTreeNode.java
@@ -0,0 +1,79 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteElement</i> of the aggregate strcuture. This is a
+ * non-terminal binary tree element.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class BinaryTreeNode implements Visitable {
+
+ /**
+ * the left subtree
+ */
+
+ protected Visitable left;
+
+ /**
+ * the right subtree
+ */
+
+ protected Visitable right;
+
+ /**
+ * Accessor for the left subtree.
+ *
+ * @return the left subtree.
+ */
+
+ public Visitable getLeft() {
+ return left;
+ }
+
+ /**
+ * Accessor for the right subtree.
+ *
+ * @return the right subtree.
+ */
+
+ public Visitable getRight() {
+ return right;
+ }
+
+ /**
+ * Creates a non-terminal node of a binary tree.
+ *
+ * @param l the new left subtree.
+ * @param l the new left subtree.
+ */
+
+ public BinaryTreeNode(Visitable left, Visitable right) {
+ this.left = left;
+ this.right = right;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Main.java
new file mode 100644
index 000000000..938f50f03
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Main.java
@@ -0,0 +1,103 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Visitor design pattern example.<p>
+ *
+ * Intent: <i>Represents an operation to be performed on the elements of an
+ * object structure. Visitor lets you define a new operation without changing
+ * the classes of the elements on which it operates</i><p>
+ *
+ * Participating classes are <code>SummationVisitor</code> and
+ * <code>TraversalVisitor</code> as <i>ConcreteVisitor</i>s, implementing the
+ * <code>VisitorProtocol.Visitor</code> interface. <BR>
+ *
+ * <code>BinaryTreeNode</code> and <code>BinaryTreeLeaf</code> are
+ * <i>ConcreteElement</i>s, implementing the <code>Visitable</code> interface.
+ * <p>
+ *
+ * In this example, a binary tree that has int values as leafs is built.
+ * SummationVisitor is a <i>Visitor</i> that collects the sum of
+ * elements in the leafs (should be 6).
+ *
+ * TraversalVisitor is a <i>Visitor</i> that
+ * collects a description of the tree like {{1,2},3}
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Note that <UL>
+ * <LI> Every visitor (even the inteface) has to know of each possible element
+ * type in the object structure.
+ * <LI> Nodes need not to know of the visitor interface;
+ * </UL>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Visitor design pattern example.<p>
+ *
+ * @param args the command-line parameters, unused
+ */
+
+
+ public static void main(String[] args) {
+
+ System.out.println("Building the tree (1): leaves");
+
+ BinaryTreeLeaf one = new BinaryTreeLeaf(1);
+ BinaryTreeLeaf two = new BinaryTreeLeaf(2);
+ BinaryTreeLeaf three = new BinaryTreeLeaf(3);
+
+ System.out.println("Building the tree (1): regular nodes");
+
+ BinaryTreeNode regN = new BinaryTreeNode(one, two);
+ BinaryTreeNode root = new BinaryTreeNode(regN, three);
+
+ System.out.println("The tree now looks like this: ");
+ System.out.println(" regN ");
+ System.out.println(" / \\ ");
+ System.out.println(" regN 3 ");
+ System.out.println(" / \\ ");
+ System.out.println(" 1 2 ");
+
+ System.out.println("Visitor 1: SumVisitor, collects the sum of leaf");
+ System.out.println("values. Result should be 6.");
+
+ SummationVisitor sumVisitor = new SummationVisitor();
+ root.accept(sumVisitor);
+ System.out.println(sumVisitor.report());
+
+ System.out.println("Visitor 2: TraversalVisitor, collects a tree");
+ System.out.println("representation. Result should be {{1,2},3}.");
+
+ TraversalVisitor traversalVisitor = new TraversalVisitor();
+ root.accept(traversalVisitor);
+ System.out.println(traversalVisitor.report());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/SummationVisitor.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/SummationVisitor.java
new file mode 100644
index 000000000..928cbd90a
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/SummationVisitor.java
@@ -0,0 +1,80 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.VisitorProtocol;
+
+/**
+ * Implements a <i>ConcreteVisitor</i> that collects the sum of all leaf
+ * values in the tree.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class SummationVisitor implements VisitorProtocol.Visitor {
+
+ /**
+ * the colleced sum of leaf values
+ */
+
+ protected int sum = 0;
+
+ /**
+ * Visits a non-terminal binary tree node.
+ *
+ * @param node the regular node
+ */
+
+ public void visitNode(VisitorProtocol.VisitableNode node) {
+ if (node instanceof BinaryTreeNode) {
+ BinaryTreeNode rnode = (BinaryTreeNode) node;
+ rnode.left.accept(this);
+ rnode.right.accept(this);
+ }
+ }
+
+ /**
+ * Visits a terminal tree node.
+ *
+ * @param node the leaf
+ */
+
+ public void visitLeaf(VisitorProtocol.VisitableNode node) {
+ if (node instanceof BinaryTreeLeaf) {
+ BinaryTreeLeaf leaf = (BinaryTreeLeaf) node;
+ sum += leaf.getValue();
+ }
+ }
+
+ /**
+ * Returns the result of the visitor's operation
+ *
+ * @return a string representing the sum of elemnent in the tree's leaves
+ */
+
+ public String report() {
+ return ">>> SumVisitor collected a sum of "+sum;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/TraversalVisitor.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/TraversalVisitor.java
new file mode 100644
index 000000000..2143cad72
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/TraversalVisitor.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.VisitorProtocol;
+
+/**
+ * Implements a <i>ConcreteVisitor</i> that collects string representation
+ * of the tree.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class TraversalVisitor implements VisitorProtocol.Visitor {
+
+ /**
+ * contains the accumulated result
+ */
+
+ protected String result = "";
+
+ /**
+ * Visits a a non-terminal binary tree node.
+ *
+ * @param node the regular node
+ */
+
+ public void visitNode(VisitorProtocol.VisitableNode node) {
+ if (node instanceof BinaryTreeNode) {
+ BinaryTreeNode rnode = (BinaryTreeNode) node;
+ result += "{";
+ rnode.left.accept(this);
+ result += ",";
+ rnode.right.accept(this);
+ result += "}";
+ }
+ }
+
+ /**
+ * Visits a terminal tree node.
+ *
+ * @param node the leaf
+ */
+
+ public void visitLeaf(VisitorProtocol.VisitableNode node) {
+ if (node instanceof BinaryTreeLeaf) {
+ BinaryTreeLeaf leaf = (BinaryTreeLeaf) node;
+ result += leaf.value;
+ }
+ }
+
+ /**
+ * Returns the result of the visitor's operation
+ *
+ * @return a string representing a traversal of the tree
+ */
+
+ public String report() {
+ return ">>> TraversalVisitor traversed the tree to: "+result;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visitable.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visitable.java
new file mode 100644
index 000000000..cbf4e52b2
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visitable.java
@@ -0,0 +1,34 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for nodes. For this example, the interface is empty.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface Visitable {}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visiting.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visiting.java
new file mode 100644
index 000000000..17bae11fd
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/Visiting.java
@@ -0,0 +1,55 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.VisitorProtocol;
+
+/**
+ * Implements a concrete visitor pattern instance. This aspect assigns
+ * the roles to the participants.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public aspect Visiting extends VisitorProtocol {
+
+ /**
+ * Assigns the <code>VisitableNote</code> role to <code>Visitable</code>
+ */
+
+ declare parents: Visitable implements VisitableNode;
+
+ /**
+ * Assigns the <code>Node</code> role to <code>BinaryTreeNode</code>
+ */
+
+ declare parents: BinaryTreeNode implements Node;
+
+ /**
+ * Assigns the <code>Leaf</code> role to <code>BinaryTreeLeaf</code>
+ */
+
+ declare parents: BinaryTreeLeaf implements Leaf;
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/build.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/build.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/build.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/visitor.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/visitor.lst
new file mode 100644
index 000000000..a4a021898
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/aspectj/visitor.lst
@@ -0,0 +1,2 @@
+*.java
+../../../patternLibrary/VisitorProtocol.java
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeLeaf.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeLeaf.java
new file mode 100644
index 000000000..38102d325
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeLeaf.java
@@ -0,0 +1,71 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteElement</i> of the aggregate strcuture. This is a
+ * terminal binary tree element (leaf).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class BinaryTreeLeaf implements Visitable {
+
+ /**
+ * the value stored in this leaf
+ */
+
+ protected int value;
+
+ /**
+ * Accepts a visitor and calls <code>visitLeaf(Node) on it.
+ *
+ * @param visitor the NodeVisitor that is to be accepted.
+ */
+
+ public void accept(BinaryTreeVisitor visitor) {
+ visitor.visitLeaf(this);
+ }
+
+ /**
+ * Creates a new <code>BinaryTreeLeaf</code> with the given value.
+ *
+ * @param value the value of the leaf
+ */
+
+ public BinaryTreeLeaf(int value) {
+ this.value = value;
+ }
+
+ /**
+ * Accessor for the leaf's value
+ *
+ * @return the leaf's value
+ */
+
+ public int getValue() {
+ return value;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeNode.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeNode.java
new file mode 100644
index 000000000..604749717
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeNode.java
@@ -0,0 +1,89 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteElement</i> of the aggregate strcuture. This is a
+ * non-terminal binary tree element.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class BinaryTreeNode implements Visitable {
+
+ /**
+ * the left subtree
+ */
+
+ protected Visitable left;
+
+ /**
+ * the right subtree
+ */
+
+ protected Visitable right;
+
+ /**
+ * Accepts a visitor and calls <code>visitRegularNode(Node) on it.
+ *
+ * @param visitor the NodeVisitor that is to be accepted.
+ */
+
+ public void accept(BinaryTreeVisitor visitor) {
+ visitor.visitNode(this);
+ }
+
+ /**
+ * Accessor for the left subtree.
+ *
+ * @return the left subtree.
+ */
+
+ public Visitable getLeft() {
+ return left;
+ }
+
+ /**
+ * Accessor for the right subtree.
+ *
+ * @return the right subtree.
+ */
+
+ public Visitable getRight() {
+ return right;
+ }
+
+ /**
+ * Creates a non-terminal node of a binary tree.
+ *
+ * @param left the new left subtree.
+ * @param right the new left subtree.
+ */
+
+ public BinaryTreeNode(Visitable left, Visitable right) {
+ this.left = left;
+ this.right = right;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeVisitor.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeVisitor.java
new file mode 100644
index 000000000..5ed0d22da
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/BinaryTreeVisitor.java
@@ -0,0 +1,59 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for <i>Visitor</i>s that operate on binary trees
+ * consisting of leaves and nodes.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface BinaryTreeVisitor {
+
+ /**
+ * Visits a non-terminal binary tree node.
+ *
+ * @param node the node to visit
+ */
+
+ public void visitNode(Visitable node);
+
+ /**
+ * Visits a leaf, which is a terminal tree node.
+ *
+ * @param node the leaf
+ */
+
+ public void visitLeaf(Visitable node);
+
+ /**
+ * Returns the result of the visitor's operation
+ *
+ * @return a string describing the result of this visitor's operation.
+ */
+
+ public String report();
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Main.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Main.java
new file mode 100644
index 000000000..0f336e61e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Main.java
@@ -0,0 +1,104 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the driver for the Visitor design pattern example.<p>
+ *
+ * Intent: <i>Represents an operation to be performed on the elements of an
+ * object structure. Visitor lets you define a new operation without changing
+ * the classes of the elements on which it operates</i><p>
+ *
+ * Participating classes are <code>SummationVisitor</code> and
+ * <code>TraversalVisitor</code> as <i>ConcreteVisitor</i>s, implementing the
+ * <code>BinaryTreeVisitor</code> interface. <BR>
+ *
+ * <code>BinaryTreeNode</code> and <code>BinaryTreeLeaf</code> are
+ * <i>ConcreteElement</i>s, implementing the <code>Visitable</code> interface.
+ * <p>
+ *
+ * In this example, a binary tree is built that has
+ * int values as leafs. <code>SummationVisitor</code> is a <i>Visitor</i>
+ * that collects the sum of the leaf values (should be 6).
+ *
+ * TraversalVisitor is a visitor that
+ * collects a description of the tree like {{1,2},3}
+ *
+ * <p><i>This is the Java version.</i><p>
+ *
+ * Note that <UL>
+ * <LI> Every visitor (even the interface) has to know of each possible element
+ * type in the object structure.
+ * <LI> Nodes need to know of the visitor interface; they have to implement the
+ * accept(NodeVisitor) method.
+ * </UL>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class Main {
+
+ /**
+ * Implements the driver for the Visitor design pattern example.<p>
+ *
+ * @param args the command-line parameters, unused
+ */
+
+
+ public static void main(String[] args) {
+
+ System.out.println("Building the tree (1): leaves");
+
+ BinaryTreeLeaf one = new BinaryTreeLeaf(1);
+ BinaryTreeLeaf two = new BinaryTreeLeaf(2);
+ BinaryTreeLeaf three = new BinaryTreeLeaf(3);
+
+ System.out.println("Building the tree (1): regular nodes");
+
+ BinaryTreeNode regN = new BinaryTreeNode(one, two);
+ BinaryTreeNode root = new BinaryTreeNode(regN, three);
+
+ System.out.println("The tree now looks like this: ");
+ System.out.println(" regN ");
+ System.out.println(" / \\ ");
+ System.out.println(" regN 3 ");
+ System.out.println(" / \\ ");
+ System.out.println(" 1 2 ");
+
+ System.out.println("Visitor 1: SumVisitor, collects the sum of leaf");
+ System.out.println("values. Result should be 6.");
+
+ SummationVisitor sumVisitor = new SummationVisitor();
+ root.accept(sumVisitor);
+ System.out.println(sumVisitor.report());
+
+ System.out.println("Visitor 2: TraversalVisitor, collects a tree");
+ System.out.println("representation. Result should be {{1,2},3}.");
+
+ TraversalVisitor traversalVisitor = new TraversalVisitor();
+ root.accept(traversalVisitor);
+ System.out.println(traversalVisitor.report());
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/SummationVisitor.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/SummationVisitor.java
new file mode 100644
index 000000000..326775c1e
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/SummationVisitor.java
@@ -0,0 +1,74 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteVisitor</i> that collects the sum of all leaf
+ * values in the tree.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class SummationVisitor implements BinaryTreeVisitor {
+
+ /**
+ * the colleced sum of leaf values
+ */
+
+ protected int sum = 0;
+
+ /**
+ * Visits a non-terminal binary tree node.
+ *
+ * @param node the regular node
+ */
+
+ public void visitNode(Visitable node) {
+ BinaryTreeNode rnode = (BinaryTreeNode) node;
+ rnode.left.accept(this);
+ rnode.right.accept(this);
+ }
+
+ /**
+ * Visits a terminal tree node.
+ *
+ * @param node the leaf
+ */
+
+ public void visitLeaf(Visitable node) {
+ BinaryTreeLeaf leaf = (BinaryTreeLeaf) node;
+ sum += leaf.getValue();
+ }
+
+ /**
+ * Returns the result of the visitor's operation
+ *
+ * @return a string representation of the sum of leaf values
+ */
+
+ public String report() {
+ return ">>> SummationVisitor collected a sum of: "+sum;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/TraversalVisitor.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/TraversalVisitor.java
new file mode 100644
index 000000000..24dbffb58
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/TraversalVisitor.java
@@ -0,0 +1,77 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements a <i>ConcreteVisitor</i> that collects string representation
+ * of the tree.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public class TraversalVisitor implements BinaryTreeVisitor {
+
+ /**
+ * contains the accumulated result
+ */
+
+ protected String result = "";
+
+ /**
+ * Visits a non-terminal binary tree node.
+ *
+ * @param node the regular node
+ */
+
+ public void visitNode(Visitable node) {
+ BinaryTreeNode rnode = (BinaryTreeNode) node;
+ result += "{";
+ rnode.getLeft().accept(this);
+ result += ",";
+ rnode.getRight().accept(this);
+ result += "}";
+ }
+
+ /**
+ * Visits a terminal tree node.
+ *
+ * @param node the leaf
+ */
+
+ public void visitLeaf(Visitable node) {
+ BinaryTreeLeaf leaf = (BinaryTreeLeaf) node;
+ result += leaf.getValue();
+ }
+
+ /**
+ * Returns the result of the visitor's operation
+ *
+ * @return a string representing a traversal of the tree
+ */
+
+ public String report() {
+ return ">>> TraversalVisitor traversed the tree to: "+result;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Visitable.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Visitable.java
new file mode 100644
index 000000000..4db9b475d
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/examples/visitor/java/Visitable.java
@@ -0,0 +1,43 @@
+package ca.ubc.cs.spl.aspectPatterns.examples.visitor.java;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Defines the interface for nodes that can accept <i>Visitor</i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface Visitable {
+
+ /**
+ * Accepts a <i>Visitor</i>.
+ *
+ * @param visitor the NodeVisitor that is to be accepted.
+ */
+
+ public void accept(BinaryTreeVisitor visitor);
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityException.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityException.java
new file mode 100644
index 000000000..752e67fb8
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityException.java
@@ -0,0 +1,47 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an exception that occurs if an a request reaches the
+ * end of a <i>Chain of Responsibility</i> but remains unhandled.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/28/04
+ *
+ * @see ChainOfResponsibilityProtocol
+ */
+
+public class ChainOfResponsibilityException extends RuntimeException {
+
+ /**
+ * Creates a ChainOfResponsibilityException
+ *
+ * @param s the error message
+ */
+
+ public ChainOfResponsibilityException(String s) {
+ super(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityProtocol.java
new file mode 100644
index 000000000..f21e0b883
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ChainOfResponsibilityProtocol.java
@@ -0,0 +1,176 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.WeakHashMap;
+
+/**
+ * Defines the general behavior of the chain of responsibility design pattern.
+ *
+ * Each concrete sub-aspect of this aspect defines one particular instance of
+ * the pattern, with an arbitrary number of <i>Handler</i> classes involved.
+ *
+ * The sub-aspect defines three things: <ol>
+ *
+ * <li> what types can be <i>Handlers</i>
+ *
+ * <li> what types can be <i>Request</i>s
+ *
+ * <li> what triggers a <i>Request</i>
+ *
+ * <li> how each <i>Handler</i> treats a particular request. The default
+ * implementation in this aspect here makes it only necessary to code
+ * those cases where an event is actually handled.
+ * </ol>
+ *
+ * Note that in this implementation, a default behavior for <i>Handler</i>s is
+ * defined: unless a <i>Handler</i> explicitly handles an event, it is passed
+ * to its successor. In addition to that, the implementation allows to define
+ * a default bahavior in case no <i>Handler</i> in the chain handles an event.
+ * Here, an exception is raised. <p>
+ *
+ * Note further that this version, as all approaches that utilize role
+ * interfaces (empty interfaces identifying the roles in the pattern), has the
+ * following limitations: role interfaces only work on types that the weaver
+ * has access to. Further, without generics support for Java/AspectJ, casting
+ * is required at some points.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 01/27/04
+ *
+ */
+
+public abstract aspect ChainOfResponsibilityProtocol {
+
+ /**
+ * This interface is used by extending aspects to say what types
+ * handle requests. It models the <i>Handler</i> role.
+ */
+
+ protected interface Handler {}
+
+ /**
+ * This interface is used by extending aspects to say what types
+ * represent requests. It models the <i>Request</i> role.
+ */
+
+ protected interface Request {}
+
+ /**
+ * Stores the mapping between <code>Handler</code>s and its<i>
+ * Successor</i>. For each handler, its <i>Successor</i>
+ * is stored.
+ */
+
+ private WeakHashMap successors = new WeakHashMap();
+
+
+ /**
+ * Implements the abstracted CoR behavior. Assumption: If the request is
+ * not handled, the last receiver handles it by default ( that is true
+ * for this implementnation of the protocol).
+ *
+ * The current handler gets asked if it wants to handle the request. If
+ * not, the request is forwarded to its successor
+ */
+
+ protected void receiveRequest(Handler handler, Request request) {
+ if (handler.acceptRequest(request)) {
+ handler.handleRequest(request);
+ } else {
+ Handler successor = getSuccessor(handler);
+ if (successor == null) {
+ throw new ChainOfResponsibilityException("request unhandled (end of chain reached)\n");
+ // This is one way to deal with unhandled requests.
+ } else {
+ receiveRequest(successor, request);
+ }
+ }
+ }
+
+ /**
+ * Method defined for Handlers: returns true if a Handler wants to hanlde
+ * that request. By default, requests are rejected.
+ *
+ * @param request the request to be handled
+ */
+
+ public boolean Handler.acceptRequest(Request request) {
+ return false;
+ }
+
+ /**
+ * Method defined for Handlers: handles a request. Default implementation,
+ * does nothing. It is possible to extend this library implementation to
+ * shows an error message if this method is not overwritten.
+ *
+ * @param request the request to be handled
+ */
+
+ public void Handler.handleRequest(Request request) {}
+
+
+ /**
+ * The join points after which a request is raised.
+ * It replaces the normally scattered calls to <i>notify()</i>. To be
+ * concretized by sub-aspects.
+ */
+
+ protected abstract pointcut eventTrigger(Handler handler, Request request);
+
+
+ /**
+ * Calls receiveRequest() after a request was started.
+ *
+ * @param s the subject on which the change occured
+ */
+
+ after(Handler handler, Request request): eventTrigger(handler, request) {
+ receiveRequest(handler, request);
+ }
+
+
+ /**
+ * Adds a successor to a <i>Handler</i>.
+ *
+ * @param handler the handler to add a new successor to
+ * @param successor the new successor to attach
+ */
+
+ public void setSuccessor(Handler handler, Handler successor) {
+ successors.put(handler, successor);
+ }
+
+
+ /**
+ * Returns the successor of a handler.
+ *
+ * @param handler the handler in question
+ * @return the successor of the handler
+ */
+
+ public Handler getSuccessor(Handler handler) {
+ return ((Handler) successors.get(handler));
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Command.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Command.java
new file mode 100644
index 000000000..03867b689
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Command.java
@@ -0,0 +1,52 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This interface is implemented by <i>Command</i> objects.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public interface Command {
+
+ /**
+ * Executes the command.
+ *
+ * @param receiver the object this command is manipulating.
+ */
+
+ public void executeCommand(CommandReceiver receiver);
+
+ /**
+ * Queries the command's executable status. This interface method is
+ * optional (default: all commands are excutable); a default
+ * implementation is provided by the abstract CommandProtocol aspect.
+ *
+ * @returns a boolean indicating whether the command is excutable.
+ */
+
+ public boolean isExecutable();
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandInvoker.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandInvoker.java
new file mode 100644
index 000000000..0933fa84c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandInvoker.java
@@ -0,0 +1,38 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This interface is used by extending aspects to say what types
+ * can be Invokers (i.e. senders of an executeCommand() call).
+ * This role is assigned by concrete sub-aspects of the <code>CommandProtocol
+ * </code> pattern aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see CommandProtocol
+ */
+
+public interface CommandInvoker { } \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandProtocol.java
new file mode 100644
index 000000000..11951abba
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandProtocol.java
@@ -0,0 +1,255 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.WeakHashMap;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.Command;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandInvoker;
+import ca.ubc.cs.spl.aspectPatterns.patternLibrary.CommandReceiver;
+
+/**
+ * This is the abstract <i>Command</i> protocol.
+ *
+ * Note that this implementation allows only for exactly one command per
+ * invoker. That is usually sufficient, but alternate implementations
+ * could account for multiple commands by using composite
+ * (macro) commands (either with or without defined order).
+ *
+ * To allow for some flexibility, commands can either be explicitly
+ * set or removed by <i>Client</i>s, or this can be done via
+ * pointcuts.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public abstract aspect CommandProtocol {
+
+////////////////////////////////
+// Invoker -> Command mapping //
+////////////////////////////////
+
+ /**
+ * stores the mapping between CommandInvokers and Commands
+ */
+
+ private WeakHashMap mappingInvokerToCommand = new WeakHashMap();
+
+ /**
+ * Sets a new command for an invoker
+ *
+ * @param invoker the object which will invoke the command
+ * @param command the command to be set
+ * @return the former command
+ */
+
+ public Object setCommand(CommandInvoker invoker, Command command) {
+ return mappingInvokerToCommand.put(invoker, command);
+ }
+
+ /**
+ * Removes a command from an invoker
+ *
+ * @param invoker the object which will no longer invoke the command
+ * @param command the command to be removed
+ * @return the former command
+ */
+
+ public Object removeCommand(CommandInvoker invoker) {
+ return setCommand(invoker, null);
+ }
+
+
+ /**
+ * Returns the command for an invoker
+ *
+ * @param invoker the object for which to return the command
+ * @return the current command for the invoker
+ */
+
+ public Command getCommand(CommandInvoker invoker) {
+ return (Command) mappingInvokerToCommand.get(invoker);
+ }
+
+
+/////////////////////////////////
+// Command -> Receiver mapping //
+/////////////////////////////////
+
+ /**
+ * stores the mapping between Coammnds and Receivers
+ */
+
+ private WeakHashMap mappingCommandToReceiver = new WeakHashMap();
+
+ /**
+ * Sets a new receiver for a command
+ *
+ * @param command the command to be set
+ * @param receiver the object to be manipulated by the command's
+ * execute() method
+ * @return the former receiver
+ */
+
+ public Object setReceiver(Command command, CommandReceiver receiver) {
+ return mappingCommandToReceiver.put(command, receiver);
+ }
+
+ /**
+ * Returns the receiver for a particular command
+ *
+ * @param invoker the object for which to return the command
+ * @returns the current command for the invoker
+ */
+
+ public CommandReceiver getReceiver(Command command) {
+ return (CommandReceiver) mappingCommandToReceiver.get(command);
+ }
+
+
+///////////////////////////////////////
+// Command Execution via PC & advice //
+///////////////////////////////////////
+
+
+ /**
+ * The join points after which to execute the command.
+ * This replaces the normally scattered <i>Command.execute()</i> calls.
+ *
+ * @param invoker the object invoking the command
+ */
+
+ protected abstract pointcut commandTrigger(CommandInvoker invoker);
+
+
+ /**
+ * Calls <code>executeCommand()</code> when the command is triggered.
+ *
+ * @param invoker the object invoking the command
+ */
+
+ after(CommandInvoker invoker): commandTrigger(invoker) {
+ Command command = getCommand(invoker);
+ if (command != null) {
+ CommandReceiver receiver = getReceiver(command);
+ command.executeCommand(receiver);
+ } else {
+ // Do nothing: This Invoker has no associated command
+ }
+ }
+
+
+//////////////////////////////////
+// setCommand() via PC & advice //
+//////////////////////////////////
+
+ /**
+ * The join points after which to set a command for an invoker.
+ * This replaces the normally scattered <i>Invoker.add(Command)</i> calls.
+ * The pointcut is provided in addition to the setCommand() method above,
+ * to allow all pattern code to be removed from concrete invokers.
+ *
+ * This PC is non-abstract, to make it optional for sub-aspcects to define
+ * it.
+ *
+ * @param invoker the invoker to attach the command to
+ * @param command the command to be attached to the invoker
+ */
+
+ protected pointcut setCommandTrigger(CommandInvoker invoker, Command command);
+
+
+ /**
+ * Calls <code>addCommand()</code> when a command should be set.
+ *
+ * @param invoker the invoker to attach the command to
+ * @param command the command to be attached to the invoker
+ */
+
+ after (CommandInvoker invoker, Command command):
+ setCommandTrigger(invoker, command) {
+ if (invoker != null) {
+ setCommand(invoker, command);
+ } else {
+ // If the invoker is null, the command cannot be set.
+ // Either ignore this case or throw an exception
+ }
+ }
+
+/////////////////////////////////////
+// removeCommand() via PC & advice //
+/////////////////////////////////////
+
+ /**
+ * The join points after which to remove a command from an invoker.
+ * This replaces the normally scattered <code>Invoker.remove(Command)
+ * </code> calls.
+ *
+ * The pointcut is provided in addition to the <code>removeCommand()
+ * </code> method above, to allow all pattern code to be removed from
+ * concrete invokers.
+ *
+ * This PC is non-abstract, to make it optional for sub-aspcects to define
+ * it.
+ *
+ * @param invoker the invoker to remove the command from
+ */
+
+ protected pointcut removeCommandTrigger(CommandInvoker invoker);
+
+ /**
+ * Calls <code>removeCommand()</code> when a command should be removed.
+ *
+ * @param invoker the invoker to remove the command from
+ */
+
+ after(CommandInvoker invoker): removeCommandTrigger(invoker) {
+ if (invoker != null) {
+ removeCommand(invoker);
+ } else {
+ // If the invoker is null, the command cannot be removed.
+ // Either ignore this case or throw an exception
+ }
+ }
+
+////////////////////////////////////////////
+// Command default method implementations //
+////////////////////////////////////////////
+
+ /**
+ * Provides a deault implementation for the isExecutable method defined
+ * in the Command interface.
+ *
+ * @return true (default implementation). Can be overwritten by concrete
+ * aspects or even concrete commands.
+ */
+
+ public boolean Command.isExecutable() {
+ return true;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandReceiver.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandReceiver.java
new file mode 100644
index 000000000..0a7f8e458
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CommandReceiver.java
@@ -0,0 +1,39 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * This interface is used by extending aspects to say what types
+ * can be Receivers (i.e. manipulated by a command object receiving an
+ * executeCommand() call).
+ * This role is assigned by concrete sub-aspects of the <code>CommandProtocol
+ * </code> pattern aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ *
+ * @see CommandProtocol
+ */
+
+public interface CommandReceiver { } \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CompositeProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CompositeProtocol.java
new file mode 100644
index 000000000..bab9e74dc
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/CompositeProtocol.java
@@ -0,0 +1,209 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Enumeration;
+import java.util.WeakHashMap;
+import java.util.Vector;
+
+/**
+ * Defines the abstract Composite design pattern.<p>
+ *
+ * It maintains the mapping between composites and their children, defines the
+ * Component, Composite, and Leaf roles, and implements facilities to
+ * implements methods that work on the whole aggregate structure.
+ *
+ * <p><i>This is the AspectJ version.</i><p>
+ *
+ * Each concrete subaspect does the following things: <UL>
+ * <LI> Defines which classes are Components and Leafs
+ * <LI> (optional) Defines methods that operate on the whole aggregate
+ * structure (using visitors)
+ * </UL>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/06/04
+ */
+
+public abstract aspect CompositeProtocol {
+
+ /**
+ * Defines the Component role. The role is public to allow clients to
+ * handle objects of that type.
+ */
+
+ public interface Component {}
+
+ /**
+ * Defines the Composite role. Composites are Components that can have
+ * children. This role is only used within the pattern context, thus it
+ * is protected.
+ */
+
+ protected interface Composite extends Component {}
+
+ /**
+ * Defines the Leaf role. Leafs are Components that can not have
+ * children. This role is only used within the pattern context, thus it
+ * is protected.
+ */
+
+ protected interface Leaf extends Component {}
+
+ /**
+ * stores the mapping between components and their children
+ */
+
+ private WeakHashMap perComponentChildren = new WeakHashMap();
+
+ /**
+ * Returns a vector of the children of the argument component
+ */
+
+ private Vector getChildren(Component s) {
+ Vector children = (Vector)perComponentChildren.get(s);
+ if ( children == null ) {
+ children = new Vector();
+ perComponentChildren.put(s, children);
+ }
+ return children;
+ }
+
+ /**
+ * Client-accessible method to add a new child to a composite
+ *
+ * @param composite the composite to add a new child to
+ * @param component the new child to add
+ */
+
+ public void addChild(Composite composite, Component component) {
+ getChildren(composite).add(component);
+ }
+
+ /**
+ * Client-accessible method to remove a child from a composite
+ *
+ * @param composite the composite to remove a child from
+ * @param component the child to remove
+ */
+
+ public void removeChild(Composite composite, Component component) {
+ getChildren(composite).remove(component);
+ }
+
+ /**
+ * Client-accessible method to get an Enumeration of all children of
+ * a composite
+ *
+ * @param composite the composite to add a new child to
+ * @param component the new child to add
+ */
+
+ public Enumeration getAllChildren(Component c) {
+ return getChildren(c).elements();
+ }
+
+
+
+ /**
+ * Defines an interface for visitors that operate on the composite
+ * structure. These visitors are implemented by concrete sub-aspects
+ * and used in the <code>recurseOperation(Component, Visitor)</code>
+ * method. This construct is needed to allow for method forwarding:
+ * A composite that receives a method forwards the request to all its
+ * children.
+ */
+
+ protected interface Visitor {
+
+ /**
+ * Generic method that performs an unspecified operation on compoennts
+ *
+ * @param c the component to perform the operation on
+ */
+
+ public void doOperation(Component c);
+ }
+
+ /**
+ * Implements the method-forwarding logic: If a method is to be applied
+ * to the aggregate structure, each composite forwards it to its children
+ *
+ * @param c the current component
+ * @param v the visitor representing the operation to be performed
+ */
+
+ public void recurseOperation(Component c, Visitor v) { // This implements the logic that Composites forward
+ for (Enumeration enum = getAllChildren(c); enum.hasMoreElements(); ) { // method calls to their children
+ Component child = (Component) enum.nextElement();
+ v.doOperation(child);
+ }
+ }
+
+
+
+ /**
+ * Defines an interface for visitors that operate on the composite
+ * structure. These visitors are implemented by comcrete sub-aspects
+ * and used in the <code>recurseOperation(Component, Visitor)<>/code>
+ * method. This construct is needed to allow for method forwarding:
+ * A composite that receives a method forwards the request to all its
+ * children. <p>
+ *
+ * This version allows for a return value of Object type. For some odd
+ * reason AJDT complains if this type is declared protected (as it should
+ * be). Note that Visitor above works fine as protected.
+ */
+
+ public interface FunctionVisitor {
+
+ /**
+ * Generic method that performs an unspecified operation on components
+ *
+ * @param c the component to perform the operation on
+ */
+
+ public Object doFunction(Component c);
+ }
+
+ /**
+ * Implements the method-forwarding logic: If a method is to be applied
+ * to the aggregate structure, each composite forwards it to its children.
+ * This version allows for a return value of Object type, effectively
+ * enableing collecting aggregate results on the composite structure.
+ *
+ * @param c the current component
+ * @param fv the visitor representing the operation to be performed
+ */
+
+ public Enumeration recurseFunction(Component c, FunctionVisitor fv) {
+ Vector results = new Vector();
+ for (Enumeration enum = getAllChildren(c); enum.hasMoreElements(); ) { // method calls to their children
+ Component child = (Component) enum.nextElement();
+ results.add(fv.doFunction(child));
+ }
+ return results.elements();
+ }
+}
+
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/FlyweightProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/FlyweightProtocol.java
new file mode 100644
index 000000000..9092d9675
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/FlyweightProtocol.java
@@ -0,0 +1,83 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Implements a the abstracted Flyweight design pattern. Included is the
+ * general creation-on-demand logic. Concrete subaspects are used to
+ * defines the actual <i>FlyweightFactories</i>.
+ *
+ * Concrete subaspects need only to assign the flyweight roles and to
+ * overwrite the <code>createFlyweight(Object)<code> method.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/11/04
+ */
+
+public abstract aspect FlyweightProtocol {
+
+ /**
+ * stores the existing <i>Flyweight</i> by key
+ */
+
+ private Hashtable flyweights = new Hashtable();
+
+ /**
+ * defines the <i>Flyweight</i> role.
+ */
+
+ protected interface Flyweight{};
+
+ /**
+ * Creates a <i>Flyweight</i> for a given key. This method is called by
+ * <code>getFlyweight(Object)</code> if the flyweight does not already
+ * exist.
+ *
+ * @param key the key identifying the particular flyweight
+ * @return the <i>Flyweight</i> representing the key
+ */
+
+ protected abstract Flyweight createFlyweight(Object key);
+
+ /**
+ * Returns the <i>Flyweight</i> for a particular key.
+ * If the appropriate <i>Flyweight</i> does not yet exist, it is created
+ * on demand.
+ *
+ * @param key the key identifying the particular <i>Flyweight</i>
+ * @return the <i>Flyweight</i> representing the key
+ */
+
+ public Flyweight getFlyweight(Object key) {
+ if (flyweights.containsKey(key)) {
+ return (Flyweight) flyweights.get(key);
+ } else {
+ Flyweight flyweight = createFlyweight(key);
+ flyweights.put(key, flyweight);
+ return flyweight;
+ }
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MediatorProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MediatorProtocol.java
new file mode 100644
index 000000000..b676ed98b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MediatorProtocol.java
@@ -0,0 +1,143 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.WeakHashMap;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * Defines the general behavior of the Mediator design pattern.
+ *
+ * Each concrete sub-aspect of MediatorProtocol defines one kind of mediation
+ * relationship. Within that kind of relationship, there can be any number
+ * of <i>Colleague</i>s.
+ *
+ * The sub-aspect defines three things: <ol>
+ *
+ * <li> what types can be <i>Colleague</i>s and <i>Mediator</i> <br>
+ * this is done using <code>implements</code>
+ *
+ * <li> what operations on the <i>Colleague</i> trigger <i>Mediator</i>
+ * updates.<br>
+ * This is done by concretizing the <code>change(Colleague)</code>
+ * pointcut
+ *
+ * <li> how to mediate <br>
+ * this is done by concretizing
+ * <code>notifyMediator(Colleague, Mediator)</code>
+ * </ol>
+ *
+ * Note that in this implementation, the work of updating is a method
+ * on the sub-aspect, not a method introduced on the <i>Mediator</i>. This
+ * allows one class of object to be the <i>Mediator</i> in different kinds of
+ * mediation relationships, each of which has a different updating
+ * behavior.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public abstract aspect MediatorProtocol {
+
+
+ /**
+ * Declares the Colleague role.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ protected interface Colleague { }
+
+ /**
+ * Declares the <code>Mediator</code> role.
+ * Roles are modeled as (empty) interfaces.
+ */
+
+ protected interface Mediator { }
+
+ /**
+ * Stores the mapping between <i>Colleagues</i>s and <i>
+ * Mediator</i>s. For each <i>Colleague</i>, its <i>Mediator</i>
+ * is stored.
+ */
+
+ private WeakHashMap mappingColleagueToMediator = new WeakHashMap();
+
+
+ /**
+ * Returns the <i>Mediator</i> of
+ * a particular <i>Colleague</i>. Used internally.
+ *
+ * @param colleague the <i>Colleague</i> for which to return the mediator
+ * @return the <i>Mediator</i> of the <i>Colleague</i> in question
+ */
+
+ private Mediator getMediator(Colleague colleague) {
+ Mediator mediator =
+ (Mediator) mappingColleagueToMediator.get(colleague);
+ return mediator;
+ }
+
+ /**
+ * Sets the <i>Mediator</i> for a <i>Colleague</i>. This is a method
+ * on the pattern aspect, not on any of the participants.
+ *
+ * @param colleague the <i>Colleague</i> to set a new <i>Mediator</i> for
+ * @param mediator the new <i>Mediator</i> to set
+ */
+
+ public void setMediator(Colleague colleague, Mediator mediator) {
+ mappingColleagueToMediator.put(colleague, mediator);
+ }
+
+
+ /**
+ * Defines what changes on <i>Colleague</i>s cause their <i>Mediator</i>
+ * to be notified
+ *
+ * @param colleague the <i>Colleague</i> on which the change occured
+ */
+
+ protected abstract pointcut change(Colleague colleague);
+
+
+ /**
+ * Call updateObserver to update each observer.
+ */
+
+ after(Colleague c): change(c) {
+ notifyMediator(c, getMediator(c));
+ }
+
+ /**
+ * Defines how the <i>Mediator</i> is to be updated when a change
+ * to a <code>Colleague</code> occurs. To be concretized by sub-aspects.
+ *
+ * @param c the <i>Colleague</i> on which a change of interest occured
+ * @param m the <i>Mediator</i> to be notifed of the change
+ */
+
+ protected abstract void notifyMediator(Colleague c, Mediator m);
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Memento.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Memento.java
new file mode 100644
index 000000000..0acf0b5e5
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/Memento.java
@@ -0,0 +1,51 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Declares the methods for setting and getting the state for <i>Memento</i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public interface Memento {
+
+ /**
+ * Sets the state of this <i>Memento</i> give the passed state.
+ *
+ *
+ * @param state the state to store
+ */
+
+ public void setState(Object state);
+
+ /**
+ * Returns the state of this <i>Memento</i> give the passed originator.
+ *
+ * @return the state stored by this <i>Memento</i>
+ */
+
+ public Object getState();
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoException.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoException.java
new file mode 100644
index 000000000..8c361ed81
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoException.java
@@ -0,0 +1,46 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements an exception that occurs if an incorrect <i>Originator</i> is used
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ *
+ * @see MementoProtocol
+ */
+
+public class MementoException extends RuntimeException {
+
+ /**
+ * Creates a MementoException
+ *
+ * @param s the error message
+ */
+
+ public MementoException(String s) {
+ super(s);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoProtocol.java
new file mode 100644
index 000000000..7697a0f58
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/MementoProtocol.java
@@ -0,0 +1,65 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the abstract Memento design pattern. It defines the role of
+ * <i>Originator</i>. The <i>Memento</i> role is client-usable and as such
+ * defined outside this aspect.
+ *
+ * Concrete sub-aspects overwrite the two abstract methods to define how
+ * <i>Memento</i>s get generated and how they are used to restore the state
+ * of <i>Originator</i>s.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/12/04
+ */
+
+public abstract aspect MementoProtocol {
+
+ /**
+ * Defines the <i>Originator</i> type. Used only internally.
+ */
+
+ protected interface Originator {}
+
+ /**
+ * Creates a <i>Memento</i> object for an <i>Originator</i>
+ *
+ * @param o the <i>Originator</i> to create a <i>Memento</i> for
+ * @return the <i>Memento</i> storing the originator's state
+ */
+
+ public abstract Memento createMementoFor(Originator o);
+
+ /**
+ * Restores this <i>Originator</i> to a former state encapsulated in the
+ * <i>Memento</i> passed
+ *
+ * @param o the <i>Originator</i> to restore
+ * @param m the <i>Memento</i> that stores the prior state
+ */
+
+ public abstract void setMemento(Originator o, Memento m);
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ObserverProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ObserverProtocol.java
new file mode 100644
index 000000000..da403022b
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ObserverProtocol.java
@@ -0,0 +1,168 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.WeakHashMap;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * Defines the general behavior of the Observer design pattern.
+ *
+ * Each concrete sub-aspect of ObserverProtocol defines one kind of observing
+ * relationship. Within that kind of relationship, there can be any number
+ * of <i>Subject</i>s, each with any number of <i>Observer</i>s.
+ *
+ * The sub-aspect defines three things: <ol>
+ *
+ * <li> what types can be <i>Subject</i>s or observers <br>
+ * this is done using +implements
+ *
+ * <li> what operations on the <i>Subject</i> require updating the observers <br>
+ * this is done by concretizing the changes(Subject) pointcut
+ *
+ * <li> how to update the observers <br>
+ * this is done by defining a method on
+ * updateObserver(Subject, Observer)
+ * </ol>
+ *
+ * Note that in this implementation, the work of updating is a method
+ * on the sub-aspect, not a method introduced on the observer. This
+ * allows one class of object to be the observer in different kinds of
+ * observing relationships, each of which has a different updating
+ * behavior. For observers that just have a single generic update
+ * behavior, the method on updateObserver will just be a simple call
+ * that generic updater.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public abstract aspect ObserverProtocol {
+
+
+ /**
+ * This interface is used by extending aspects to say what types
+ * can be <i>Subject</i>s. It models the <i>Subject</i> role.
+ */
+
+ protected interface Subject { }
+
+
+ /**
+ * This interface is used by extending aspects to say what types
+ * can be <i>Observer</i>s. It models the <i>Observer</i> role.
+ */
+
+ protected interface Observer { }
+
+
+ /**
+ * Stores the mapping between <i>Subject</i>s and <i>
+ * Observer</i>s. For each <i>Subject</i>, a <code>LinkedList</code>
+ * is of its <i>Observer</i>s is stored.
+ */
+
+ private WeakHashMap perSubjectObservers;
+
+
+ /**
+ * Returns a <code>Collection</code> of the <i>Observer</i>s of
+ * a particular subject. Used internally.
+ *
+ * @param subject the <i>subject</i> for which to return the <i>Observer</i>s
+ * @return a <code>Collection</code> of s's <i>Observer</i>s
+ */
+
+ protected List getObservers(Subject subject) {
+ if (perSubjectObservers == null) {
+ perSubjectObservers = new WeakHashMap();
+ }
+ List observers = (List)perSubjectObservers.get(subject);
+ if ( observers == null ) {
+ observers = new LinkedList();
+ perSubjectObservers.put(subject, observers);
+ }
+ return observers;
+ }
+
+
+ /**
+ * Adds an <i>Observer</i> to a <i>Subject</i>. This is the equivalent of <i>
+ * attach()</i>, but is a method on the pattern aspect, not the
+ * <i>Subject</i>.
+ *
+ * @param s the <i>Subject</i> to attach a new <i>Observer</i> to
+ * @param o the new <i>Observer</i> to attach
+ */
+
+ public void addObserver(Subject subject, Observer observer) {
+ getObservers(subject).add(observer);
+ }
+
+ /**
+ * Removes an observer from a <i>Subject</i>. This is the equivalent of <i>
+ * detach()</i>, but is a method on the pattern aspect, not the <i>Subject</i>.
+ *
+ * @param s the <i>Subject</i> to remove the <i>Observer</i> from
+ * @param o the <i>Observer</i> to remove
+ */
+
+ public void removeObserver(Subject subject, Observer observer) {
+ getObservers(subject).remove(observer);
+ }
+
+ /**
+ * The join points after which to do the update.
+ * It replaces the normally scattered calls to <i>notify()</i>. To be
+ * concretized by sub-aspects.
+ */
+
+ protected abstract pointcut subjectChange(Subject s);
+
+ /**
+ * Calls <code>updateObserver(..)</code> after a change of interest to
+ * update each <i>Observer</i>.
+ *
+ * @param subject the <i>Subject</i> on which the change occured
+ */
+
+ after(Subject subject): subjectChange(subject) {
+ Iterator iter = getObservers(subject).iterator();
+ while ( iter.hasNext() ) {
+ updateObserver(subject, ((Observer)iter.next()));
+ }
+ }
+
+ /**
+ * Defines how each <i>Observer</i> is to be updated when a change
+ * to a <i>Subject</i> occurs. To be concretized by sub-aspects.
+ *
+ * @param subject the <i>Subject</i> on which a change of interest occured
+ * @param observer the <i>Observer</i> to be notifed of the change
+ */
+
+ protected abstract void updateObserver(Subject subject, Observer observer);
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/PrototypeProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/PrototypeProtocol.java
new file mode 100644
index 000000000..79ef7cd56
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/PrototypeProtocol.java
@@ -0,0 +1,91 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the abstract Prototype design pattern. It attaches a default
+ * <code>clone()</code> method on all <i>Prototype</i> participants and
+ * provides a static <code>cloneObject(Prototype)</clone> method. The default
+ * implementation of that method is to try to use the <code>clone()</code>
+ * method and, failing that, to call its protected <code>
+ * createCloneFor(Prototype)</code> method. Concrete subaspects can either
+ * overwrite none or one (or both) of the methods to tailor their
+ * particular design pattern instance to its individual needs
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/13/04
+ */
+
+public abstract aspect PrototypeProtocol {
+
+ /**
+ * Defines the <i>Prototype</i> role.
+ */
+
+ protected interface Prototype {}
+
+ /**
+ * Attaches a default <code>clone()</code> method to all prototypes.
+ * This makes use of Java's clone() mechanism that creates a deep copy
+ * of the object in question.
+ *
+ * @return a copy of the object
+ */
+
+ public Object Prototype.clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ /**
+ * Provides a static default aspect method for cloning prototypes.
+ * It uses the attached clone() method if possible. If not, it calls the
+ * static <code>createCloneFor(Prototype)</code> method.
+ *
+ * @param object the prototype object to clone
+ * @return a copy of the object
+ */
+
+
+ public Object cloneObject(Prototype object) {
+ try {
+ return object.clone();
+ } catch (CloneNotSupportedException ex) {
+ return createCloneFor(object);
+ }
+ }
+
+ /**
+ * Provides an alternative method for cases when the default
+ * <code>clone()</code> method fails. This method can be
+ * overwritten by concrete subaspects. In this default implementation
+ * it return null.
+ *
+ * @param object the prototype object to clone
+ * @return a copy of the object, but null in this case
+ */
+
+ protected Object createCloneFor(Prototype object) {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ProxyProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ProxyProtocol.java
new file mode 100644
index 000000000..856a681a9
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/ProxyProtocol.java
@@ -0,0 +1,115 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * Defines the abstracted Proxy design pattern.<p>
+ *
+ * Concrete sub-aspects define the following: <UL>
+ * <LI> Which class(es) are <i>RealSubject</i>s
+ * <LI> Which requests need to be handled by the <i>Proxy</i>
+ * (methods, field accesses)
+ * <LI> What to return in case of a proxy-covered
+ * access to a method.
+ * </UL>
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public abstract aspect ProxyProtocol {
+
+ /**
+ * Defines the Subject role (used for correct typing)
+ */
+
+ protected interface Subject {}
+
+ /**
+ * Captures all accesses to the subject that should be covered by
+ * this pattern instance.
+ */
+
+ protected abstract pointcut requests();
+
+ /**
+ * Extends the <code>requests()</code> pointcut to include a
+ * field for the joinpoint. Used internally only.
+ */
+
+ private pointcut requestsByCaller(Object caller):
+ requests() && this(caller);
+
+ /**
+ * Intercepts accesses to protected parts of the OutputSubject.
+ * If access is proxy protected, the method
+ * <code>handleProxyProtection(..)</code> is called instead.
+ *
+ * @param caller the object responsible for the protected access
+ * @param subject the subject receiving the call
+ */
+
+ Object around(Object caller, Subject subject):
+ requestsByCaller(caller) && target(subject) {
+
+ if (! isProxyProtected(caller, subject, thisJoinPoint) )
+ return proceed(caller, subject);
+ return handleProxyProtection(caller, subject, thisJoinPoint);
+ }
+
+ /**
+ * Checks whether the request should be handled by the Proxy or not
+ *
+ * @param caller the object responsible for the protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the protected access
+ *
+ * @return true if the access is covered by the proxy, false otherwise
+ */
+
+ protected abstract boolean isProxyProtected(Object caller,
+ Subject subject,
+ JoinPoint joinPoint);
+
+ /**
+ * For delegation: Provides an alternative return value if access
+ * is proxy protected. A default implementation is supplied so that
+ * concrete subaspects are not forced to implement the method.
+ *
+ * @param caller the object responsible for the proxy protected access
+ * @param subject the subject receiving the call
+ * @param joinPoint the joinpoint associated with the proxy protected
+ * access
+ *
+ * @return an alternative return value
+ */
+
+ protected Object handleProxyProtection(Object caller,
+ Subject subject,
+ JoinPoint joinPoint) {
+ return null;
+ }
+}
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/SingletonProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/SingletonProtocol.java
new file mode 100644
index 000000000..fddd603da
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/SingletonProtocol.java
@@ -0,0 +1,93 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Defines the general behavior of the Singleton design pattern.
+ *
+ * Each concrete sub-aspect of SingletonProtocol defines the Singleton
+ * property for one or more types.
+ *
+ * The sub-aspect defines two things: <ol>
+ *
+ * <li> what types are <i>Singleton</i> <br>
+ *
+ * <li> what classes can access the <i>Singleton</i>'s constructor (if any)
+ * despite its property
+ * </ol>
+ *
+ * for this implementation we choose to illustrate that it is not necessary
+ * to provide a factory method for accessing the <i>Singleton</i>
+ * instance (like <i>getSingleton()</i>). The regular
+ * constructor may be used instead.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/18/04
+ */
+
+public abstract aspect SingletonProtocol {
+
+ /**
+ * stores the <i>Singleton</i> instances
+ */
+
+ private Hashtable singletons = new Hashtable();
+
+ /**
+ * Defines the <i>Singleton</i> role. It is realized as <code>public
+ * </code> to allow for more flexibility (i.e., alternatively, types
+ * can just themselves declare that they implement the interface to
+ * aquire the <i>Singleton</i> property.
+ */
+
+ public interface Singleton {}
+
+ /**
+ * Placeholder for exceptions to the <i>Singleton</i>'s constructor
+ * protection. For example, non-singleton subclasses may need to
+ * access the protected constructor of the <i>Singleton</i> normally.
+ *
+ * An alternative implementation would be to define an interface
+ * for singleton exceptions similar to the one above.
+ */
+
+ protected pointcut protectionExclusions();
+
+ /**
+ * Protects the <i>Singleton</i>'s constructor. Creates the unique
+ * instance on demant and returns it instead of a new object.
+ *
+ * @return the singleton instance
+ */
+
+ Object around(): call((Singleton+).new(..)) && !protectionExclusions() {
+ Class singleton = thisJoinPoint.getSignature().getDeclaringType();
+ if (singletons.get(singleton) == null) { // How to access the static instance variable here?
+ singletons.put(singleton, proceed());
+ }
+ return singletons.get(singleton);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/StrategyProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/StrategyProtocol.java
new file mode 100644
index 000000000..8ce60f4fc
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/StrategyProtocol.java
@@ -0,0 +1,87 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+import java.util.Hashtable;
+
+/**
+ * Implements the the abstract Strategy design pattern protocol<p>
+ *
+ * Defines the <i>Strategy</i> and <i>Context</i> role. Also provides
+ * methods for setting and retrieving the <i>Strategy</i> for a
+ * given <i>Context</i>.
+ *
+ * It is also possible (although not shown here) to provide abstract
+ * pointcust for setting or removing <i>Strategy</i>s from
+ * <i>Context</>s. This would allow <i>Client</i> implementations
+ * to be free of pattern code. For an example of how to do that,
+ * see the implementation of the abstract CommandProtocol aspect.
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+
+
+public abstract aspect StrategyProtocol {
+
+ /**
+ * Stores the current strategy for each context
+ *
+ * @param numbers the int array to sort
+ */
+ Hashtable strategyPerContext = new Hashtable();
+
+ /**
+ * Defines the <i>Strategy</i> role
+ */
+
+ protected interface Strategy { }
+
+ /**
+ * Defines the <i>Context</i> role
+ */
+
+ protected interface Context { }
+
+ /**
+ * Sets the strategy for a given context
+ *
+ * @param c the context to set the strategy for
+ * @param s the new strategy
+ */
+ public void setConcreteStrategy(Context c, Strategy s) {
+ strategyPerContext.put(c, s);
+ }
+
+ /**
+ * Returns the strategy for a given context
+ *
+ * @param c the context object
+ * @return the strategy object for that context
+ */
+ public Strategy getConcreteStrategy(Context c) {
+ return (Strategy) strategyPerContext.get(c);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/VisitorProtocol.java b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/VisitorProtocol.java
new file mode 100644
index 000000000..b1c30546c
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/VisitorProtocol.java
@@ -0,0 +1,130 @@
+package ca.ubc.cs.spl.aspectPatterns.patternLibrary;
+
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * This file is part of the design patterns project at UBC
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is ca.ubc.cs.spl.aspectPatterns.
+ *
+ * For more details and the latest version of this code, please see:
+ * http://www.cs.ubc.ca/labs/spl/projects/aodps.html
+ *
+ * Contributor(s):
+ */
+
+/**
+ * Implements the abstracted Visitor design pattern.<p>
+ *
+ * Intent: <i>Represents an operation to be performed on the elements of an
+ * object structure. Visitor lets you define a new operation without changing
+ * the classes of the elements on which it operates</i><p>
+ *
+ * Note that this implementation only deals with two different kind of nodes:
+ * terminal and non-terminal nodes. In cases where the aggregate structure
+ * contains more types of nodes, this aspect cannot be used without
+ * modifications. <p>
+ *
+ * Note further that whenever the aggregate structure is unimportant, the
+ * additional functionality can be added in a much sipmler using
+ * AspectJ's open classes mechanism (i.e., by using inter-type declarations
+ * to implement the desired functionality).
+ *
+ * @author Jan Hannemann
+ * @author Gregor Kiczales
+ * @version 1.1, 02/17/04
+ */
+
+public abstract aspect VisitorProtocol {
+
+ /**
+ * Defines the <i>Element</i> role. The inerface is public so that
+ * <i>ConcreteVisitor</i>s can use the type.
+ */
+
+ public interface VisitableNode {}
+
+ /**
+ * Defines a <i>ConcreteElement</i> role for non-terminal nodes in
+ * a binary tree structure. The interface is protected as it is only used
+ * by concrete subaspects.
+ */
+
+ protected interface Node extends VisitableNode {}
+
+ /**
+ * Defines a <i>ConcreteElement</i> role for terminal nodes in
+ * a tree structure. The inerface is protected as it is only used
+ * by concrete subaspects.
+ */
+
+ protected interface Leaf extends VisitableNode {}
+
+ /**
+ * This interface is implemented by <i>ConcreteVisitor</i>s.
+ */
+
+ public interface Visitor {
+
+ /**
+ * Defines a method signature for visiting regular nodes.
+ *
+ * @param node the regular node to visit
+ */
+
+ public void visitNode(VisitableNode node);
+
+ /**
+ * Defines a method signature for visiting leaf nodes.
+ *
+ * @param node the leaf node to visit
+ */
+
+ public void visitLeaf(VisitableNode node);
+
+ /**
+ * Defines a method signature for returning the visitor's results
+ *
+ * @param node a string containig the visitor's results
+ */
+
+ public String report();
+ }
+
+ /**
+ * Declares <code>accept(..)</code> for visitable nodes
+ *
+ * @param visitor the visitor that is to be accepted
+ */
+
+ public void VisitableNode.accept(Visitor visitor) {}
+
+ /**
+ * Declares <code>accept(..)</code> for regular nodes
+ *
+ * @param visitor the visitor that is to be accepted
+ */
+
+ public void Node.accept(Visitor visitor) {
+ visitor.visitNode(this);
+ }
+
+ /**
+ * Declares <code>accept(..)</code> for leaf nodes
+ *
+ * @param visitor the visitor that is to be accepted
+ */
+
+ public void Leaf.accept(Visitor visitor) {
+ visitor.visitLeaf(this);
+ }
+} \ No newline at end of file
diff --git a/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/build-lib.lst b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/build-lib.lst
new file mode 100644
index 000000000..ba39bf644
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/ca/ubc/cs/spl/aspectPatterns/patternLibrary/build-lib.lst
@@ -0,0 +1,5 @@
+-outjar
+lib.jar
+-sourceroots
+.
+
diff --git a/docs/sandbox/ubc-design-patterns/src/tut-all.lst b/docs/sandbox/ubc-design-patterns/src/tut-all.lst
new file mode 100644
index 000000000..8b16e3479
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/tut-all.lst
@@ -0,0 +1,253 @@
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\AbstractFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\AbstractFactoryEnhancement.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\Display.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\FramedFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\aspectj\RegularFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\java\AbstractFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\java\Display.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\java\FramedFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\abstractFactory\java\RegularFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\aspectj\PrinterAdapter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\aspectj\SystemOutPrinter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\aspectj\Writer.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\java\PrinterAdapter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\java\SystemOutPrinter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\adapter\java\Writer.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\AbstractionImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\CrossCapitalImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\GreetingScreen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\InformationScreen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\Screen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\ScreenImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\aspectj\StarImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\CrossCapitalImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\GreetingScreen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\InformationScreen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\Screen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\ScreenImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\bridge\java\StarImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\aspectj\Creator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\aspectj\CreatorImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\aspectj\TextCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\aspectj\XMLCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\java\Creator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\java\TextCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\builder\java\XMLCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\Click.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\ClickChain.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\Frame.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\aspectj\Panel.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\Click.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\ClickHandler.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\Frame.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\chainOfResponsibility\java\Panel.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\ButtonCommand.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\ButtonCommand2.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\ButtonCommanding.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\aspectj\Printer.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\java\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\java\ButtonCommand.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\java\ButtonCommand2.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\java\Command.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\command\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\aspectj\Directory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\aspectj\File.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\aspectj\FileSystemComposition.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\java\Directory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\java\File.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\java\FileSystemComponent.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\composite\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\aspectj\BracketDecorator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\aspectj\ConcreteOutput.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\aspectj\StarDecorator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\BracketDecorator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\ConcreteOutput.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\Output.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\OutputDecorator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\decorator\java\StarDecorator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\java\Decoration.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\java\OutputFacade.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\java\RegularScreen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\facade\java\StringTransformer.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\aspectj\ButtonCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\aspectj\CreatorImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\aspectj\GUIComponentCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\aspectj\LabelCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\java\ButtonCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\java\GUIComponentCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\java\LabelCreator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\factoryMethod\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\aspect\CharacterFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\aspect\FlyweightImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\aspect\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\aspect\PrintableFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\aspect\WhitespaceFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\java\CharacterFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\java\PrintableFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\java\PrintableFlyweightFactory.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\flyweight\java\WhitespaceFlyweight.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\AndExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\BooleanConstant.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\BooleanExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\BooleanInterpretation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\ExpressionException.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\NotExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\OrExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\VariableContext.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\aspectj\VariableExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\AndExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\BooleanConstant.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\BooleanExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\ExpressionException.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\NotExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\OrExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\VariableContext.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\interpreter\java\VariableExpression.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\aspectj\OpenList.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\aspectj\OpenListIteration.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\aspectj\SimpleList.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\java\OpenList.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\java\ReverseIterator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\iterator\java\SimpleList.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\aspectj\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\aspectj\Label.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\aspectj\MediatorImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\java\Button.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\java\GUIColleague.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\java\GUIMediator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\java\Label.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\mediator\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\aspectj\Counter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\aspectj\CounterMemento.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\java\Counter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\java\CounterMemento.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\memento\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\ColorObserver.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\CoordinateObserver.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\Point.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\Screen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\aspectj\ScreenObserver.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\java\ChangeObserver.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\java\ChangeSubject.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\java\Point.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\observer\java\Screen.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\aspectj\StringPrototypeA.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\aspectj\StringPrototypeB.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\aspectj\StringPrototypes.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\java\StringPrototypeA.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\prototype\java\StringPrototypeB.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\AlternateOutputImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\OutputImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\RequestBlocking.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\RequestCounting.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\aspectj\RequestDelegation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\java\OutputImplementation.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\java\OutputSubject.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\java\RequestBlocker.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\proxy\java\RequestCounter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\aspectj\Printer.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\aspectj\PrinterSubclass.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\aspectj\SingletonInstance.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\java\PrinterSingleton.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\singleton\java\PrinterSubclass.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\Queue.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\QueueEmpty.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\QueueFull.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\QueueNormal.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\QueueState.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\aspectj\QueueStateAspect.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\Queue.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\QueueContext.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\QueueEmpty.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\QueueFull.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\QueueNormal.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\state\java\QueueState.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\aspectj\BubbleSort.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\aspectj\LinearSort.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\aspectj\Sorter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\aspectj\SortingStrategy.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\java\BubbleSort.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\java\LinearSort.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\java\Sorter.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\strategy\java\SortingStrategy.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\aspectj\DecoratedStringGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\aspectj\FancyGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\aspectj\Generating.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\aspectj\SimpleGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\java\DecoratedStringGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\java\FancyGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\templateMethod\java\SimpleGenerator.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\BinaryTreeLeaf.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\BinaryTreeNode.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\SummationVisitor.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\TraversalVisitor.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\Visitable.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\aspectj\Visiting.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\BinaryTreeLeaf.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\BinaryTreeNode.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\BinaryTreeVisitor.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\Main.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\SummationVisitor.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\TraversalVisitor.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\examples\visitor\java\Visitable.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\ChainOfResponsibilityException.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\ChainOfResponsibilityProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\Command.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\CommandInvoker.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\CommandProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\CommandReceiver.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\CompositeProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\FlyweightProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\MediatorProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\Memento.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\MementoException.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\MementoProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\ObserverProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\PrototypeProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\ProxyProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\SingletonProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\StrategyProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\patternLibrary\VisitorProtocol.java
+c:\home\ws\main\os-aj-hanneman-2004\src\ca\ubc\cs\spl\aspectPatterns\testCenter\TestCenter.java
diff --git a/docs/sandbox/ubc-design-patterns/src/tut-source.lst b/docs/sandbox/ubc-design-patterns/src/tut-source.lst
new file mode 100644
index 000000000..9607e3545
--- /dev/null
+++ b/docs/sandbox/ubc-design-patterns/src/tut-source.lst
@@ -0,0 +1,5 @@
+-sourceroots
+.
+-aspectpath
+../../../patternLibrary/lib.jar
+