Source Code Cross Referenced for ExtendedJRJdtCompiler.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » compiler » 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 » Report » iReport 2.0.5 » it.businesslogic.ireport.compiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005-2007 JasperSoft http://www.jaspersoft.com
003:         *
004:         * This program is free software; you can redistribute it and/or modify
005:         * it under the terms of the GNU General Public License as published by
006:         * the Free Software Foundation; either version 2 of the License, or
007:         * (at your option) any later version.
008:         *
009:         * This program is distributed WITHOUT ANY WARRANTY; and without the
010:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
011:         * See the GNU General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU General Public License
014:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
015:         * or write to:
016:         *
017:         * Free Software Foundation, Inc.,
018:         * 59 Temple Place - Suite 330,
019:         * Boston, MA  USA  02111-1307
020:         *
021:         *
022:         * ExtendedJRJdtCompiler.java
023:         *
024:         * Created on March 14, 2007, 2:28 PM
025:         *
026:         * To change this template, choose Tools | Template Manager
027:         * and open the template in the editor.
028:         */
029:
030:        package it.businesslogic.ireport.compiler;
031:
032:        import it.businesslogic.ireport.compiler.xml.SourceLocation;
033:        import it.businesslogic.ireport.compiler.xml.SourceTraceDigester;
034:        import java.util.HashMap;
035:        import java.util.HashSet;
036:        import java.util.Map;
037:        import java.util.Set;
038:        import net.sf.jasperreports.engine.JRExpression;
039:        import net.sf.jasperreports.engine.design.JRCompilationSourceCode;
040:        import net.sf.jasperreports.engine.design.JRCompilationUnit;
041:        import net.sf.jasperreports.engine.design.JRJdtCompiler;
042:        import org.eclipse.jdt.core.compiler.IProblem;
043:        import org.eclipse.jdt.internal.compiler.CompilationResult;
044:        import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
045:
046:        /**
047:         *
048:         * @author gtoffoli
049:         */
050:        public class ExtendedJRJdtCompiler extends JRJdtCompiler {
051:
052:            private JasperReportErrorHandler errorHandler = null;
053:            private SourceTraceDigester digester = null;
054:            private ICompilerRequestor super CompilerRequestor = null;
055:
056:            protected ICompilerRequestor getCompilerRequestor(
057:                    JRCompilationUnit[] units, StringBuffer problemBuffer) {
058:                return new CompilerRequestor(super .getCompilerRequestor(units,
059:                        problemBuffer), units);
060:            }
061:
062:            protected class CompilerRequestor implements  ICompilerRequestor {
063:                private ICompilerRequestor super CompilerRequestor = null;
064:                private final Map expressionErrors = new HashMap();
065:                private final JRCompilationUnit[] units;
066:
067:                protected CompilerRequestor(
068:                        ICompilerRequestor super CompilerRequestor,
069:                        JRCompilationUnit[] units) {
070:                    this .super CompilerRequestor = super CompilerRequestor;
071:                    this .units = units;
072:                }
073:
074:                public void acceptResult(CompilationResult result) {
075:                    if (super CompilerRequestor != null)
076:                        super CompilerRequestor.acceptResult(result);
077:                    if (result.hasErrors()) {
078:                        String className = String.valueOf(result
079:                                .getCompilationUnit().getMainTypeName());
080:
081:                        JRCompilationUnit unit = null;
082:                        for (int classIdx = 0; classIdx < units.length; ++classIdx) {
083:                            if (className.equals(units[classIdx].getName())) {
084:                                unit = units[classIdx];
085:                                break;
086:                            }
087:                        }
088:
089:                        IProblem[] errors = result.getErrors();
090:                        for (int i = 0; i < errors.length; i++) {
091:                            IProblem problem = errors[i];
092:                            int line = problem.getSourceLineNumber();
093:                            JRCompilationSourceCode sourceCode = unit
094:                                    .getCompilationSource();
095:                            JRExpression expression = sourceCode
096:                                    .getExpressionAtLine(line);
097:                            if (expression == null) {
098:                                getErrorHandler().addMarker(problem, null);
099:                            } else if (addExpressionError(expression, problem)) {
100:                                SourceLocation location = getDigester()
101:                                        .getLocation(expression);
102:                                getErrorHandler().addMarker(problem, location);
103:                            }
104:                        }
105:                    }
106:                }
107:
108:                protected boolean addExpressionError(JRExpression expression,
109:                        IProblem problem) {
110:                    Set errors = (Set) expressionErrors.get(expression);
111:                    if (errors == null) {
112:                        errors = new HashSet();
113:                        expressionErrors.put(expression, errors);
114:                    }
115:                    return errors.add(new ExpressionErrorKey(problem));
116:                }
117:            }
118:
119:            protected static class ExpressionErrorKey {
120:                private final IProblem problem;
121:                private final int hash;
122:
123:                public ExpressionErrorKey(IProblem problem) {
124:                    this .problem = problem;
125:                    this .hash = computeHash();
126:                }
127:
128:                private int computeHash() {
129:                    int h = problem.getMessage().hashCode();
130:                    return h;
131:                }
132:
133:                public int hashCode() {
134:                    return hash;
135:                }
136:
137:                public boolean equals(Object o) {
138:                    if (o == null || !(o instanceof  ExpressionErrorKey)
139:                            || this .hash != o.hashCode()) {
140:                        return false;
141:                    }
142:
143:                    if (this  == o) {
144:                        return true;
145:                    }
146:
147:                    ExpressionErrorKey k = (ExpressionErrorKey) o;
148:                    return problem.getMessage().equals(k.problem.getMessage());
149:                }
150:            }
151:
152:            public JasperReportErrorHandler getErrorHandler() {
153:                return errorHandler;
154:            }
155:
156:            public void setErrorHandler(JasperReportErrorHandler errorHandler) {
157:                this .errorHandler = errorHandler;
158:            }
159:
160:            public SourceTraceDigester getDigester() {
161:                return digester;
162:            }
163:
164:            public void setDigester(SourceTraceDigester digester) {
165:                this.digester = digester;
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.