Source Code Cross Referenced for ParseException.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » rdf » arp » 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 » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.rdf.arp 
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:         * (c) Copyright 2001-2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP All rights
004:         * reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are met: 1.
008:         * Redistributions of source code must retain the above copyright notice, this
009:         * list of conditions and the following disclaimer. 2. Redistributions in
010:         * binary form must reproduce the above copyright notice, this list of
011:         * conditions and the following disclaimer in the documentation and/or other
012:         * materials provided with the distribution. 3. The name of the author may not
013:         * be used to endorse or promote products derived from this software without
014:         * specific prior written permission.
015:         * 
016:         * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
017:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
018:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
019:         * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
020:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
021:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
022:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
023:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
024:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
025:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026:         *  * $Id: ParseException.java,v 1.17 2008/01/02 12:06:45 andy_seaborne Exp $
027:         * 
028:         * AUTHOR: Jeremy J. Carroll
029:         */
030:        package com.hp.hpl.jena.rdf.arp;
031:
032:        import org.xml.sax.SAXParseException;
033:
034:        import com.hp.hpl.jena.rdf.arp.impl.Location;
035:
036:        /**
037:         * An exception during the RDF processing of ARP. Note: it is distinguished from
038:         * an XML related exception from Xerces because while both are
039:         * SAXParseException's, the latter are not com.hp.hpl.jena.arp.ParseException's.
040:         * 
041:         */
042:        public class ParseException extends SAXParseException implements 
043:                ARPErrorNumbers {
044:
045:            /**
046:             * 
047:             */
048:            private static final long serialVersionUID = -5986976549492477885L;
049:            final int id;
050:
051:            protected ParseException(int id, Location where, String msg) {
052:                super (msg, where.inputName, null, where.endLine,
053:                        where.endColumn);
054:                this .id = id;
055:
056:            }
057:
058:            public ParseException(int id, Location where, Exception e) {
059:                super (e.getMessage(), where.inputName, null, where.endLine,
060:                        where.endColumn, e);
061:                if (getCause() == null)
062:                    initCause(e);
063:                this .id = id;
064:            }
065:
066:            /**
067:             * The error number (from {@link ARPErrorNumbers}) related to this
068:             * exception.
069:             * 
070:             * @return The error number.
071:             */
072:            public int getErrorNumber() {
073:                return id;
074:            }
075:
076:            /**
077:             * Is this error an RDF syntax error.
078:             * A syntax error indicates that well-formed XML,
079:             * uses RDF properties and attributes, and whitespace
080:             * and XML elements, in a way that does not conform with
081:             * the RDF/XML Syntax (Revised) specification.
082:             * (Currently most such errors have code
083:             * {@link ARPErrorNumbers#ERR_SYNTAX_ERROR},
084:             * but this may change in the future).
085:             * @return True if this is a syntax error
086:             */
087:            public boolean isSyntaxError() {
088:                switch (id) {
089:                case ERR_SYNTAX_ERROR:
090:                case ERR_BAD_RDF_ELEMENT:
091:                case ERR_BAD_RDF_ATTRIBUTE:
092:                case ERR_LI_AS_TYPE:
093:                case ERR_NOT_WHITESPACE:
094:                    return true;
095:                }
096:                return false;
097:            }
098:
099:            SAXParseException rootCause() {
100:                Exception e = getException();
101:                return e == null ? this  : (SAXParseException) e;
102:            }
103:
104:            private boolean promoteMe;
105:
106:            /**
107:             * Intended for use within an RDFErrorHandler. This method is untested.
108:             * Marks the exception to be promoted to be thrown from the parser's entry
109:             * method.
110:             */
111:            public void promote() {
112:                promoteMe = true;
113:            }
114:
115:            /**
116:             * The message without location information. Use either the formatMessage
117:             * method, or the SAXParseException interface, to access the location
118:             * information.
119:             * 
120:             * @return The exception message.
121:             */
122:            public String getMessage() {
123:                // turn 1 to W001
124:                // turn 204 to E204
125:                String idStr = id != 0 ? "{" + (id < 200 ? "W" : "E")
126:                        + ("" + (1000 + id)).substring(1) + "} " : "";
127:
128:                return idStr + super .getMessage();
129:            }
130:
131:            /**
132:             * Calls e.getMessage() and also accesses line and column information for
133:             * SAXParseException's.
134:             * 
135:             * @return e.getMessage() possibly prepended by error location information.
136:             * @param e
137:             *            The exception to describe.
138:             */
139:            static public String formatMessage(Exception e) {
140:                String msg = e.getMessage();
141:                if (msg == null)
142:                    msg = e.toString();
143:                if (!(e instanceof  SAXParseException))
144:                    return msg;
145:                SAXParseException sax = (SAXParseException) e;
146:                String file = sax.getSystemId();
147:                if (file == null)
148:                    file = sax.getPublicId();
149:                String rslt = file == null ? "" : file;
150:                if (sax.getLineNumber() == -1)
151:                    return (file != null ? (file + ": ") : "") + msg;
152:
153:                if (sax.getColumnNumber() == -1) {
154:                    return rslt + "(line " + sax.getLineNumber() + "): " + msg;
155:                }
156:                return rslt + "(line " + sax.getLineNumber() + " column "
157:                        + sax.getColumnNumber() + "): " + msg;
158:
159:            }
160:
161:            public boolean isPromoted() {
162:                return promoteMe;
163:            }
164:
165:            /**
166:             * The  string from
167:             * {@link ARPErrorNumbers} associated with an integer error code
168:             * @param errNo An error code from {@link ARPErrorNumbers}.
169:             * @return The field name from {@link ARPErrorNumbers} with this error number, or null
170:             */
171:            static public String errorCodeName(int errNo) {
172:                Class c = ARPErrorNumbers.class;
173:                java.lang.reflect.Field flds[] = c.getDeclaredFields();
174:                for (int i = 0; i < flds.length; i++) {
175:                    try {
176:                        if (flds[i].getInt(null) == errNo)
177:                            return flds[i].getName();
178:                    } catch (Exception e) {
179:                        // ignore exceptions
180:                    }
181:                }
182:                return null;
183:            }
184:
185:            /**
186:             * The integer code associated with a string from
187:             * {@link ARPErrorNumbers}.
188:             * @param upper A field name from {@link ARPErrorNumbers}, (in upper case).
189:             * @return The integer value or -1, if none.
190:             */
191:            static public int errorCode(String upper) {
192:                Class c = ARPErrorNumbers.class;
193:                try {
194:                    java.lang.reflect.Field fld = c.getField(upper);
195:                    return fld.getInt(null);
196:                } catch (Exception e) {
197:                    return -1;
198:                }
199:            }
200:
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.