Source Code Cross Referenced for SourceMessages.java in  » Scripting » Nice » gnu » text » 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 » Scripting » Nice » gnu.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 1999  Per M.A. Bothner.
002:        // This is free software;  for terms and warranty disclaimer see ./COPYING.
003:
004:        package gnu.text;
005:
006:        /** A collection of (zero or more) SourceErrors. */
007:
008:        public class SourceMessages {
009:            // Number of errors (not counting warnings).  A value of 1000 is "fatal".
010:            private int errorCount = 0;
011:
012:            SourceError firstError;
013:            SourceError lastError;
014:
015:            public SourceError getErrors() {
016:                return firstError;
017:            }
018:
019:            /** Return true iff errors (not warnings) have been seen. */
020:            public boolean seenErrors() {
021:                return errorCount > 0;
022:            }
023:
024:            /** Get the number of errors (not counting warnings). */
025:            public int getErrorCount() {
026:                return errorCount;
027:            }
028:
029:            public void clearErrors() {
030:                errorCount = 0;
031:            }
032:
033:            public void clear() {
034:                firstError = lastError = null;
035:                errorCount = 0;
036:            }
037:
038:            // The last SourceError with a *differnt* filename than prev has.
039:            SourceError lastPrevFilename = null;
040:
041:            public void error(SourceError error) {
042:                if (error.severity == 'f')
043:                    errorCount = 1000;
044:                else if (error.severity != 'w')
045:                    errorCount++;
046:
047:                // Insert the next error so that line numbers are increasing.
048:                if (lastError != null && lastError.filename != null
049:                        && !lastError.filename.equals(error.filename))
050:                    lastPrevFilename = lastError;
051:                SourceError prev = lastPrevFilename;
052:                for (;;) {
053:                    SourceError next;
054:                    if (prev == null)
055:                        next = firstError;
056:                    else
057:                        next = prev.next;
058:                    if (next == null)
059:                        break;
060:                    if (error.line != 0 && next.line != 0) {
061:                        if (error.line < next.line)
062:                            break;
063:                        if (error.line == next.line && error.column != 0
064:                                && next.column != 0) {
065:                            if (error.column < next.column)
066:                                break;
067:                        }
068:                    }
069:                    prev = next;
070:                }
071:                if (prev == null) {
072:                    error.next = firstError;
073:                    firstError = error;
074:                } else {
075:                    error.next = prev.next;
076:                    prev.next = error;
077:                }
078:                if (prev == lastError)
079:                    lastError = error;
080:            }
081:
082:            public void error(char severity, String filename, int line,
083:                    int column, String message) {
084:                error(new SourceError(severity, filename, line, column, message));
085:            }
086:
087:            public void printAll(java.io.PrintStream out, int max) {
088:                for (SourceError err = firstError; err != null && --max >= 0; err = err.next) {
089:                    out.println(err);
090:                }
091:            }
092:
093:            public void printAll(java.io.PrintWriter out, int max) {
094:                for (SourceError err = firstError; err != null && --max >= 0; err = err.next) {
095:                    out.println(err);
096:                }
097:            }
098:
099:            public String toString(int max) {
100:                if (firstError == null)
101:                    return null;
102:                StringBuffer buffer = new StringBuffer();
103:                for (SourceError err = firstError; err != null && --max >= 0; err = err.next) {
104:                    buffer.append(err);
105:                    buffer.append('\n');
106:                }
107:                return buffer.toString();
108:            }
109:
110:            /** Returns true if an error was seen.  Prints and clears the messages.
111:             * @param out where to write the error message to
112:             * @param max maximum number of messages to print (can be 0) */
113:            public boolean checkErrors(java.io.PrintWriter out, int max) {
114:                if (firstError != null) {
115:                    printAll(out, max);
116:                    firstError = lastError = null;
117:                    int saveCount = errorCount;
118:                    errorCount = 0;
119:                    return saveCount > 0;
120:                }
121:                return false;
122:            }
123:
124:            /** Returns true if an error was seen.  Prints and clears the messages
125:             * @param out where to write the error message to
126:             * @param max maximum number of messages to print (can be 0) */
127:            public boolean checkErrors(java.io.PrintStream out, int max) {
128:                if (firstError != null) {
129:                    printAll(out, max);
130:                    firstError = lastError = null;
131:                    int saveCount = errorCount;
132:                    errorCount = 0;
133:                    return saveCount > 0;
134:                }
135:                return false;
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.