Source Code Cross Referenced for AbstractJavaCompiler.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » language » programming » java » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.language.programming.java 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.components.language.programming.java;
018:
019:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
020:        import org.apache.avalon.excalibur.pool.Recyclable;
021:        import org.apache.cocoon.components.language.programming.LanguageCompiler;
022:
023:        import java.io.BufferedReader;
024:        import java.io.IOException;
025:        import java.io.InputStream;
026:        import java.io.InputStreamReader;
027:        import java.util.List;
028:
029:        /**
030:         * This class implements the functionality common to all Java compilers.
031:         * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
032:         * @version CVS $Id: AbstractJavaCompiler.java 433543 2006-08-22 06:22:54Z crossley $
033:         * @since 2.0
034:         */
035:        public abstract class AbstractJavaCompiler extends AbstractLogEnabled
036:                implements  LanguageCompiler, Recyclable {
037:
038:            /**
039:             * The source program filename
040:             */
041:            protected String file;
042:
043:            /**
044:             * The name of the directory containing the source program file
045:             */
046:            protected String srcDir;
047:
048:            /**
049:             * The name of the directory to contain the resulting object program file
050:             */
051:            protected String destDir;
052:
053:            /**
054:             * The classpath to be used for compilation
055:             */
056:            protected String classpath;
057:
058:            /**
059:             * The encoding of the source program or <code>null</code> to use the
060:             * platform's default encoding
061:             */
062:            protected String encoding = null;
063:
064:            /**
065:             * The version of the JVM for wich the code was written.
066:             * i.e: 130 = Java 1.3, 140 = Java 1.4 and 150 = Java 1.5
067:             */
068:            protected int compilerComplianceLevel;
069:
070:            /**
071:             * The input stream to output compilation errors
072:             */
073:            protected InputStream errors;
074:
075:            /**
076:             * Set the name of the file containing the source program
077:             *
078:             * @param file The name of the file containing the source program
079:             */
080:            public void setFile(String file) {
081:                this .file = file;
082:            }
083:
084:            /**
085:             * Set the name of the directory containing the source program file
086:             *
087:             * @param srcDir The name of the directory containing the source program file
088:             */
089:            public void setSource(String srcDir) {
090:                this .srcDir = srcDir;
091:            }
092:
093:            /**
094:             * Set the name of the directory to contain the resulting object program file
095:             *
096:             * @param destDir The name of the directory to contain the resulting object
097:             * program file
098:             */
099:            public void setDestination(String destDir) {
100:                this .destDir = destDir;
101:            }
102:
103:            /**
104:             * Set the classpath to be used for this compilation
105:             *
106:             * @param classpath The classpath to be used for this compilation
107:             */
108:            public void setClasspath(String classpath) {
109:                this .classpath = classpath;
110:            }
111:
112:            /**
113:             * Set the encoding of the input source file or <code>null</code> to use the
114:             * platform's default encoding
115:             *
116:             * @param encoding The encoding of the input source file or <code>null</code>
117:             * to use the platform's default encoding
118:             */
119:            public void setEncoding(String encoding) {
120:                this .encoding = encoding;
121:            }
122:
123:            /**
124:             * Set the version of the java source code to be compiled
125:             *
126:             * @param compilerComplianceLevel The version of the JVM for wich the code was written.
127:             * i.e: 130 = Java 1.3, 140 = Java 1.4 and 150 = Java 1.5
128:             * 
129:             * @since 2.1.7
130:             */
131:            public void setCompilerComplianceLevel(int compilerComplianceLevel) {
132:                this .compilerComplianceLevel = compilerComplianceLevel;
133:            }
134:
135:            /**
136:             * Return the list of errors generated by this compilation
137:             *
138:             * @return The list of errors generated by this compilation
139:             * @exception IOException If an error occurs during message collection
140:             */
141:            public List getErrors() throws IOException {
142:                return parseStream(new BufferedReader(new InputStreamReader(
143:                        errors)));
144:            }
145:
146:            /**
147:             * Parse the compiler error stream to produce a list of
148:             * <code>CompilerError</code>s
149:             *
150:             * @param errors The error stream
151:             * @return The list of compiler error messages
152:             * @exception IOException If an error occurs during message collection
153:             */
154:            protected abstract List parseStream(BufferedReader errors)
155:                    throws IOException;
156:
157:            /**
158:             * Fill the arguments taken by the Java compiler
159:             *
160:             * @param arguments The list of compilation arguments
161:             * @return The prepared list of compilation arguments
162:             */
163:
164:            protected List fillArguments(List arguments) {
165:                // add compiler compliance level
166:                /*arguments.add("-source");
167:                switch (compilerComplianceLevel) {
168:                    case 150:
169:                        arguments.add("5");
170:                        break;
171:                    case 140:
172:                        //arguments.add("-target");
173:                        arguments.add("1.4");
174:                        break;
175:                    default:
176:                        //arguments.add("-target");
177:                        arguments.add("1.3");
178:                }*/
179:                // destination directory
180:                arguments.add("-d");
181:                arguments.add(destDir);
182:
183:                // classpath
184:                arguments.add("-classpath");
185:                arguments.add(classpath);
186:
187:                // sourcepath
188:                arguments.add("-sourcepath");
189:                arguments.add(srcDir);
190:
191:                // add optimization (for what is worth)
192:                arguments.add("-O");
193:
194:                // add encoding if set
195:                if (encoding != null) {
196:                    arguments.add("-encoding");
197:                    arguments.add(encoding);
198:                }
199:                return arguments;
200:            }
201:
202:            /**
203:             * Copy arguments to a string array
204:             *
205:             * @param arguments The compiler arguments
206:             * @return A string array containing compilation arguments
207:             */
208:            protected String[] toStringArray(List arguments) {
209:                int i;
210:                String[] args = new String[arguments.size() + 1];
211:
212:                for (i = 0; i < arguments.size(); i++) {
213:                    args[i] = (String) arguments.get(i);
214:                }
215:
216:                args[i] = file;
217:
218:                return args;
219:            }
220:
221:            /** Reset all internal state.
222:             * This method is called by the component manager before this
223:             * component is return to its pool.
224:             */
225:            public void recycle() {
226:                file = null;
227:                srcDir = null;
228:                destDir = null;
229:                classpath = null;
230:                encoding = null;
231:                errors = null;
232:            }
233:        }
ww_w_._ja__v_a2__s__._co___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.