krysalis-update/src/java/org/krysalis/depot/common/util/throwable PortableRuntimeException.java,NONE,1.1 PortableException.java,NONE,1.1 PortableThrowable.java,NONE,1.1 PortableError.java,NONE,1.1

Nick Chalko <[email protected]> Wed, 08 Dec 2004 09:07:15 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-update/src/java/org/krysalis/depot/common/util/throwable
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24726/src/java/org/krysalis/depot/common/util/throwable

Added Files:
	PortableRuntimeException.java PortableException.java 
	PortableThrowable.java PortableError.java 
Log Message:
Copied from the apache incubator.

--- NEW FILE: PortableException.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  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.
 */

package org.krysalis.depot.common.util.throwable;

import java.io.PrintStream;
import java.io.PrintWriter;

import org.krysalis.depot.common.util.envsafe.RelativelySafe;

/**
 * @author ajack
 */
public class PortableException extends Exception {

    private Throwable m_cause = null;

    /**
     * Constructor for PortableException.
     */
    public PortableException() {
        super();
    }

    /**
     * Constructor for PortableException.
     * @param message
     */
    public PortableException(String message) {
        super(message);
    }

    /**
     * Constructor for PortableException.
     * @param message
     * @param cause
     */
    public PortableException(String message, Throwable cause) {
        super(message);

        setCause(cause);
    }

    /**
     * Constructor for PortableException.
     * @param cause
     */
    public PortableException(Throwable cause) {
        super();

        setCause(cause);
    }

    /**
     * Returns the cause.
     * @return Throwable
     */
    public Throwable getCause() {
        return m_cause;
    }

    /**
     * Sets the cause.
     * @param cause The cause to set
     */
    public void setCause(Throwable cause) {
        m_cause = cause;

        RelativelySafe.callMethod(this, "initCause", Throwable.class, cause);
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace() {
        super.printStackTrace();

        if (null != m_cause) {
            System.err.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace();
        }
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace(PrintWriter out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }

    public void printStackTrace(PrintStream out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }
}

--- NEW FILE: PortableThrowable.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  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.
 */

package org.krysalis.depot.common.util.throwable;

import java.io.PrintStream;
import java.io.PrintWriter;

import org.krysalis.depot.common.util.envsafe.RelativelySafe;

/**
 * @author ajack
 */
public class PortableThrowable extends Throwable {

    private Throwable m_cause = null;

    /**
     * Constructor for PortableThrowable.
     */
    public PortableThrowable() {
        super();
    }

    /**
     * Constructor for PortableThrowable.
     * @param message
     */
    public PortableThrowable(String message) {
        super(message);
    }

    /**
     * Constructor for PortableThrowable.
     * @param message
     * @param cause
     */
    public PortableThrowable(String message, Throwable cause) {
        super(message);
        setCause(cause);
    }

    /**
     * Constructor for PortableThrowable.
     * @param cause
     */
    public PortableThrowable(Throwable cause) {
        super();
        setCause(cause);
    }

    /**
     * Returns the cause.
     * @return Throwable
     */
    public Throwable getCause() {
        return m_cause;
    }

    /**
     * Sets the cause.
     * @param cause The cause to set
     */
    public void setCause(Throwable cause) {
        m_cause = cause;

        RelativelySafe.callMethod(this, "initCause", cause);
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace() {
        super.printStackTrace();

        if (null != m_cause) {
            System.err.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace();
        }
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace(PrintWriter out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }

    public void printStackTrace(PrintStream out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }
}

--- NEW FILE: PortableError.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  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.
 */

package org.krysalis.depot.common.util.throwable;

import java.io.PrintStream;
import java.io.PrintWriter;

import org.krysalis.depot.common.util.envsafe.RelativelySafe;

/**
 * @author ajack
 */
public class PortableError extends Error {

    private Throwable m_cause = null;

    /**
     * Constructor for PortableError.
     */
    public PortableError() {
        super();
    }

    /**
     * Constructor for PortableError.
     * @param message
     */
    public PortableError(String message) {
        super(message);
    }

    /**
     * Constructor for PortableError.
     * @param message
     * @param cause
     */
    public PortableError(String message, Throwable cause) {
        super(message);
        setCause(cause);
    }

    /**
     * Constructor for PortableError.
     * @param cause
     */
    public PortableError(Throwable cause) {
        super();
        setCause(cause);
    }

    /**
     * Returns the cause.
     * @return Throwable
     */
    public Throwable getCause() {
        return m_cause;
    }

    /**
     * Sets the cause.
     * @param cause The cause to set
     */
    public void setCause(Throwable cause) {
        m_cause = cause;

        RelativelySafe.callMethod(this, "initCause", cause);
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace() {
        super.printStackTrace();

        if (null != m_cause) {
            System.err.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace();
        }
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace(PrintWriter out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }

    public void printStackTrace(PrintStream out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }
}

--- NEW FILE: PortableRuntimeException.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  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.
 */

package org.krysalis.depot.common.util.throwable;

import java.io.PrintStream;
import java.io.PrintWriter;

import org.krysalis.depot.common.util.envsafe.RelativelySafe;

/**
 * @author ajack
 */
public class PortableRuntimeException extends RuntimeException {

    private Throwable m_cause = null;

    /**
     * Constructor for PortableRuntimeException.
     */
    public PortableRuntimeException() {
        super();
    }

    /**
     * Constructor for PortableRuntimeException.
     * @param message
     */
    public PortableRuntimeException(String message) {
        super(message);
    }

    /**
     * Constructor for PortableRuntimeException.
     * @param message
     * @param cause
     */
    public PortableRuntimeException(String message, Throwable cause) {
        super(message);
        setCause(cause);
    }

    /**
     * Constructor for PortableRuntimeException.
     * @param cause
     */
    public PortableRuntimeException(Throwable cause) {
        super();
        setCause(cause);
    }

    /**
     * Returns the cause.
     * @return Throwable
     */
    public Throwable getCause() {
        return m_cause;
    }

    /**
     * Sets the cause.
     * @param cause The cause to set
     */
    public void setCause(Throwable cause) {
        m_cause = cause;

        RelativelySafe.callMethod(this, "initCause", cause);
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace() {
        super.printStackTrace();

        if (null != m_cause) {
            System.err.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace();
        }
    }

    /**
     * @see java.lang.Throwable#printStackTrace(java.io.PrintWriter)
     */
    public void printStackTrace(PrintWriter out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }

    public void printStackTrace(PrintStream out) {
        super.printStackTrace(out);

        if (null != m_cause) {
            out.println("Caused By:" + m_cause.toString());
            m_cause.printStackTrace(out);
        }
    }
}



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/