001 
002 /*
003  *  JScripter Emulation 1.0 - To Script Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (at your option) any later version.
010  *  
011  *  This program is distributed in the hope that it will be useful,
012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014  *  GNU Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package org.jscripter.emu.java.lang;
021 
022 /**
023  * <p>An <b>internal</b> class of an error thrown to indicate that an assertion has failed, emulating a standard 
024  * <tt>java.lang</tt> interface or class with the same simple name as this one.</p>
025  * <p>This interface or class is only used internally by JS re-compiler implementations.</p>
026  * <p>Please refer to <a href="http://java.sun.com/docs/">the Java API Standards</a> for detail description of the original class or interface.</p>
027  * 
028  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
029  * 
030  * @javascript Re-compilers must redirect the resolution of the emulated original Java class or interface to this one.
031  */
032 public class AssertionError extends Error
033 {
034     /**
035      * <p>Internally constructs an error of this type with no detail message.</p>
036      * @since 1.0
037      * @javascript Re-compilers must report error on end-users directly using this constructor.
038      */
039     public AssertionError() {
040     }
041 
042     private AssertionError(java.lang.String message) {
043         super(message);
044     }
045 
046     /**
047      * <p>Internally constructs an error of this type with its detail message derived from the 
048      * specified object, which is converted to a string.</p>
049      * <p>If the specified object is an instance of {@link Throwable}, it becomes the cause of the 
050      * newly constructed assertion error.</p>
051      * @param message A value to be used in constructing detail message.
052      * @since 1.0
053      * @see Throwable#getCause()
054      * @javascript Re-compilers must report error on end-users directly using this constructor.
055      */
056     public AssertionError(java.lang.Object message) {
057         super(String.valueOf((Object)message), message instanceof Throwable ? (Throwable) message : null);
058     }
059 
060     /**
061      * <p>Internally constructs an error of this type with its detail message derived from the 
062      * specified <tt>boolean</tt> value, which is converted to a string.</p>
063      * @param message A value to be used in constructing detail message.
064      * @since 1.0
065      * @javascript Re-compilers must report error on end-users directly using this constructor.
066      */
067     public AssertionError(boolean message) {
068         this(String.valueOf(message));
069     }
070 
071     /**
072      * <p>Internally constructs an error of this type with its detail message derived from the 
073      * specified <tt>char</tt> value, which is converted to a string.</p>
074      * @param message A value to be used in constructing detail message.
075      * @since 1.0
076      * @javascript Re-compilers must report error on end-users directly using this constructor.
077      */
078     public AssertionError(char message) {
079         this(String.valueOf(message));
080     }
081 
082     /**
083      * <p>Internally constructs an error of this type with its detail message derived from the 
084      * specified <tt>int</tt> value, which is converted to a string.</p>
085      * @param message A value to be used in constructing detail message.
086      * @since 1.0
087      * @javascript Re-compilers must report error on end-users directly using this constructor.
088      */
089     public AssertionError(int message) {
090         this(String.valueOf(message));
091     }
092 
093     /**
094      * <p>Internally constructs an error of this type with its detail message derived from the 
095      * specified <tt>long</tt> value, which is converted to a string.</p>
096      * @param message A value to be used in constructing detail message.
097      * @since 1.0
098      * @javascript Re-compilers must report error on end-users directly using this constructor.
099      */
100     public AssertionError(long message) {
101         this(String.valueOf(message));
102     }
103 
104     /**
105      * <p>Internally constructs an error of this type with its detail message derived from the 
106      * specified <tt>float</tt> value, which is converted to a string.</p>
107      * @param message A value to be used in constructing detail message.
108      * @since 1.0
109      * @javascript Re-compilers must report error on end-users directly using this constructor.
110      */
111     public AssertionError(float message) {
112         this(String.valueOf(message));
113     }
114 
115     /**
116      * <p>Internally constructs an error of this type with its detail message derived from the 
117      * specified <tt>double</tt> value, which is converted to a string.</p>
118      * @param message A value to be used in constructing detail message.
119      * @since 1.0
120      * @javascript Re-compilers must report error on end-users directly using this constructor.
121      */
122     public AssertionError(double message) {
123         this(String.valueOf(message));
124     }
125 }