Source Code Cross Referenced for FOPException.java in  » Graphic-Library » fop » org » apache » fop » apps » 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 » Graphic Library » fop » org.apache.fop.apps 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        /* $Id: FOPException.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020:        package org.apache.fop.apps;
021:
022:        import org.xml.sax.Locator;
023:        import org.xml.sax.SAXException;
024:
025:        /**
026:         * Exception thrown when FOP has a problem.
027:         */
028:        public class FOPException extends SAXException {
029:
030:            private static final String EXCEPTION_SEPARATOR = "\n---------\n";
031:
032:            private String systemId;
033:            private int line;
034:            private int column;
035:
036:            /**
037:             * Constructs a new FOP exception with the specified detail message.
038:             * @param message the detail message.
039:             */
040:            public FOPException(String message) {
041:                super (message);
042:            }
043:
044:            /**
045:             * Constructs a new FOP exception with the specified detail message and location.
046:             * @param message the detail message
047:             * @param systemId the system id of the FO document which is associated with the exception
048:             *                 may be null.
049:             * @param line line number in the FO document which is associated with the exception.
050:             * @param column clolumn number in the line which is associated with the exception.
051:             */
052:            public FOPException(String message, String systemId, int line,
053:                    int column) {
054:                super (message);
055:                this .systemId = systemId;
056:                this .line = line;
057:                this .column = column;
058:            }
059:
060:            /**
061:             * Constructs a new FOP exception with the specified detail message and location.
062:             * @param message the detail message.
063:             * @param locator the locator holding the location.
064:             */
065:            public FOPException(String message, Locator locator) {
066:                super (message);
067:                setLocator(locator);
068:            }
069:
070:            /**
071:             * Constructs a new FOP exception with the specified cause.
072:             * @param cause the cause.
073:             */
074:            public FOPException(Exception cause) {
075:                super (cause);
076:            }
077:
078:            /**
079:             * Constructs a new exception with the specified detail message and cause.
080:             * @param message  the detail message
081:             * @param cause the cause 
082:             */
083:            public FOPException(String message, Exception cause) {
084:                super (message, cause);
085:            }
086:
087:            /**
088:             * Set a location associated with the exception.
089:             * @param locator the locator holding the location.
090:             */
091:            public void setLocator(Locator locator) {
092:                if (locator != null) {
093:                    this .systemId = locator.getSystemId();
094:                    this .line = locator.getLineNumber();
095:                    this .column = locator.getColumnNumber();
096:                }
097:            }
098:
099:            /**
100:             * Set a location associated with the exception.
101:             * @param systemId the system id of the FO document which is associated with the exception;
102:             *                 may be null.
103:             * @param line line number in the FO document which is associated with the exception.
104:             * @param column clolumn number in the line which is associated with the exception.
105:             */
106:            public void setLocation(String systemId, int line, int column) {
107:                this .systemId = systemId;
108:                this .line = line;
109:                this .column = column;
110:            }
111:
112:            /**
113:             * Indicate whether a location was set.
114:             * @return whether a location was set
115:             */
116:            public boolean isLocationSet() {
117:                // TODO: this is actually a dangerous assumption: A line
118:                // number of 0 or -1 might be used to indicate an unknown line
119:                // number, while the system ID might still be of use.
120:                return line > 0;
121:            }
122:
123:            /**
124:             * Returns the detail message string of this FOP exception.
125:             * If a location was set, the message is prepended with it in the
126:             * form
127:             * <pre>
128:             *  SystemId:LL:CC: &amp;the message&amp;
129:             * </pre>
130:             * (the format used by most GNU tools)
131:             * @return the detail message string of this FOP exception
132:             */
133:            public String getMessage() {
134:                if (isLocationSet()) {
135:                    return systemId + ":" + line + ":" + column + ": "
136:                            + super .getMessage();
137:                } else {
138:                    return super .getMessage();
139:                }
140:            }
141:
142:            /**
143:             * Attempts to recast the exception as other Throwable types.
144:             * @return the exception recast as another type if possible, otherwise null.
145:             */
146:            protected Throwable getRootException() {
147:                Throwable result = getException();
148:
149:                if (result instanceof  SAXException) {
150:                    result = ((SAXException) result).getException();
151:                }
152:                if (result instanceof  java.lang.reflect.InvocationTargetException) {
153:                    result = ((java.lang.reflect.InvocationTargetException) result)
154:                            .getTargetException();
155:                }
156:                if (result != getException()) {
157:                    return result;
158:                }
159:                return null;
160:            }
161:
162:            /**
163:             * Prints this FOP exception and its backtrace to the standard error stream.
164:             */
165:            public void printStackTrace() {
166:                synchronized (System.err) {
167:                    super .printStackTrace();
168:                    if (getException() != null) {
169:                        System.err.println(EXCEPTION_SEPARATOR);
170:                        getException().printStackTrace();
171:                    }
172:                    if (getRootException() != null) {
173:                        System.err.println(EXCEPTION_SEPARATOR);
174:                        getRootException().printStackTrace();
175:                    }
176:                }
177:            }
178:
179:            /**
180:             * Prints this FOP exception and its backtrace to the specified print stream.
181:             * @param stream PrintStream to use for output
182:             */
183:            public void printStackTrace(java.io.PrintStream stream) {
184:                synchronized (stream) {
185:                    super .printStackTrace(stream);
186:                    if (getException() != null) {
187:                        stream.println(EXCEPTION_SEPARATOR);
188:                        getException().printStackTrace(stream);
189:                    }
190:                    if (getRootException() != null) {
191:                        stream.println(EXCEPTION_SEPARATOR);
192:                        getRootException().printStackTrace(stream);
193:                    }
194:                }
195:            }
196:
197:            /**
198:             * Prints this FOP exception and its backtrace to the specified print writer.
199:             * @param writer PrintWriter to use for output
200:             */
201:            public void printStackTrace(java.io.PrintWriter writer) {
202:                synchronized (writer) {
203:                    super.printStackTrace(writer);
204:                    if (getException() != null) {
205:                        writer.println(EXCEPTION_SEPARATOR);
206:                        getException().printStackTrace(writer);
207:                    }
208:                    if (getRootException() != null) {
209:                        writer.println(EXCEPTION_SEPARATOR);
210:                        getRootException().printStackTrace(writer);
211:                    }
212:                }
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.