Source Code Cross Referenced for CreateBuilder.java in  » Testing » KeY » de » uka » ilkd » key » java » recoderext » 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.java.recoderext 
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:        // This file is part of KeY - Integrated Deductive Software Design
010:        // Copyright (C) 2001-2004 Universitaet Karlsruhe, Germany
011:        //                         Universitaet Koblenz-Landau, Germany
012:        //                         Chalmers University of Technology, Sweden
013:        //
014:        // The KeY system is protected by the GNU General Public License. 
015:        // See LICENSE.TXT for details.
016:        package de.uka.ilkd.key.java.recoderext;
017:
018:        import recoder.CrossReferenceServiceConfiguration;
019:        import recoder.java.Identifier;
020:        import recoder.java.StatementBlock;
021:        import recoder.java.declaration.ClassDeclaration;
022:        import recoder.java.declaration.MethodDeclaration;
023:        import recoder.java.declaration.TypeDeclaration;
024:        import recoder.java.declaration.modifier.Private;
025:        import recoder.java.expression.literal.BooleanLiteral;
026:        import recoder.java.expression.literal.IntLiteral;
027:        import recoder.java.reference.MethodReference;
028:        import recoder.java.reference.ThisReference;
029:        import recoder.java.reference.TypeReference;
030:        import recoder.java.statement.Return;
031:        import recoder.list.*;
032:
033:        /**
034:         * If an allocation expression <code>new Class(...)</code> occurs, a new object
035:         * has to be created, in KeY this is quite similar to take it out of a list of
036:         * objects and setting the implicit flag <code> &lt;created&gt; </code> to
037:         * <code>true</code> as well as setting all fields of the object to their
038:         * default values. For the complete procedure, the method creates the 
039:         * implicit method <code>&lt;createObject$gt;</code> which on its part calls
040:         * another implicit method <code>lt;prepare&gt;</code> for setting the fields
041:         * default values.
042:         */
043:        public class CreateBuilder extends RecoderModelTransformer {
044:
045:            public static final String IMPLICIT_CREATE = "<create>";
046:
047:            public CreateBuilder(CrossReferenceServiceConfiguration services,
048:                    CompilationUnitMutableList units) {
049:                super (services, units);
050:            }
051:
052:            /** 
053:             * Creates the body of the static <code>&lt;createObject&gt;</code>
054:             * method.
055:             */
056:            private StatementBlock createBody(ClassDeclaration recoderClass) {
057:
058:                StatementMutableList result = new StatementArrayList(10);
059:
060:                result.add(assign(attribute(new ThisReference(),
061:                        new ImplicitIdentifier(
062:                                ImplicitFieldAdder.IMPLICIT_TRANSIENT)),
063:                        new IntLiteral(0)));
064:
065:                result.add(assign(attribute(new ThisReference(),
066:                        new ImplicitIdentifier(
067:                                ImplicitFieldAdder.IMPLICIT_INITIALIZED)),
068:                        new BooleanLiteral(false)));
069:
070:                result.add(new MethodReference(null, new ImplicitIdentifier(
071:                        PrepareObjectBuilder.IMPLICIT_OBJECT_PREPARE_ENTER)));
072:
073:                result.add(new Return(new ThisReference()));
074:
075:                return new StatementBlock(result);
076:
077:            }
078:
079:            /**
080:             * creates the implicit static <code>&lt;createObject&gt;</code>
081:             * method that takes the object to be created out of the pool
082:             * @param type the TypeDeclaration for which the
083:             * <code>&lt;prepare&gt;</code> is created
084:             * @return the implicit <code>&lt;prepare&gt;</code> method
085:             */
086:            public MethodDeclaration createMethod(ClassDeclaration type) {
087:                ModifierMutableList modifiers = new ModifierArrayList(2);
088:                modifiers.add(new Private());
089:                MethodDeclaration md = new MethodDeclaration(modifiers,
090:                        new TypeReference((Identifier) type.getIdentifier()
091:                                .deepClone()), new ImplicitIdentifier(
092:                                IMPLICIT_CREATE),
093:                        new ParameterDeclarationArrayList(0), null,
094:                        createBody(type));
095:                md.makeAllParentRolesValid();
096:                return md;
097:            }
098:
099:            /**
100:             * entry method for the constructor normalform builder
101:             * @param td the TypeDeclaration 
102:             */
103:            protected void makeExplicit(TypeDeclaration td) {
104:                if (td instanceof  ClassDeclaration) {
105:                    attach(createMethod((ClassDeclaration) td), td, td
106:                            .getMembers().size());
107:                    //  	    java.io.StringWriter sw = new java.io.StringWriter();
108:                    //  	    services.getProgramFactory().getPrettyPrinter(sw).visitClassDeclaration((ClassDeclaration)td);
109:                    //  	    System.out.println(sw.toString());
110:                    //  	    try { sw.close(); } catch (Exception e) {}		
111:                }
112:            }
113:
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.