Source Code Cross Referenced for Report.java in  » Code-Analyzer » doctorj » org » incava » analysis » 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 » Code Analyzer » doctorj » org.incava.analysis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.incava.analysis;
002:
003:        import java.io.*;
004:        import java.util.Iterator;
005:        import java.util.Set;
006:        import java.util.TreeSet;
007:        import net.sourceforge.pmd.ast.Token;
008:
009:        /**
010:         * Reports errors (violations), in a format that is determined by the subclass.
011:         */
012:        public abstract class Report {
013:            /**
014:             * The file to which this report currently applies. By default, this is '-',
015:             * denoting standard output.
016:             */
017:            protected String fileName = "-";
018:
019:            /**
020:             * The writer to which this report sends output.
021:             */
022:            private Writer writer;
023:
024:            /**
025:             * The set of violations, which are maintained in sorted order.
026:             */
027:            private Set violations = new TreeSet();
028:
029:            /**
030:             * Creates a report for the given writer.
031:             *
032:             * @param writer The writer associated with this report.
033:             */
034:            public Report(Writer writer) {
035:                this .writer = writer;
036:            }
037:
038:            /**
039:             * Creates a report for the given output stream.
040:             *
041:             * @param os The output stream associated with this report.
042:             */
043:            public Report(OutputStream os) {
044:                this (new OutputStreamWriter(os));
045:            }
046:
047:            /**
048:             * Creates a report for the given writer, and a string source.
049:             *
050:             * @param writer The writer associated with this report.
051:             * @param source The source code to which this report applies.
052:             */
053:            public Report(Writer writer, String source) {
054:                this (writer);
055:
056:                reset(source);
057:            }
058:
059:            /**
060:             * Creates a report for the given writer, and a file source.
061:             *
062:             * @param writer The writer associated with this report.
063:             * @param file The file, containing source code, to which this report applies.
064:             */
065:            public Report(Writer writer, File file) {
066:                this (writer);
067:
068:                reset(file);
069:            }
070:
071:            /**
072:             * Creates a report for the given output stream, and string source.
073:             *
074:             * @param os The output stream associated with this report.
075:             * @param source The source code to which this report applies.
076:             */
077:            public Report(OutputStream os, String source) {
078:                this (os);
079:
080:                reset(source);
081:            }
082:
083:            /**
084:             * Creates a report for the given output stream, and file.
085:             *
086:             * @param os The output stream associated with this report.
087:             * @param file The file, containing source code, to which this report applies.
088:             */
089:            public Report(OutputStream os, File file) {
090:                this (os);
091:
092:                reset(file);
093:            }
094:
095:            /**
096:             * Associates the given file with the list of violations, including that are
097:             * adding to this report later, i.e., prior to <code>flush</code>.
098:             *
099:             * @param file The file associated with the set of violations.
100:             */
101:            public void reset(File file) {
102:                tr.Ace.log("file", file);
103:
104:                try {
105:                    fileName = file.getCanonicalPath();
106:                } catch (IOException ioe) {
107:                }
108:            }
109:
110:            /**
111:             * Associates the given string source with the list of violations, including
112:             * that are adding to this report later, i.e., prior to <code>flush</code>.
113:             *
114:             * @param source The source code associated with the set of violations.
115:             */
116:            public void reset(String source) {
117:                tr.Ace.log("source", source);
118:
119:                fileName = "-";
120:            }
121:
122:            /**
123:             * Writes all violations, and clears the list.
124:             */
125:            public void flush() {
126:                try {
127:                    tr.Ace.stack("flushing");
128:
129:                    Iterator it = violations.iterator();
130:                    while (it.hasNext()) {
131:                        Object obj = it.next();
132:                        Violation v = (Violation) obj;
133:                        String str = toString(v);
134:                        tr.Ace.log("v", v);
135:                        tr.Ace.log("str", str);
136:                        writer.write(str);
137:                    }
138:                    // we can't close STDOUT
139:                    writer.flush();
140:                    // writer.close();
141:                } catch (IOException ioe) {
142:                }
143:                violations = new TreeSet();
144:            }
145:
146:            /**
147:             * Adds the given violation.
148:             *
149:             * @param v The violation being added.
150:             */
151:            public void addViolation(Violation v) {
152:                tr.Ace.stack("v", v);
153:                violations.add(v);
154:            }
155:
156:            /**
157:             * Exists only for testing.
158:             */
159:            public Set getViolations() {
160:                return violations;
161:            }
162:
163:            /**
164:             * Returns a string representing the given violation, consistent with the
165:             * format of the Report subclass.
166:             *
167:             * @param violation The violation to represent as a string.
168:             */
169:            protected abstract String toString(Violation violation);
170:
171:            /**
172:             * Sends the given string to the writer associated with this Report.
173:             *
174:             * @param str The string to be written.
175:             */
176:            protected void write(String str) {
177:                tr.Ace.log("str", str);
178:                try {
179:                    writer.write(str);
180:                } catch (IOException ioe) {
181:                }
182:            }
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.