1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/emul/src/main/java/java/lang/Number.java Fri Sep 28 17:59:03 2012 +0200
1.3 @@ -0,0 +1,112 @@
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 +/**
1.32 + * The abstract class <code>Number</code> is the superclass of classes
1.33 + * <code>BigDecimal</code>, <code>BigInteger</code>,
1.34 + * <code>Byte</code>, <code>Double</code>, <code>Float</code>,
1.35 + * <code>Integer</code>, <code>Long</code>, and <code>Short</code>.
1.36 + * <p>
1.37 + * Subclasses of <code>Number</code> must provide methods to convert
1.38 + * the represented numeric value to <code>byte</code>, <code>double</code>,
1.39 + * <code>float</code>, <code>int</code>, <code>long</code>, and
1.40 + * <code>short</code>.
1.41 + *
1.42 + * @author Lee Boynton
1.43 + * @author Arthur van Hoff
1.44 + * @see java.lang.Byte
1.45 + * @see java.lang.Double
1.46 + * @see java.lang.Float
1.47 + * @see java.lang.Integer
1.48 + * @see java.lang.Long
1.49 + * @see java.lang.Short
1.50 + * @since JDK1.0
1.51 + */
1.52 +public abstract class Number implements java.io.Serializable {
1.53 + /**
1.54 + * Returns the value of the specified number as an <code>int</code>.
1.55 + * This may involve rounding or truncation.
1.56 + *
1.57 + * @return the numeric value represented by this object after conversion
1.58 + * to type <code>int</code>.
1.59 + */
1.60 + public abstract int intValue();
1.61 +
1.62 + /**
1.63 + * Returns the value of the specified number as a <code>long</code>.
1.64 + * This may involve rounding or truncation.
1.65 + *
1.66 + * @return the numeric value represented by this object after conversion
1.67 + * to type <code>long</code>.
1.68 + */
1.69 + public abstract long longValue();
1.70 +
1.71 + /**
1.72 + * Returns the value of the specified number as a <code>float</code>.
1.73 + * This may involve rounding.
1.74 + *
1.75 + * @return the numeric value represented by this object after conversion
1.76 + * to type <code>float</code>.
1.77 + */
1.78 + public abstract float floatValue();
1.79 +
1.80 + /**
1.81 + * Returns the value of the specified number as a <code>double</code>.
1.82 + * This may involve rounding.
1.83 + *
1.84 + * @return the numeric value represented by this object after conversion
1.85 + * to type <code>double</code>.
1.86 + */
1.87 + public abstract double doubleValue();
1.88 +
1.89 + /**
1.90 + * Returns the value of the specified number as a <code>byte</code>.
1.91 + * This may involve rounding or truncation.
1.92 + *
1.93 + * @return the numeric value represented by this object after conversion
1.94 + * to type <code>byte</code>.
1.95 + * @since JDK1.1
1.96 + */
1.97 + public byte byteValue() {
1.98 + return (byte)intValue();
1.99 + }
1.100 +
1.101 + /**
1.102 + * Returns the value of the specified number as a <code>short</code>.
1.103 + * This may involve rounding or truncation.
1.104 + *
1.105 + * @return the numeric value represented by this object after conversion
1.106 + * to type <code>short</code>.
1.107 + * @since JDK1.1
1.108 + */
1.109 + public short shortValue() {
1.110 + return (short)intValue();
1.111 + }
1.112 +
1.113 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
1.114 + private static final long serialVersionUID = -8742448824652078965L;
1.115 +}