Source Code Cross Referenced for ParseErrorException.java in  » Template-Engine » Velocity » org » apache » velocity » exception » 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 » Template Engine » Velocity » org.apache.velocity.exception 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.velocity.exception;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.    
020:         */
021:
022:        import org.apache.velocity.runtime.parser.ParseException;
023:        import org.apache.velocity.util.introspection.Info;
024:
025:        /**
026:         *  Application-level exception thrown when a resource of any type
027:         *  has a syntax or other error which prevents it from being parsed.
028:         *  <br>
029:         *  When this resource is thrown, a best effort will be made to have
030:         *  useful information in the exception's message.  For complete
031:         *  information, consult the runtime log.
032:         *
033:         * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
034:         * @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
035:         * @version $Id: ParseErrorException.java 471381 2006-11-05 08:56:58Z wglass $
036:         */
037:        public class ParseErrorException extends VelocityException {
038:            /**
039:             * Version Id for serializable
040:             */
041:            private static final long serialVersionUID = -6665197935086306472L;
042:
043:            /**
044:             * The column number of the parsing error, or -1 if not defined.
045:             */
046:            private int columnNumber = -1;
047:
048:            /**
049:             * The line number of the parsing error, or -1 if not defined.
050:             */
051:            private int lineNumber = -1;
052:
053:            /**
054:             * The name of the template containing the error, or null if not defined.
055:             */
056:            private String templateName = "*unset*";
057:
058:            /**
059:             * If applicable, contains the invalid syntax or reference that triggered this exception
060:             */
061:            private String invalidSyntax;
062:
063:            /**
064:             * Create a ParseErrorException with the given message.
065:             *
066:             * @param exceptionMessage the error exception message
067:             */
068:            public ParseErrorException(String exceptionMessage) {
069:                super (exceptionMessage);
070:            }
071:
072:            /**
073:             * Create a ParseErrorException with the given ParseException.
074:             *
075:             * @param pex the parsing exception
076:             */
077:            public ParseErrorException(ParseException pex) {
078:                super (pex.getMessage());
079:
080:                // Don't use a second C'tor, TemplateParseException is a subclass of
081:                // ParseException...
082:                if (pex instanceof  ExtendedParseException) {
083:                    ExtendedParseException xpex = (ExtendedParseException) pex;
084:
085:                    columnNumber = xpex.getColumnNumber();
086:                    lineNumber = xpex.getLineNumber();
087:                    templateName = xpex.getTemplateName();
088:                } else {
089:                    //  ugly, ugly, ugly...
090:
091:                    if (pex.currentToken != null
092:                            && pex.currentToken.next != null) {
093:                        columnNumber = pex.currentToken.next.beginColumn;
094:                        lineNumber = pex.currentToken.next.beginLine;
095:                    }
096:                }
097:            }
098:
099:            /**
100:             * Create a ParseErrorException with the given ParseException.
101:             *
102:             * @param pex the parsing exception
103:             */
104:            public ParseErrorException(VelocityException pex) {
105:                super (pex.getMessage());
106:
107:                // Don't use a second C'tor, TemplateParseException is a subclass of
108:                // ParseException...
109:                if (pex instanceof  ExtendedParseException) {
110:                    ExtendedParseException xpex = (ExtendedParseException) pex;
111:
112:                    columnNumber = xpex.getColumnNumber();
113:                    lineNumber = xpex.getLineNumber();
114:                    templateName = xpex.getTemplateName();
115:                } else if (pex.getWrappedThrowable() instanceof  ParseException) {
116:                    ParseException pex2 = (ParseException) pex
117:                            .getWrappedThrowable();
118:
119:                    if (pex2.currentToken != null
120:                            && pex2.currentToken.next != null) {
121:                        columnNumber = pex2.currentToken.next.beginColumn;
122:                        lineNumber = pex2.currentToken.next.beginLine;
123:                    }
124:                }
125:            }
126:
127:            /**
128:             * Create a ParseErrorRuntimeException with the given message and info
129:             * 
130:             * @param exceptionMessage the error exception message
131:             * @param info an Info object with the current template info
132:             */
133:            public ParseErrorException(String exceptionMessage, Info info) {
134:                super (exceptionMessage);
135:                columnNumber = info.getColumn();
136:                lineNumber = info.getLine();
137:                templateName = info.getTemplateName();
138:            }
139:
140:            /**
141:             * Create a ParseErrorRuntimeException with the given message and info
142:             * 
143:             * @param exceptionMessage the error exception message
144:             * @param info an Info object with the current template info
145:             * @param invalidSyntax the invalid syntax or reference triggering this exception
146:             */
147:            public ParseErrorException(String exceptionMessage, Info info,
148:                    String invalidSyntax) {
149:                super (exceptionMessage);
150:                columnNumber = info.getColumn();
151:                lineNumber = info.getLine();
152:                templateName = info.getTemplateName();
153:                this .invalidSyntax = invalidSyntax;
154:            }
155:
156:            /**
157:             * Return the column number of the parsing error, or -1 if not defined.
158:             *
159:             * @return column number of the parsing error, or -1 if not defined
160:             */
161:            public int getColumnNumber() {
162:                return columnNumber;
163:            }
164:
165:            /**
166:             * Return the line number of the parsing error, or -1 if not defined.
167:             *
168:             * @return line number of the parsing error, or -1 if not defined
169:             */
170:            public int getLineNumber() {
171:                return lineNumber;
172:            }
173:
174:            /**
175:             * Return the name of the template containing the error, or null if not
176:             * defined.
177:             *
178:             * @return the name of the template containing the parsing error, or null
179:             *      if not defined
180:             */
181:            public String getTemplateName() {
182:                return templateName;
183:            }
184:
185:            /**
186:             * Return the invalid syntax or reference that triggered this error, or null
187:             * if not defined.
188:             * 
189:             * @return Return the invalid syntax or reference that triggered this error, or null
190:             * if not defined
191:             */
192:            public String getInvalidSyntax() {
193:                return invalidSyntax;
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.