rt/emul/mini/src/main/java/java/lang/Number.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 26 Feb 2013 16:54:16 +0100
changeset 772 d382dacfd73f
parent 555 emul/mini/src/main/java/java/lang/Number.java@cde0c2d7794e
child 783 8264f07b1f46
permissions -rw-r--r--
Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
     1 /*
     2  * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    25 
    26 package java.lang;
    27 
    28 import org.apidesign.bck2brwsr.core.ExtraJavaScript;
    29 
    30 /**
    31  * The abstract class <code>Number</code> is the superclass of classes
    32  * <code>BigDecimal</code>, <code>BigInteger</code>,
    33  * <code>Byte</code>, <code>Double</code>, <code>Float</code>,
    34  * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
    35  * <p>
    36  * Subclasses of <code>Number</code> must provide methods to convert
    37  * the represented numeric value to <code>byte</code>, <code>double</code>,
    38  * <code>float</code>, <code>int</code>, <code>long</code>, and
    39  * <code>short</code>.
    40  *
    41  * @author      Lee Boynton
    42  * @author      Arthur van Hoff
    43  * @see     java.lang.Byte
    44  * @see     java.lang.Double
    45  * @see     java.lang.Float
    46  * @see     java.lang.Integer
    47  * @see     java.lang.Long
    48  * @see     java.lang.Short
    49  * @since   JDK1.0
    50  */
    51 @ExtraJavaScript(
    52     resource="/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js",
    53     processByteCode=true
    54 )
    55 public abstract class Number implements java.io.Serializable {
    56     /**
    57      * Returns the value of the specified number as an <code>int</code>.
    58      * This may involve rounding or truncation.
    59      *
    60      * @return  the numeric value represented by this object after conversion
    61      *          to type <code>int</code>.
    62      */
    63     public abstract int intValue();
    64 
    65     /**
    66      * Returns the value of the specified number as a <code>long</code>.
    67      * This may involve rounding or truncation.
    68      *
    69      * @return  the numeric value represented by this object after conversion
    70      *          to type <code>long</code>.
    71      */
    72     public abstract long longValue();
    73 
    74     /**
    75      * Returns the value of the specified number as a <code>float</code>.
    76      * This may involve rounding.
    77      *
    78      * @return  the numeric value represented by this object after conversion
    79      *          to type <code>float</code>.
    80      */
    81     public abstract float floatValue();
    82 
    83     /**
    84      * Returns the value of the specified number as a <code>double</code>.
    85      * This may involve rounding.
    86      *
    87      * @return  the numeric value represented by this object after conversion
    88      *          to type <code>double</code>.
    89      */
    90     public abstract double doubleValue();
    91 
    92     /**
    93      * Returns the value of the specified number as a <code>byte</code>.
    94      * This may involve rounding or truncation.
    95      *
    96      * @return  the numeric value represented by this object after conversion
    97      *          to type <code>byte</code>.
    98      * @since   JDK1.1
    99      */
   100     public byte byteValue() {
   101         return (byte)intValue();
   102     }
   103 
   104     /**
   105      * Returns the value of the specified number as a <code>short</code>.
   106      * This may involve rounding or truncation.
   107      *
   108      * @return  the numeric value represented by this object after conversion
   109      *          to type <code>short</code>.
   110      * @since   JDK1.1
   111      */
   112     public short shortValue() {
   113         return (short)intValue();
   114     }
   115 
   116     /** use serialVersionUID from JDK 1.0.2 for interoperability */
   117     private static final long serialVersionUID = -8742448824652078965L;
   118 }