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


001:        package gnu.text;
002:
003:        /** Represents an error message from processing a "source" file. */
004:
005:        public class SourceError implements  SourceLocator {
006:            /** Used to chain to the "next" message. */
007:            public SourceError next;
008:
009:            /** The seriousness of the error - one of 'w' (for warning),
010:             * 'e' (for error), or 'f' (for fatal error). */
011:            public char severity;
012:
013:            /** The name or URL of the file containing the error. */
014:            public String filename;
015:
016:            /** If non-null, an error code, as might be specified by a standard. */
017:            public String code;
018:
019:            /** The line number of the error, with 1 being the top line.
020:             * The value 0 means unknown or not applicable (such as the entire file). */
021:            /** The (1-origin) location of the error. */
022:            public int line;
023:
024:            /** The column number of the error, with 1 being the left-most column.
025:             * The value 0 means unknown or not applicable (such as the entire line). */
026:            public int column;
027:
028:            /** The actual error message.
029:             * This is post-localization and -formatting.
030:             * It can contain multiple lines, separated by '\n'.*/
031:            public String message;
032:
033:            /** Provides optional stack trace.
034:             * Filled when --debug-error-prints-stack-trace or
035:             * --debug-warning-prints-stack-trace option is used.*/
036:            public Throwable fakeException;
037:
038:            public SourceError(char severity, String filename, int line,
039:                    int column, String message) {
040:                this .severity = severity;
041:                this .filename = filename;
042:                this .line = line;
043:                this .column = column;
044:                this .message = message;
045:            }
046:
047:            public SourceError(char severity, SourceLocator location,
048:                    String message) {
049:                this (severity, location.getFileName(),
050:                        location.getLineNumber(), location.getColumnNumber(),
051:                        message);
052:            }
053:
054:            /** Create a new SourceError using the current line/column from
055:             * a <code>LineBufferedReader</code>. */
056:            public SourceError(LineBufferedReader port, char severity,
057:                    String message) {
058:                this (severity, port.getName(), port.getLineNumber() + 1, port
059:                        .getColumnNumber(), message);
060:                if (column >= 0)
061:                    column++;
062:            }
063:
064:            /** Convert the error to a String.
065:             * The String starts with filename, line and option column,
066:             * followed by the message.  Warning messages are indicated as such. */
067:            public String toString() {
068:                StringBuffer buffer = new StringBuffer();
069:                buffer.append(filename == null ? "<unknown>" : filename);
070:                if (line > 0 || column > 0) {
071:                    buffer.append(':');
072:                    buffer.append(line);
073:                    if (column > 0) {
074:                        buffer.append(':');
075:                        buffer.append(column);
076:                    }
077:                }
078:                buffer.append(": ");
079:                if (severity == 'w')
080:                    buffer.append("warning - ");
081:                buffer.append(message);
082:                if (code != null) {
083:                    buffer.append(" [");
084:                    buffer.append(code);
085:                    buffer.append("]");
086:                }
087:                if (fakeException != null) {
088:                    // We assume getStackTrace is evailable if getCause is,
089:                    // rather than add a new PreProcess parameter.
090:                    /* #ifdef use:java.lang.Throwable.getCause */
091:                    StackTraceElement[] stackTrace = fakeException
092:                            .getStackTrace();
093:                    for (int i = 0; i < stackTrace.length; i++) {
094:                        buffer.append("\n");
095:                        buffer.append("    ");
096:                        buffer.append(stackTrace[i].toString());
097:                    }
098:                    /* #else */
099:                    // java.io.StringWriter writer = new java.io.StringWriter();
100:                    // java.io.PrintWriter pwriter = new java.io.PrintWriter(writer);
101:                    // fakeException.printStackTrace(pwriter);
102:                    // pwriter.close();
103:                    // buffer.append("\n");
104:                    // buffer.append(writer.toString());
105:                    /* #endif */
106:                }
107:                return buffer.toString();
108:            }
109:
110:            public void print(java.io.PrintWriter out) {
111:                out.print(this );
112:            }
113:
114:            public void println(java.io.PrintWriter out) {
115:                String line = toString();
116:                for (;;) {
117:                    int nl = line.indexOf('\n');
118:                    if (nl < 0)
119:                        break;
120:                    out.println(line.substring(0, nl));
121:                    line = line.substring(nl + 1);
122:                }
123:                out.println(line);
124:            }
125:
126:            public void println(java.io.PrintStream out) {
127:                String line = toString();
128:                for (;;) {
129:                    int nl = line.indexOf('\n');
130:                    if (nl < 0)
131:                        break;
132:                    out.println(line.substring(0, nl));
133:                    line = line.substring(nl + 1);
134:                }
135:                out.println(line);
136:            }
137:
138:            public int getLineNumber() {
139:                return line == 0 ? -1 : line;
140:            }
141:
142:            public int getColumnNumber() {
143:                return column == 0 ? -1 : column;
144:            }
145:
146:            public String getPublicId() {
147:                return null;
148:            }
149:
150:            public String getSystemId() {
151:                return filename;
152:            }
153:
154:            public String getFileName() {
155:                return filename;
156:            }
157:
158:            public boolean isStableSourceLocation() {
159:                return true;
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.