001: /**
002: *
003: * Copyright (C) 2000-2004 Enterprise Distributed Technologies Ltd
004: *
005: * www.enterprisedt.com
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * Bug fixes, suggestions and comments should be sent to bruce@enterprisedt.com
022: *
023: * Change Log:
024: *
025: * $Log: BaseIOException.java,v $
026: * Revision 1.1 2006/03/16 21:49:54 hans
027: * Added getInnerThrowable which is used in place of getCause (which is not supported pre JDK1.4)
028: *
029: */package com.enterprisedt;
030:
031: import java.io.IOException;
032:
033: /**
034: * Extension of java.io.IOException which adds "cause" functionality.
035: * This replicates the behaviour that is already present in JDK 1.4
036: * or better.
037: *
038: * @author Hans Andersen
039: */
040: public class BaseIOException extends IOException {
041:
042: private Throwable _cause;
043:
044: /**
045: * Creates a BaseIOException with no message or cause.
046: */
047: public BaseIOException() {
048: super ();
049: }
050:
051: /**
052: * Creates a BaseIOException with the given message.
053: * @param message Exception message
054: */
055: public BaseIOException(String message) {
056: super (message);
057: }
058:
059: /**
060: * Creates a BaseIOException with the given cause.
061: * @param cause Throwable which caused this exception to be thrown.
062: */
063: public BaseIOException(Throwable cause) {
064: super (cause.getMessage());
065: _cause = cause;
066: }
067:
068: /**
069: * Creates a BaseIOException with the given cause.
070: * @param message Exception message
071: * @param cause Throwable which caused this exception to be thrown.
072: */
073: public BaseIOException(String message, Throwable cause) {
074: super (message);
075: _cause = cause;
076: }
077:
078: /**
079: * Returns the cause of this exception.
080: * Included for JDK1.4+ compatibility.
081: */
082: public Throwable getCause() {
083: return _cause;
084: }
085:
086: /**
087: * Returns the cause of this exception (same as getCause).
088: * This has a different name from JDK1.4's Exception.getCause
089: * in order to prevent cross-over behaviour.
090: */
091: public Throwable getInnerThrowable() {
092: return _cause;
093: }
094:
095: /**
096: * Initializes the cause.
097: *
098: * @param cause Throwable which caused this exception to be thrown.
099: */
100: public Throwable initCause(Throwable cause) {
101: _cause = cause;
102: return _cause;
103: }
104: }
|