1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/Number.java Tue Feb 26 16:54:16 2013 +0100
1.3 @@ -0,0 +1,118 @@
1.4 +/*
1.5 + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved.
1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 + *
1.8 + * This code is free software; you can redistribute it and/or modify it
1.9 + * under the terms of the GNU General Public License version 2 only, as
1.10 + * published by the Free Software Foundation. Oracle designates this
1.11 + * particular file as subject to the "Classpath" exception as provided
1.12 + * by Oracle in the LICENSE file that accompanied this code.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 + * version 2 for more details (a copy is included in the LICENSE file that
1.18 + * accompanied this code).
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License version
1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 + *
1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 + * or visit www.oracle.com if you need additional information or have any
1.26 + * questions.
1.27 + */
1.28 +
1.29 +package java.lang;
1.30 +
1.31 +import org.apidesign.bck2brwsr.core.ExtraJavaScript;
1.32 +
1.33 +/**
1.34 + * The abstract class <code>Number</code> is the superclass of classes
1.35 + * <code>BigDecimal</code>, <code>BigInteger</code>,
1.36 + * <code>Byte</code>, <code>Double</code>, <code>Float</code>,
1.37 + * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
1.38 + * <p>
1.39 + * Subclasses of <code>Number</code> must provide methods to convert
1.40 + * the represented numeric value to <code>byte</code>, <code>double</code>,
1.41 + * <code>float</code>, <code>int</code>, <code>long</code>, and
1.42 + * <code>short</code>.
1.43 + *
1.44 + * @author Lee Boynton
1.45 + * @author Arthur van Hoff
1.46 + * @see java.lang.Byte
1.47 + * @see java.lang.Double
1.48 + * @see java.lang.Float
1.49 + * @see java.lang.Integer
1.50 + * @see java.lang.Long
1.51 + * @see java.lang.Short
1.52 + * @since JDK1.0
1.53 + */
1.54 +@ExtraJavaScript(
1.55 + resource="/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js",
1.56 + processByteCode=true
1.57 +)
1.58 +public abstract class Number implements java.io.Serializable {
1.59 + /**
1.60 + * Returns the value of the specified number as an <code>int</code>.
1.61 + * This may involve rounding or truncation.
1.62 + *
1.63 + * @return the numeric value represented by this object after conversion
1.64 + * to type <code>int</code>.
1.65 + */
1.66 + public abstract int intValue();
1.67 +
1.68 + /**
1.69 + * Returns the value of the specified number as a <code>long</code>.
1.70 + * This may involve rounding or truncation.
1.71 + *
1.72 + * @return the numeric value represented by this object after conversion
1.73 + * to type <code>long</code>.
1.74 + */
1.75 + public abstract long longValue();
1.76 +
1.77 + /**
1.78 + * Returns the value of the specified number as a <code>float</code>.
1.79 + * This may involve rounding.
1.80 + *
1.81 + * @return the numeric value represented by this object after conversion
1.82 + * to type <code>float</code>.
1.83 + */
1.84 + public abstract float floatValue();
1.85 +
1.86 + /**
1.87 + * Returns the value of the specified number as a <code>double</code>.
1.88 + * This may involve rounding.
1.89 + *
1.90 + * @return the numeric value represented by this object after conversion
1.91 + * to type <code>double</code>.
1.92 + */
1.93 + public abstract double doubleValue();
1.94 +
1.95 + /**
1.96 + * Returns the value of the specified number as a <code>byte</code>.
1.97 + * This may involve rounding or truncation.
1.98 + *
1.99 + * @return the numeric value represented by this object after conversion
1.100 + * to type <code>byte</code>.
1.101 + * @since JDK1.1
1.102 + */
1.103 + public byte byteValue() {
1.104 + return (byte)intValue();
1.105 + }
1.106 +
1.107 + /**
1.108 + * Returns the value of the specified number as a <code>short</code>.
1.109 + * This may involve rounding or truncation.
1.110 + *
1.111 + * @return the numeric value represented by this object after conversion
1.112 + * to type <code>short</code>.
1.113 + * @since JDK1.1
1.114 + */
1.115 + public short shortValue() {
1.116 + return (short)intValue();
1.117 + }
1.118 +
1.119 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
1.120 + private static final long serialVersionUID = -8742448824652078965L;
1.121 +}