public void assignAdaption() { boolean interfaceTarget = false; if (attemptedInterfaceMethods.size() > 0) { interfaceTarget = true; } for (int i = 0; i < attemptedInterfaceMethods.size(); i++) { if (!checkMethods.contains(attemptedInterfaceMethods.get(i))) { interfaceTarget = false; break; } } if (interfaceTarget) { if (!interfaces[0].replaceAll("/", ".").equals(this.param.replaceAll("/", "."))) { UMLMaker.addPattern( interfaces[0].replaceAll("/", "."), "target", "adapter", DesignParser.getCurrentClass()); UMLMaker.addPattern( DesignParser.getCurrentClass(), "adapter", "adapter", DesignParser.getCurrentClass()); UMLMaker.addPattern( this.param.replaceAll("/", "."), "adaptee", "adapter", DesignParser.getCurrentClass()); UMLMaker.addLabelledArrow( DesignParser.getCurrentClass(), interfaces[0].replaceAll("/", "."), "\\<\\<adapts\\>\\>"); } } else { boolean superTarget = false; if (attemptedMethods.size() > 0) { superTarget = true; } for (int i = 0; i < attemptedMethods.size(); i++) { if (!checkMethods.contains(attemptedMethods.get(i))) { superTarget = false; break; } } if (superTarget) { if (!this.nameOfSuper.equals(this.param.replaceAll("/", "."))) { UMLMaker.addPattern( this.nameOfSuper, "target", "adapter", DesignParser.getCurrentClass()); UMLMaker.addPattern( DesignParser.getCurrentClass(), "adapter", "adapter", DesignParser.getCurrentClass()); UMLMaker.addPattern(this.param, "adaptee", "adapter", DesignParser.getCurrentClass()); UMLMaker.addLabelledArrow( DesignParser.getCurrentClass(), this.nameOfSuper, "\\<\\<adapts\\>\\>"); } } } }
public static void main(String[] args) throws IOException { String[] arguments = { "problem.sprites.ISprite", "problem.client.AnimatorApp", "problem.graphics.AnimationPanel", "problem.graphics.MainWindow", "problem.sprites.AbstractSprite", "problem.sprites.CircleSprite", "problem.sprites.CompositeSprite", "problem.sprites.GuardedSnowmanSprite", "problem.sprites.RectangleSprite", "problem.sprites.SnowmanSprite", "problem.sprites.SpriteFactory" }; DesignParser.parse(arguments, "./output/sample_output.txt", "uml"); }