[FOray-commit] SF.net SVN: foray: [7267] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-05-26 17:49:17
|
Revision: 7267 Author: victormote Date: 2006-05-26 10:48:40 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7267&view=rev Log Message: ----------- Move FOrayException class to new core package. Modified Paths: -------------- trunk/foray/foray-app/.classpath trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/FOray.java trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java trunk/foray/foray-app/src/java/org/foray/app/Options.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/Starter.java trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Added Paths: ----------- trunk/foray/foray-core/ trunk/foray/foray-core/src/ trunk/foray/foray-core/src/java/ trunk/foray/foray-core/src/java/org/ trunk/foray/foray-core/src/java/org/foray/ trunk/foray/foray-core/src/java/org/foray/core/ trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java Modified: trunk/foray/foray-app/.classpath =================================================================== --- trunk/foray/foray-app/.classpath 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/.classpath 2006-05-26 17:48:40 UTC (rev 7267) @@ -32,5 +32,6 @@ <classpathentry combineaccessrules="false" kind="src" path="/axslArea-W"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayLayout"/> <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> + <classpathentry combineaccessrules="false" kind="src" path="/FOrayCore"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -31,6 +31,7 @@ * Modified to use streaming API by Mark Lillywhite, mar...@in... */ +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineOptions.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ConfigurationParser.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOInputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,8 @@ package org.foray.app; +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOray.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOray.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.output.MIFConverter; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -1,166 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.xml.sax.SAXException; - -import java.io.PrintStream; -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; - -/** - * Exception thrown when FOray has a problem. - */ -public class FOrayException extends Exception { - static final long serialVersionUID = 298590433713255908L; - - private static final String EXCEPTION_SEPARATOR = "\n---------\n"; - - private Throwable _exception; - private String contextMessage; - - /** - * Create a new FOray Exception - * - * @param message descriptive message - */ - public FOrayException(String message) { - super(message); - this.contextMessage = null; - } - - public FOrayException(String message, String contextMessage) { - super(message); - this.contextMessage = contextMessage; - } - - public FOrayException(Throwable e) { - super(e.getMessage()); - setException(e); - this.contextMessage = null; - } - - public FOrayException(Throwable e, String contextMessage) { - super(e.getMessage()); - setException(e); - this.contextMessage = contextMessage; - } - - public FOrayException(String message, Throwable e) { - super(message); - setException(e); - this.contextMessage = null; - } - - public FOrayException(String message, Throwable e, String contextMessage) { - super(message); - setException(e); - this.contextMessage = contextMessage; - } - - protected void setException(Throwable t) { - _exception = t; - } - - public Throwable getException() { - return _exception; - } - - public void setContextMessage(String contextMessage) { - this.contextMessage = contextMessage; - } - - public boolean isContextSet() { - return this.contextMessage != null; - } - - protected Throwable getRootException() { - Throwable result = _exception; - - if (result instanceof SAXException) { - result = ((SAXException)result).getException(); - } - if (result instanceof InvocationTargetException) { - result = - ((InvocationTargetException)result) - .getTargetException(); - } - if (result != _exception) { - return result; - } - return null; - } - - public String getMessage() { - if (this.contextMessage != null) { - return super.getMessage() + "\n" - + this.contextMessage; - } - return super.getMessage(); - } - - public void printStackTrace() { - synchronized (System.err) { - super.printStackTrace(); - if (_exception != null) { - System.err.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(); - } - if (getRootException() != null) { - System.err.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(); - } - } - } - - public void printStackTrace(PrintStream stream) { - synchronized (stream) { - super.printStackTrace(stream); - if (_exception != null) { - stream.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(stream); - } - if (getRootException() != null) { - stream.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(stream); - } - } - } - - public void printStackTrace(PrintWriter writer) { - synchronized (writer) { - super.printStackTrace(writer); - if (_exception != null) { - writer.println(EXCEPTION_SEPARATOR); - _exception.printStackTrace(writer); - } - if (getRootException() != null) { - writer.println(EXCEPTION_SEPARATOR); - getRootException().printStackTrace(writer); - } - } - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -27,6 +27,7 @@ import org.foray.area.FOrayAreaTreeFactory; import org.foray.common.Logging; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.common.XMLParser; +import org.foray.core.FOrayException; import org.foray.font.FOrayFontServer; import org.foray.graphic.FOrayGraphicServer; Modified: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import org.foray.render.Renderer; Modified: trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/InputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,8 @@ package org.foray.app; +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/Options.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/Options.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,6 +25,7 @@ package org.foray.app; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/Starter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/Starter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,6 +24,7 @@ package org.foray.app; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/TraxInputHandler.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,6 +26,8 @@ +import org.foray.core.FOrayException; + import org.apache.commons.logging.Log; import org.xml.sax.InputSource; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTask.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -24,10 +24,10 @@ package org.foray.app.ant; -import org.foray.app.FOrayException; import org.foray.app.FOrayTarget; import org.foray.app.Starter; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.apache.commons.logging.Log; import org.apache.tools.ant.BuildException; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,13 +26,13 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.Options; import org.foray.app.SessionConfig; import org.foray.app.Starter; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,13 +26,13 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.SessionConfig; import org.foray.app.TraxInputHandler; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputConfig; import org.foray.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -35,13 +35,13 @@ import javax.xml.transform.TransformerException; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; import org.foray.render.awt.viewer.SecureResourceBundle; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -30,13 +30,13 @@ import java.io.OutputStream; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -36,13 +36,13 @@ import javax.xml.transform.stream.StreamSource; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.output.OutputTarget; +import org.foray.core.FOrayException; import org.foray.demo.embed.model.ProjectTeam; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -36,11 +36,11 @@ import javax.xml.transform.stream.StreamSource; import org.foray.app.Application; -import org.foray.app.FOrayException; import org.foray.app.SessionConfig; import org.foray.app.FOrayDocument; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; /** Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -26,12 +26,12 @@ import org.foray.app.FOInputHandler; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; import org.foray.app.SessionConfig; import org.foray.common.Logging; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,10 +25,10 @@ package org.foray.demo.servlet; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.render.awt.AWTPrintRenderer; import java.awt.print.PrinterJob ; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 17:23:07 UTC (rev 7266) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -25,10 +25,10 @@ package org.foray.demo.servlet; import org.foray.app.FOrayDocument; -import org.foray.app.FOrayException; import org.foray.app.FOraySession; import org.foray.app.FOrayTarget; import org.foray.app.InputHandler; +import org.foray.core.FOrayException; import org.foray.output.OutputTarget; import java.io.ByteArrayOutputStream; Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java (from rev 7265, trunk/foray/foray-app/src/java/org/foray/app/FOrayException.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayException.java 2006-05-26 17:48:40 UTC (rev 7267) @@ -0,0 +1,166 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.xml.sax.SAXException; + +import java.io.PrintStream; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; + +/** + * Exception thrown when FOray has a problem. + */ +public class FOrayException extends Exception { + static final long serialVersionUID = 298590433713255908L; + + private static final String EXCEPTION_SEPARATOR = "\n---------\n"; + + private Throwable _exception; + private String contextMessage; + + /** + * Create a new FOray Exception + * + * @param message descriptive message + */ + public FOrayException(String message) { + super(message); + this.contextMessage = null; + } + + public FOrayException(String message, String contextMessage) { + super(message); + this.contextMessage = contextMessage; + } + + public FOrayException(Throwable e) { + super(e.getMessage()); + setException(e); + this.contextMessage = null; + } + + public FOrayException(Throwable e, String contextMessage) { + super(e.getMessage()); + setException(e); + this.contextMessage = contextMessage; + } + + public FOrayException(String message, Throwable e) { + super(message); + setException(e); + this.contextMessage = null; + } + + public FOrayException(String message, Throwable e, String contextMessage) { + super(message); + setException(e); + this.contextMessage = contextMessage; + } + + protected void setException(Throwable t) { + _exception = t; + } + + public Throwable getException() { + return _exception; + } + + public void setContextMessage(String contextMessage) { + this.contextMessage = contextMessage; + } + + public boolean isContextSet() { + return this.contextMessage != null; + } + + protected Throwable getRootException() { + Throwable result = _exception; + + if (result instanceof SAXException) { + result = ((SAXException)result).getException(); + } + if (result instanceof InvocationTargetException) { + result = + ((InvocationTargetException)result) + .getTargetException(); + } + if (result != _exception) { + return result; + } + return null; + } + + public String getMessage() { + if (this.contextMessage != null) { + return super.getMessage() + "\n" + + this.contextMessage; + } + return super.getMessage(); + } + + public void printStackTrace() { + synchronized (System.err) { + super.printStackTrace(); + if (_exception != null) { + System.err.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(); + } + if (getRootException() != null) { + System.err.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(); + } + } + } + + public void printStackTrace(PrintStream stream) { + synchronized (stream) { + super.printStackTrace(stream); + if (_exception != null) { + stream.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(stream); + } + if (getRootException() != null) { + stream.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(stream); + } + } + } + + public void printStackTrace(PrintWriter writer) { + synchronized (writer) { + super.printStackTrace(writer); + if (_exception != null) { + writer.println(EXCEPTION_SEPARATOR); + _exception.printStackTrace(writer); + } + if (getRootException() != null) { + writer.println(EXCEPTION_SEPARATOR); + getRootException().printStackTrace(writer); + } + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |