001    package edu.rice.cs.cunit.threadCheck;
002    
003    /**
004     * Exception in the thread checker or its instrumentor.
005     *
006     * @author Mathias Ricken
007     */
008    public class ThreadCheckException extends RuntimeException {
009        /**
010         * Constructs a new runtime exception with <code>null</code> as its detail message.  The cause is not initialized,
011         * and may subsequently be initialized by a call to {@link #initCause}.
012         */
013        public ThreadCheckException() {
014            super();
015        }
016    
017        /**
018         * Constructs a new runtime exception with the specified detail message. The cause is not initialized, and may
019         * subsequently be initialized by a call to {@link #initCause}.
020         *
021         * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()}
022         *                method.
023         */
024        public ThreadCheckException(String message) {
025            super(message);
026        }
027    
028        /**
029         * Constructs a new runtime exception with the specified detail message and cause.  <p>Note that the detail message
030         * associated with <code>cause</code> is <i>not</i> automatically incorporated in this runtime exception's detail
031         * message.
032         *
033         * @param message the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
034         * @param cause   the cause (which is saved for later retrieval by the {@link #getCause()} method).  (A
035         *                <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.)
036         *
037         * @since 1.4
038         */
039        public ThreadCheckException(String message, Throwable cause) {
040            super(message, cause);
041        }
042    
043        /**
044         * Constructs a new runtime exception with the specified cause and a detail message of <tt>(cause==null ? null :
045         * cause.toString())</tt> (which typically contains the class and detail message of <tt>cause</tt>).  This
046         * constructor is useful for runtime exceptions that are little more than wrappers for other throwables.
047         *
048         * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).  (A <tt>null</tt>
049         *              value is permitted, and indicates that the cause is nonexistent or unknown.)
050         *
051         * @since 1.4
052         */
053        public ThreadCheckException(Throwable cause) {
054            super(cause);
055        }
056    
057    
058        /**
059         * Returns a hash code value for the object..
060         * @see Object#equals(Object)
061         * @see java.util.Hashtable
062         */
063        public int hashCode() {
064            return (getMessage() != null ? getMessage().hashCode() : 0);
065        }
066    
067        /**
068         * Indicates whether some other object is "equal to" this one.
069         * @param obj the reference object with which to compare.
070         * @return <code>true</code> if this object is the same as the obj argument; <code>false</code> otherwise.
071         * @see #hashCode()
072         * @see java.util.Hashtable
073         */
074        public boolean equals(Object obj) {
075            if (!(obj instanceof ThreadCheckException)) { return false; }
076            ThreadCheckException o = (ThreadCheckException)obj;
077            if (getMessage()!=null) { return getMessage().equals(o.getMessage()); }
078            return false;
079        }
080    }