Source Code Cross Referenced for Generator.java in  » Web-Server » simple » simple » page » translate » 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 » Web Server » simple » simple.page.translate 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Generator.java March 2006
003:         *
004:         * Copyright (C) 2006, Niall Gallagher <niallg@users.sf.net>
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
013:         * GNU Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General 
016:         * Public License along with this library; if not, write to the 
017:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
018:         * Boston, MA  02111-1307  USA
019:         */
020:
021:        package simple.page.translate;
022:
023:        import freemarker.log.Logger;
024:        import simple.page.Workspace;
025:        import java.io.FileWriter;
026:        import java.io.File;
027:
028:        /**
029:         * The <code>Generator</code> object is used to generate the sources 
030:         * for the document definition built during parsing. This will acquire
031:         * a template suitable for the runtime language specified by the JSP
032:         * source. This templates is given the definition, and the output of
033:         * the template is written to source file specified by the definition.
034:         *
035:         * @author Niall Gallagher
036:         */
037:        final class Generator {
038:
039:            /**
040:             * To ensure that logging does not cause undesired JSP output, 
041:             * the freemarker logging is turned off for this generator.
042:             */
043:            static {
044:                try {
045:                    Logger.selectLoggerLibrary(Logger.LIBRARY_NONE);
046:                } catch (Exception e) {
047:                    e.printStackTrace();
048:                }
049:            }
050:
051:            /**
052:             * This is used to load the template to match the source object.
053:             */
054:            private SchemaLoader loader;
055:
056:            /**
057:             * Constructor for the <code>Generator</code> object. This is used
058:             * to generate a source file for the specified runtime language.
059:             * By default the Java and Groovy languages can be generated.
060:             *
061:             * @param project this is the project used by this generator
062:             */
063:            public Generator(Workspace project) {
064:                this .loader = new SchemaLoader(project);
065:            }
066:
067:            /**
068:             * This is used to generate the source for the provided document
069:             * definition. This will ensure that the source is written to the
070:             * file suggested by the document definition. If the directory
071:             * leading to the source file does not exist then it is created.
072:             *
073:             * @param source this is the document definition to generate
074:             */
075:            public void generate(Definition source) throws Exception {
076:                File path = source.getDirectory();
077:                File file = source.getSource();
078:
079:                if (!path.exists()) {
080:                    path.mkdirs();
081:                }
082:                generate(source, file);
083:            }
084:
085:            /**
086:             * This is used to generate the source for the provided document
087:             * definition. This will ensure that the source is written to the
088:             * file suggested by the document definition. If the directory
089:             * leading to the source file does not exist then it is created.
090:             *
091:             * @param source this is the document definition to generate
092:             */
093:            private void generate(Definition source, File file)
094:                    throws Exception {
095:                Schema template = loader.getSchema(source);
096:                FileWriter data = new FileWriter(file);
097:
098:                template.write(data);
099:                data.close();
100:            }
101:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.