Source Code Cross Referenced for JikesOutputParser.java in  » Build » ANT » org » apache » tools » ant » taskdefs » 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 » Build » ANT » org.apache.tools.ant.taskdefs 
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:         */
018:        package org.apache.tools.ant.taskdefs;
019:
020:        import java.io.BufferedReader;
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:        import java.io.InputStreamReader;
024:        import java.io.OutputStream;
025:        import org.apache.tools.ant.Project;
026:        import org.apache.tools.ant.Task;
027:
028:        /**
029:         * Parses output from jikes and
030:         * passes errors and warnings
031:         * into the right logging channels of Project.
032:         *
033:         * <p><strong>As of Ant 1.2, this class is considered to be dead code
034:         * by the Ant developers and is unmaintained.  Don't use
035:         * it.</strong></p>
036:         *
037:         * @deprecated since 1.2.
038:         *             Use Jikes' exit value to detect compilation failure.
039:         */
040:        public class JikesOutputParser implements  ExecuteStreamHandler {
041:            // CheckStyle:VisibilityModifier OFF - bc
042:            protected Task task;
043:            protected boolean errorFlag = false; // no errors so far
044:            protected int errors;
045:            protected int warnings;
046:            protected boolean error = false;
047:            protected boolean emacsMode;
048:
049:            protected BufferedReader br;
050:
051:            // CheckStyle:VisibilityModifier ON
052:
053:            /**
054:             * Ignore.
055:             * @param os ignored
056:             */
057:            public void setProcessInputStream(OutputStream os) {
058:            }
059:
060:            /**
061:             * Ignore.
062:             * @param is ignored
063:             */
064:            public void setProcessErrorStream(InputStream is) {
065:            }
066:
067:            /**
068:             * Set the inputstream
069:             * @param is the input stream
070:             * @throws IOException on error
071:             */
072:            public void setProcessOutputStream(InputStream is)
073:                    throws IOException {
074:                br = new BufferedReader(new InputStreamReader(is));
075:            }
076:
077:            /**
078:             * Invokes parseOutput.
079:             * @throws IOException on error
080:             */
081:            public void start() throws IOException {
082:                parseOutput(br);
083:            }
084:
085:            /**
086:             * Ignore.
087:             */
088:            public void stop() {
089:            }
090:
091:            /**
092:             * Construct a new Parser object
093:             * @param task      task in which context we are called
094:             * @param emacsMode if true output in emacs mode
095:             */
096:            protected JikesOutputParser(Task task, boolean emacsMode) {
097:                super ();
098:
099:                System.err
100:                        .println("As of Ant 1.2 released in October 2000, the "
101:                                + "JikesOutputParser class");
102:                System.err.println("is considered to be dead code by the Ant "
103:                        + "developers and is unmaintained.");
104:                System.err.println("Don\'t use it!");
105:
106:                this .task = task;
107:                this .emacsMode = emacsMode;
108:            }
109:
110:            /**
111:             * Parse the output of a jikes compiler
112:             * @param reader - Reader used to read jikes's output
113:             * @throws IOException on error
114:             */
115:            protected void parseOutput(BufferedReader reader)
116:                    throws IOException {
117:                if (emacsMode) {
118:                    parseEmacsOutput(reader);
119:                } else {
120:                    parseStandardOutput(reader);
121:                }
122:            }
123:
124:            private void parseStandardOutput(BufferedReader reader)
125:                    throws IOException {
126:                String line;
127:                String lower;
128:                // We assume, that every output, jikes does, stands for an error/warning
129:                // XXX
130:                // Is this correct?
131:
132:                // TODO:
133:                // A warning line, that shows code, which contains a variable
134:                // error will cause some trouble. The parser should definitely
135:                // be much better.
136:
137:                while ((line = reader.readLine()) != null) {
138:                    lower = line.toLowerCase();
139:                    if (line.trim().equals("")) {
140:                        continue;
141:                    }
142:                    if (lower.indexOf("error") != -1) {
143:                        setError(true);
144:                    } else if (lower.indexOf("warning") != -1) {
145:                        setError(false);
146:                    } else {
147:                        // If we don't know the type of the line
148:                        // and we are in emacs mode, it will be
149:                        // an error, because in this mode, jikes won't
150:                        // always print "error", but sometimes other
151:                        // keywords like "Syntax". We should look for
152:                        // all those keywords.
153:                        if (emacsMode) {
154:                            setError(true);
155:                        }
156:                    }
157:                    log(line);
158:                }
159:            }
160:
161:            private void parseEmacsOutput(BufferedReader reader)
162:                    throws IOException {
163:                // This may change, if we add advanced parsing capabilities.
164:                parseStandardOutput(reader);
165:            }
166:
167:            private void setError(boolean err) {
168:                error = err;
169:                if (error) {
170:                    errorFlag = true;
171:                }
172:            }
173:
174:            private void log(String line) {
175:                if (!emacsMode) {
176:                    task.log("", (error ? Project.MSG_ERR : Project.MSG_WARN));
177:                }
178:                task.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN));
179:            }
180:
181:            /**
182:             * Indicate if there were errors during the compile
183:             * @return if errors occurred
184:             */
185:            protected boolean getErrorFlag() {
186:                return errorFlag;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.