Source Code Cross Referenced for ParseException.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » annotation » expression » ast » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.annotation.expression.ast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
002:
003:        /**************************************************************************************
004:         * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved.                 *
005:         * http://aspectwerkz.codehaus.org                                                    *
006:         * ---------------------------------------------------------------------------------- *
007:         * The software in this package is published under the terms of the LGPL license      *
008:         * a copy of which has been included with this distribution in the license.txt file.  *
009:         **************************************************************************************/package org.codehaus.aspectwerkz.annotation.expression.ast;
010:
011:        /**
012:         * This exception is thrown when parse errors are encountered. You can explicitly create objects of this exception type
013:         * by calling the method generateParseException in the generated parser. <p/>You can modify this class to customize your
014:         * error reporting mechanisms so long as you retain the public fields.
015:         */
016:        public class ParseException extends Exception {
017:            /**
018:             * This variable determines which constructor was used to create this object and thereby affects the semantics of
019:             * the "getMessage" method (see below).
020:             */
021:            protected boolean specialConstructor;
022:
023:            /**
024:             * This is the last token that has been consumed successfully. If this object has been created due to a parse error,
025:             * the token followng this token will (therefore) be the first error token.
026:             */
027:            public Token currentToken;
028:
029:            /**
030:             * Each entry in this array is an array of integers. Each array of integers represents a sequence of tokens (by
031:             * their ordinal values) that is expected at this point of the parse.
032:             */
033:            public int[][] expectedTokenSequences;
034:
035:            /**
036:             * This is a reference to the "tokenImage" array of the generated parser within which the parse error occurred. This
037:             * array is defined in the generated ...Constants interface.
038:             */
039:            public String[] tokenImage;
040:
041:            /**
042:             * The end of line string for this machine.
043:             */
044:            protected String eol = System.getProperty("line.separator", "\n");
045:
046:            /**
047:             * This constructor is used by the method "generateParseException" in the generated parser. Calling this constructor
048:             * generates a new object of this type with the fields "currentToken", "expectedTokenSequences", and "tokenImage"
049:             * set. The boolean flag "specialConstructor" is also set to true to indicate that this constructor was used to
050:             * create this object. This constructor calls its super class with the empty string to force the "toString" method
051:             * of parent class "Throwable" to print the error message in the form: ParseException: <result of getMessage>
052:             */
053:            public ParseException(Token currentTokenVal,
054:                    int[][] expectedTokenSequencesVal, String[] tokenImageVal) {
055:                super ("");
056:                specialConstructor = true;
057:                currentToken = currentTokenVal;
058:                expectedTokenSequences = expectedTokenSequencesVal;
059:                tokenImage = tokenImageVal;
060:            }
061:
062:            /**
063:             * The following constructors are for use by you for whatever purpose you can think of. Constructing the exception
064:             * in this manner makes the exception behave in the normal way - i.e., as documented in the class "Throwable". The
065:             * fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain relevant information. The JavaCC
066:             * generated code does not use these constructors.
067:             */
068:            public ParseException() {
069:                super ();
070:                specialConstructor = false;
071:            }
072:
073:            public ParseException(String message) {
074:                super (message);
075:                specialConstructor = false;
076:            }
077:
078:            /**
079:             * This method has the standard behavior when this object has been created using the standard constructors.
080:             * Otherwise, it uses "currentToken" and "expectedTokenSequences" to generate a parse error message and returns it.
081:             * If this object has been created due to a parse error, and you do not catch it (it gets thrown from the parser),
082:             * then this method is called during the printing of the final stack trace, and hence the correct error message gets
083:             * displayed.
084:             */
085:            public String getMessage() {
086:                if (!specialConstructor) {
087:                    return super .getMessage();
088:                }
089:                String expected = "";
090:                int maxSize = 0;
091:                for (int i = 0; i < expectedTokenSequences.length; i++) {
092:                    if (maxSize < expectedTokenSequences[i].length) {
093:                        maxSize = expectedTokenSequences[i].length;
094:                    }
095:                    for (int j = 0; j < expectedTokenSequences[i].length; j++) {
096:                        expected += (tokenImage[expectedTokenSequences[i][j]] + " ");
097:                    }
098:                    if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
099:                        expected += "...";
100:                    }
101:                    expected += (eol + "    ");
102:                }
103:                String retval = "Encountered \"";
104:                Token tok = currentToken.next;
105:                for (int i = 0; i < maxSize; i++) {
106:                    if (i != 0) {
107:                        retval += " ";
108:                    }
109:                    if (tok.kind == 0) {
110:                        retval += tokenImage[0];
111:                        break;
112:                    }
113:                    retval += add_escapes(tok.image);
114:                    tok = tok.next;
115:                }
116:                retval += ("\" at line " + currentToken.next.beginLine
117:                        + ", column " + currentToken.next.beginColumn);
118:                retval += ("." + eol);
119:                if (expectedTokenSequences.length == 1) {
120:                    retval += ("Was expecting:" + eol + "    ");
121:                } else {
122:                    retval += ("Was expecting one of:" + eol + "    ");
123:                }
124:                retval += expected;
125:                return retval;
126:            }
127:
128:            /**
129:             * Used to convert raw characters to their escaped version when these raw version cannot be used as part of an ASCII
130:             * string literal.
131:             */
132:            protected String add_escapes(String str) {
133:                StringBuffer retval = new StringBuffer();
134:                char ch;
135:                for (int i = 0; i < str.length(); i++) {
136:                    switch (str.charAt(i)) {
137:                    case 0:
138:                        continue;
139:                    case '\b':
140:                        retval.append("\\b");
141:                        continue;
142:                    case '\t':
143:                        retval.append("\\t");
144:                        continue;
145:                    case '\n':
146:                        retval.append("\\n");
147:                        continue;
148:                    case '\f':
149:                        retval.append("\\f");
150:                        continue;
151:                    case '\r':
152:                        retval.append("\\r");
153:                        continue;
154:                    case '\"':
155:                        retval.append("\\\"");
156:                        continue;
157:                    case '\'':
158:                        retval.append("\\\'");
159:                        continue;
160:                    case '\\':
161:                        retval.append("\\\\");
162:                        continue;
163:                    default:
164:                        if (((ch = str.charAt(i)) < 0x20) || (ch > 0x7e)) {
165:                            String s = "0000" + Integer.toString(ch, 16);
166:                            retval.append("\\u"
167:                                    + s.substring(s.length() - 4, s.length()));
168:                        } else {
169:                            retval.append(ch);
170:                        }
171:                        continue;
172:                    }
173:                }
174:                return retval.toString();
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.