Source Code Cross Referenced for AbstractFactory.java in  » Testing » KeY » de » uka » ilkd » key » casetool » patternimplementor » patterns » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » KeY » de.uka.ilkd.key.casetool.patternimplementor.patterns 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        //
009:        //
010:
011:        package de.uka.ilkd.key.casetool.patternimplementor.patterns;
012:
013:        import de.uka.ilkd.key.casetool.patternimplementor.*;
014:
015:        public class AbstractFactory implements  AbstractPatternImplementor {
016:            private PIParameterGroup abstractFactory;
017:            private ConstraintMechanism constraintMechanism;
018:
019:            public PIParameterGroup getParameters() {
020:                if (abstractFactory == null) {
021:                    createParameters();
022:                }
023:
024:                return abstractFactory;
025:            }
026:
027:            /*public AbstractFactory()
028:            {
029:
030:                    createParameters();
031:            }*/
032:            protected void createParameters() {
033:                abstractFactory = new PIParameterGroup(
034:                        "AbstractFactoryPattern", "Abstract Factory Pattern");
035:
036:                PIParameterString af = new PIParameterString("AbstractFactory",
037:                        "Abstract factory", "AbstractFactory");
038:                PIParameterMultiString ap = new PIParameterMultiString(
039:                        "AbstractProduct", "Abstract products",
040:                        "AbstractProduct");
041:                PIParameterMultiString cf = new PIParameterMultiString(
042:                        "ConcreteFactory", "Concrete factories",
043:                        "ConcreteFactory1 ConcreteFactory2");
044:                PIParameterDependent cp = new PIParameterDependent(
045:                        "ConcreteProduct", "Concrete products", cf);
046:
047:                abstractFactory.add(af);
048:                abstractFactory.add(ap);
049:                abstractFactory.add(cf);
050:                abstractFactory.add(cp);
051:                constraintMechanism = new ConstraintMechanism(
052:                        "AbstractFactory.constraints", abstractFactory, this );
053:
054:                /*System.out.println("abstractFactory {");
055:                System.out.println(abstractFactory);
056:                System.out.println("}");*/
057:            }
058:
059:            /*public void createAbstractFactoryDialog() {
060:                    JDialog jd = new JDialog();
061:                    jd.setContentPane(new PIParameterGUIGroup(abstractFactory));
062:                    jd.pack();
063:                    jd.setVisible(true);
064:            }*/
065:            private SourceCode createConcreteFactory() {
066:                String af = abstractFactory.get("AbstractFactory").getValue();
067:                String[] cf = ((PIParameterMultiString) abstractFactory
068:                        .get("ConcreteFactory")).getValues();
069:                String[] ap = ((PIParameterMultiString) abstractFactory
070:                        .get("AbstractProduct")).getValues();
071:                String[][] cps = ((PIParameterGroup) abstractFactory
072:                        .get("ConcreteProduct")).getValues();
073:
074:                SourceCode source = new SourceCode();
075:
076:                for (int i = 0; i < cf.length; i++) {
077:                    source.beginClass(cf[i]);
078:                    source.add("/**");
079:                    source.add(constraintMechanism.getConstraints(" * ",
080:                            "ConcreteFactory", cf[i]));
081:                    source.add(" */");
082:                    source.add("public class " + cf[i] + " extends " + af
083:                            + " {");
084:
085:                    // fulhack?
086:                    for (int j = 0; j < Math.min(ap.length, cps[i].length); j++) {
087:                        source.add("\t/**");
088:                        source.add(constraintMechanism.getConstraints("\t * ",
089:                                "ConcreteFactory::createProduct", cf[i] + "::"
090:                                        + cps[i][j]));
091:                        source.add("\t */");
092:                        source.add("\tpublic " + ap[j] + " Create" + ap[j]
093:                                + "() {");
094:                        source.add("\t\treturn new " + cps[i][j] + "();");
095:                        source.add("\t}");
096:                    }
097:
098:                    source.add("}");
099:                }
100:
101:                return source;
102:            }
103:
104:            private SourceCode createConcreteProducts() {
105:                String[] ap = ((PIParameterMultiString) abstractFactory
106:                        .get("AbstractProduct")).getValues();
107:                String[][] cps = ((PIParameterGroup) abstractFactory
108:                        .get("ConcreteProduct")).getValues();
109:
110:                //SourceCode classes = new SourceCode();
111:                SourceCode source = new SourceCode();
112:
113:                for (int j = 0; j < cps.length; j++) {
114:                    //Property cp = (Property)concreteProducts.elementAt(j);
115:                    for (int i = 0; i < Math.min(ap.length, cps[j].length); i++) {
116:                        //SourceCode source = new SourceCode();
117:                        source.beginClass(cps[j][i]);
118:                        source.add("/**");
119:                        source.add(constraintMechanism.getConstraints(" * ",
120:                                "ConcreteProduct", cps[j][i]));
121:                        source.add(" */");
122:
123:                        source.add("public class " + cps[j][i] + " extends "
124:                                + ap[i] + " {");
125:                        source.add("}");
126:
127:                        //classes.add(source);
128:                    }
129:                }
130:
131:                return source; //classes;
132:            }
133:
134:            private SourceCode createAbstractProducts() {
135:                String[] ap = ((PIParameterMultiString) abstractFactory
136:                        .get("AbstractProduct")).getValues();
137:
138:                //SourceCode classes = new SourceCode();
139:                SourceCode source = new SourceCode();
140:
141:                for (int i = 0; i < ap.length; i++) {
142:                    //SourceCode source = new SourceCode();
143:                    source.beginClass(ap[i]);
144:                    source.add("/**");
145:                    source.add(constraintMechanism.getConstraints(" * ",
146:                            "AbstractProduct", ap[i]));
147:                    source.add(" */");
148:                    source.add("public class " + ap[i] + " {");
149:                    source.add("}");
150:
151:                    //classes.add(source);
152:                }
153:
154:                return source;
155:
156:                //return classes;
157:            }
158:
159:            private SourceCode createAbstractFactory() {
160:                String af = abstractFactory.get("AbstractFactory").getValue();
161:                String[] ap = ((PIParameterMultiString) abstractFactory
162:                        .get("AbstractProduct")).getValues();
163:
164:                SourceCode source = new SourceCode();
165:                source.beginClass(af);
166:                source.add("/**");
167:                source.add(constraintMechanism.getConstraints(" * ",
168:                        "AbstractFactory", af));
169:                source.add(" */");
170:                source.add("public abstract class " + af + " {");
171:
172:                for (int i = 0; i < ap.length; i++) {
173:                    String tmp = ap[i];
174:                    source.add("\t/**");
175:                    source.add(constraintMechanism
176:                            .getConstraints("\t * ",
177:                                    "AbstractFactory::createProduct", af + "::"
178:                                            + ap[i]));
179:                    source.add("\t */");
180:                    source.add("\tpublic abstract " + ap[i] + " Create" + tmp
181:                            + "();");
182:                }
183:
184:                source.add("}");
185:
186:                return source;
187:            }
188:
189:            public SourceCode getImplementation() {
190:                if (abstractFactory == null) {
191:                    System.err
192:                            .println("ERROR - AbstractFactory,getImplementor : abstractFactory == null");
193:
194:                    return null;
195:                }
196:
197:                SourceCode code = new SourceCode();
198:                code.add(createConcreteFactory());
199:                code.add(createConcreteProducts());
200:                code.add(createAbstractProducts());
201:                code.add(createAbstractFactory());
202:
203:                return code;
204:            }
205:
206:            public String getName() {
207:                return "Creational Patterns:Abstract Factory";
208:            }
209:        }
w__ww__.j_a_v_a2s_.c_o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.