Merging exceptions, and etc.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/emul/src/main/java/java/lang/ArrayIndexOutOfBoundsException.java Sun Sep 30 14:37:39 2012 -0700
1.3 @@ -0,0 +1,67 @@
1.4 +/*
1.5 + * Copyright (c) 1994, 2008, 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 + * Thrown to indicate that an array has been accessed with an
1.33 + * illegal index. The index is either negative or greater than or
1.34 + * equal to the size of the array.
1.35 + *
1.36 + * @author unascribed
1.37 + * @since JDK1.0
1.38 + */
1.39 +public
1.40 +class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
1.41 + private static final long serialVersionUID = -5116101128118950844L;
1.42 +
1.43 + /**
1.44 + * Constructs an <code>ArrayIndexOutOfBoundsException</code> with no
1.45 + * detail message.
1.46 + */
1.47 + public ArrayIndexOutOfBoundsException() {
1.48 + super();
1.49 + }
1.50 +
1.51 + /**
1.52 + * Constructs a new <code>ArrayIndexOutOfBoundsException</code>
1.53 + * class with an argument indicating the illegal index.
1.54 + *
1.55 + * @param index the illegal index.
1.56 + */
1.57 + public ArrayIndexOutOfBoundsException(int index) {
1.58 + super("Array index out of range: " + index);
1.59 + }
1.60 +
1.61 + /**
1.62 + * Constructs an <code>ArrayIndexOutOfBoundsException</code> class
1.63 + * with the specified detail message.
1.64 + *
1.65 + * @param s the detail message.
1.66 + */
1.67 + public ArrayIndexOutOfBoundsException(String s) {
1.68 + super(s);
1.69 + }
1.70 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/emul/src/main/java/java/lang/AssertionError.java Sun Sep 30 14:37:39 2012 -0700
2.3 @@ -0,0 +1,167 @@
2.4 +/*
2.5 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2.7 + *
2.8 + * This code is free software; you can redistribute it and/or modify it
2.9 + * under the terms of the GNU General Public License version 2 only, as
2.10 + * published by the Free Software Foundation. Oracle designates this
2.11 + * particular file as subject to the "Classpath" exception as provided
2.12 + * by Oracle in the LICENSE file that accompanied this code.
2.13 + *
2.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
2.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2.17 + * version 2 for more details (a copy is included in the LICENSE file that
2.18 + * accompanied this code).
2.19 + *
2.20 + * You should have received a copy of the GNU General Public License version
2.21 + * 2 along with this work; if not, write to the Free Software Foundation,
2.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2.23 + *
2.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2.25 + * or visit www.oracle.com if you need additional information or have any
2.26 + * questions.
2.27 + */
2.28 +
2.29 +package java.lang;
2.30 +
2.31 +/**
2.32 + * Thrown to indicate that an assertion has failed.
2.33 + *
2.34 + * <p>The seven one-argument public constructors provided by this
2.35 + * class ensure that the assertion error returned by the invocation:
2.36 + * <pre>
2.37 + * new AssertionError(<i>expression</i>)
2.38 + * </pre>
2.39 + * has as its detail message the <i>string conversion</i> of
2.40 + * <i>expression</i> (as defined in section 15.18.1.1 of
2.41 + * <cite>The Java™ Language Specification</cite>),
2.42 + * regardless of the type of <i>expression</i>.
2.43 + *
2.44 + * @since 1.4
2.45 + */
2.46 +public class AssertionError extends Error {
2.47 + private static final long serialVersionUID = -5013299493970297370L;
2.48 +
2.49 + /**
2.50 + * Constructs an AssertionError with no detail message.
2.51 + */
2.52 + public AssertionError() {
2.53 + }
2.54 +
2.55 + /**
2.56 + * This internal constructor does no processing on its string argument,
2.57 + * even if it is a null reference. The public constructors will
2.58 + * never call this constructor with a null argument.
2.59 + */
2.60 + private AssertionError(String detailMessage) {
2.61 + super(detailMessage);
2.62 + }
2.63 +
2.64 + /**
2.65 + * Constructs an AssertionError with its detail message derived
2.66 + * from the specified object, which is converted to a string as
2.67 + * defined in section 15.18.1.1 of
2.68 + * <cite>The Java™ Language Specification</cite>.
2.69 + *<p>
2.70 + * If the specified object is an instance of {@code Throwable}, it
2.71 + * becomes the <i>cause</i> of the newly constructed assertion error.
2.72 + *
2.73 + * @param detailMessage value to be used in constructing detail message
2.74 + * @see Throwable#getCause()
2.75 + */
2.76 + public AssertionError(Object detailMessage) {
2.77 + this("" + detailMessage);
2.78 + if (detailMessage instanceof Throwable)
2.79 + initCause((Throwable) detailMessage);
2.80 + }
2.81 +
2.82 + /**
2.83 + * Constructs an AssertionError with its detail message derived
2.84 + * from the specified <code>boolean</code>, which is converted to
2.85 + * a string as defined in section 15.18.1.1 of
2.86 + * <cite>The Java™ Language Specification</cite>.
2.87 + *
2.88 + * @param detailMessage value to be used in constructing detail message
2.89 + */
2.90 + public AssertionError(boolean detailMessage) {
2.91 + this("" + detailMessage);
2.92 + }
2.93 +
2.94 + /**
2.95 + * Constructs an AssertionError with its detail message derived
2.96 + * from the specified <code>char</code>, which is converted to a
2.97 + * string as defined in section 15.18.1.1 of
2.98 + * <cite>The Java™ Language Specification</cite>.
2.99 + *
2.100 + * @param detailMessage value to be used in constructing detail message
2.101 + */
2.102 + public AssertionError(char detailMessage) {
2.103 + this("" + detailMessage);
2.104 + }
2.105 +
2.106 + /**
2.107 + * Constructs an AssertionError with its detail message derived
2.108 + * from the specified <code>int</code>, which is converted to a
2.109 + * string as defined in section 15.18.1.1 of
2.110 + * <cite>The Java™ Language Specification</cite>.
2.111 + *
2.112 + * @param detailMessage value to be used in constructing detail message
2.113 + */
2.114 + public AssertionError(int detailMessage) {
2.115 + this("" + detailMessage);
2.116 + }
2.117 +
2.118 + /**
2.119 + * Constructs an AssertionError with its detail message derived
2.120 + * from the specified <code>long</code>, which is converted to a
2.121 + * string as defined in section 15.18.1.1 of
2.122 + * <cite>The Java™ Language Specification</cite>.
2.123 + *
2.124 + * @param detailMessage value to be used in constructing detail message
2.125 + */
2.126 + public AssertionError(long detailMessage) {
2.127 + this("" + detailMessage);
2.128 + }
2.129 +
2.130 + /**
2.131 + * Constructs an AssertionError with its detail message derived
2.132 + * from the specified <code>float</code>, which is converted to a
2.133 + * string as defined in section 15.18.1.1 of
2.134 + * <cite>The Java™ Language Specification</cite>.
2.135 + *
2.136 + * @param detailMessage value to be used in constructing detail message
2.137 + */
2.138 + public AssertionError(float detailMessage) {
2.139 + this("" + detailMessage);
2.140 + }
2.141 +
2.142 + /**
2.143 + * Constructs an AssertionError with its detail message derived
2.144 + * from the specified <code>double</code>, which is converted to a
2.145 + * string as defined in section 15.18.1.1 of
2.146 + * <cite>The Java™ Language Specification</cite>.
2.147 + *
2.148 + * @param detailMessage value to be used in constructing detail message
2.149 + */
2.150 + public AssertionError(double detailMessage) {
2.151 + this("" + detailMessage);
2.152 + }
2.153 +
2.154 + /**
2.155 + * Constructs a new {@code AssertionError} with the specified
2.156 + * detail message and cause.
2.157 + *
2.158 + * <p>Note that the detail message associated with
2.159 + * {@code cause} is <i>not</i> automatically incorporated in
2.160 + * this error's detail message.
2.161 + *
2.162 + * @param message the detail message, may be {@code null}
2.163 + * @param cause the cause, may be {@code null}
2.164 + *
2.165 + * @since 1.7
2.166 + */
2.167 + public AssertionError(String message, Throwable cause) {
2.168 + super(message, cause);
2.169 + }
2.170 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/emul/src/main/java/java/lang/Byte.java Sun Sep 30 14:37:39 2012 -0700
3.3 @@ -0,0 +1,452 @@
3.4 +/*
3.5 + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3.7 + *
3.8 + * This code is free software; you can redistribute it and/or modify it
3.9 + * under the terms of the GNU General Public License version 2 only, as
3.10 + * published by the Free Software Foundation. Oracle designates this
3.11 + * particular file as subject to the "Classpath" exception as provided
3.12 + * by Oracle in the LICENSE file that accompanied this code.
3.13 + *
3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3.17 + * version 2 for more details (a copy is included in the LICENSE file that
3.18 + * accompanied this code).
3.19 + *
3.20 + * You should have received a copy of the GNU General Public License version
3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3.23 + *
3.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3.25 + * or visit www.oracle.com if you need additional information or have any
3.26 + * questions.
3.27 + */
3.28 +
3.29 +package java.lang;
3.30 +
3.31 +/**
3.32 + *
3.33 + * The {@code Byte} class wraps a value of primitive type {@code byte}
3.34 + * in an object. An object of type {@code Byte} contains a single
3.35 + * field whose type is {@code byte}.
3.36 + *
3.37 + * <p>In addition, this class provides several methods for converting
3.38 + * a {@code byte} to a {@code String} and a {@code String} to a {@code
3.39 + * byte}, as well as other constants and methods useful when dealing
3.40 + * with a {@code byte}.
3.41 + *
3.42 + * @author Nakul Saraiya
3.43 + * @author Joseph D. Darcy
3.44 + * @see java.lang.Number
3.45 + * @since JDK1.1
3.46 + */
3.47 +public final class Byte extends Number implements Comparable<Byte> {
3.48 +
3.49 + /**
3.50 + * A constant holding the minimum value a {@code byte} can
3.51 + * have, -2<sup>7</sup>.
3.52 + */
3.53 + public static final byte MIN_VALUE = -128;
3.54 +
3.55 + /**
3.56 + * A constant holding the maximum value a {@code byte} can
3.57 + * have, 2<sup>7</sup>-1.
3.58 + */
3.59 + public static final byte MAX_VALUE = 127;
3.60 +
3.61 + /**
3.62 + * The {@code Class} instance representing the primitive type
3.63 + * {@code byte}.
3.64 + */
3.65 + public static final Class<Byte> TYPE = (Class<Byte>) Class.getPrimitiveClass("byte");
3.66 +
3.67 + /**
3.68 + * Returns a new {@code String} object representing the
3.69 + * specified {@code byte}. The radix is assumed to be 10.
3.70 + *
3.71 + * @param b the {@code byte} to be converted
3.72 + * @return the string representation of the specified {@code byte}
3.73 + * @see java.lang.Integer#toString(int)
3.74 + */
3.75 + public static String toString(byte b) {
3.76 + return Integer.toString((int)b, 10);
3.77 + }
3.78 +
3.79 + private static class ByteCache {
3.80 + private ByteCache(){}
3.81 +
3.82 + static final Byte cache[] = new Byte[-(-128) + 127 + 1];
3.83 +
3.84 + static {
3.85 + for(int i = 0; i < cache.length; i++)
3.86 + cache[i] = new Byte((byte)(i - 128));
3.87 + }
3.88 + }
3.89 +
3.90 + /**
3.91 + * Returns a {@code Byte} instance representing the specified
3.92 + * {@code byte} value.
3.93 + * If a new {@code Byte} instance is not required, this method
3.94 + * should generally be used in preference to the constructor
3.95 + * {@link #Byte(byte)}, as this method is likely to yield
3.96 + * significantly better space and time performance since
3.97 + * all byte values are cached.
3.98 + *
3.99 + * @param b a byte value.
3.100 + * @return a {@code Byte} instance representing {@code b}.
3.101 + * @since 1.5
3.102 + */
3.103 + public static Byte valueOf(byte b) {
3.104 + final int offset = 128;
3.105 + return ByteCache.cache[(int)b + offset];
3.106 + }
3.107 +
3.108 + /**
3.109 + * Parses the string argument as a signed {@code byte} in the
3.110 + * radix specified by the second argument. The characters in the
3.111 + * string must all be digits, of the specified radix (as
3.112 + * determined by whether {@link java.lang.Character#digit(char,
3.113 + * int)} returns a nonnegative value) except that the first
3.114 + * character may be an ASCII minus sign {@code '-'}
3.115 + * (<code>'\u002D'</code>) to indicate a negative value or an
3.116 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
3.117 + * indicate a positive value. The resulting {@code byte} value is
3.118 + * returned.
3.119 + *
3.120 + * <p>An exception of type {@code NumberFormatException} is
3.121 + * thrown if any of the following situations occurs:
3.122 + * <ul>
3.123 + * <li> The first argument is {@code null} or is a string of
3.124 + * length zero.
3.125 + *
3.126 + * <li> The radix is either smaller than {@link
3.127 + * java.lang.Character#MIN_RADIX} or larger than {@link
3.128 + * java.lang.Character#MAX_RADIX}.
3.129 + *
3.130 + * <li> Any character of the string is not a digit of the
3.131 + * specified radix, except that the first character may be a minus
3.132 + * sign {@code '-'} (<code>'\u002D'</code>) or plus sign
3.133 + * {@code '+'} (<code>'\u002B'</code>) provided that the
3.134 + * string is longer than length 1.
3.135 + *
3.136 + * <li> The value represented by the string is not a value of type
3.137 + * {@code byte}.
3.138 + * </ul>
3.139 + *
3.140 + * @param s the {@code String} containing the
3.141 + * {@code byte}
3.142 + * representation to be parsed
3.143 + * @param radix the radix to be used while parsing {@code s}
3.144 + * @return the {@code byte} value represented by the string
3.145 + * argument in the specified radix
3.146 + * @throws NumberFormatException If the string does
3.147 + * not contain a parsable {@code byte}.
3.148 + */
3.149 + public static byte parseByte(String s, int radix)
3.150 + throws NumberFormatException {
3.151 + int i = Integer.parseInt(s, radix);
3.152 + if (i < MIN_VALUE || i > MAX_VALUE)
3.153 + throw new NumberFormatException(
3.154 + "Value out of range. Value:\"" + s + "\" Radix:" + radix);
3.155 + return (byte)i;
3.156 + }
3.157 +
3.158 + /**
3.159 + * Parses the string argument as a signed decimal {@code
3.160 + * byte}. The characters in the string must all be decimal digits,
3.161 + * except that the first character may be an ASCII minus sign
3.162 + * {@code '-'} (<code>'\u002D'</code>) to indicate a negative
3.163 + * value or an ASCII plus sign {@code '+'}
3.164 + * (<code>'\u002B'</code>) to indicate a positive value. The
3.165 + * resulting {@code byte} value is returned, exactly as if the
3.166 + * argument and the radix 10 were given as arguments to the {@link
3.167 + * #parseByte(java.lang.String, int)} method.
3.168 + *
3.169 + * @param s a {@code String} containing the
3.170 + * {@code byte} representation to be parsed
3.171 + * @return the {@code byte} value represented by the
3.172 + * argument in decimal
3.173 + * @throws NumberFormatException if the string does not
3.174 + * contain a parsable {@code byte}.
3.175 + */
3.176 + public static byte parseByte(String s) throws NumberFormatException {
3.177 + return parseByte(s, 10);
3.178 + }
3.179 +
3.180 + /**
3.181 + * Returns a {@code Byte} object holding the value
3.182 + * extracted from the specified {@code String} when parsed
3.183 + * with the radix given by the second argument. The first argument
3.184 + * is interpreted as representing a signed {@code byte} in
3.185 + * the radix specified by the second argument, exactly as if the
3.186 + * argument were given to the {@link #parseByte(java.lang.String,
3.187 + * int)} method. The result is a {@code Byte} object that
3.188 + * represents the {@code byte} value specified by the string.
3.189 + *
3.190 + * <p> In other words, this method returns a {@code Byte} object
3.191 + * equal to the value of:
3.192 + *
3.193 + * <blockquote>
3.194 + * {@code new Byte(Byte.parseByte(s, radix))}
3.195 + * </blockquote>
3.196 + *
3.197 + * @param s the string to be parsed
3.198 + * @param radix the radix to be used in interpreting {@code s}
3.199 + * @return a {@code Byte} object holding the value
3.200 + * represented by the string argument in the
3.201 + * specified radix.
3.202 + * @throws NumberFormatException If the {@code String} does
3.203 + * not contain a parsable {@code byte}.
3.204 + */
3.205 + public static Byte valueOf(String s, int radix)
3.206 + throws NumberFormatException {
3.207 + return valueOf(parseByte(s, radix));
3.208 + }
3.209 +
3.210 + /**
3.211 + * Returns a {@code Byte} object holding the value
3.212 + * given by the specified {@code String}. The argument is
3.213 + * interpreted as representing a signed decimal {@code byte},
3.214 + * exactly as if the argument were given to the {@link
3.215 + * #parseByte(java.lang.String)} method. The result is a
3.216 + * {@code Byte} object that represents the {@code byte}
3.217 + * value specified by the string.
3.218 + *
3.219 + * <p> In other words, this method returns a {@code Byte} object
3.220 + * equal to the value of:
3.221 + *
3.222 + * <blockquote>
3.223 + * {@code new Byte(Byte.parseByte(s))}
3.224 + * </blockquote>
3.225 + *
3.226 + * @param s the string to be parsed
3.227 + * @return a {@code Byte} object holding the value
3.228 + * represented by the string argument
3.229 + * @throws NumberFormatException If the {@code String} does
3.230 + * not contain a parsable {@code byte}.
3.231 + */
3.232 + public static Byte valueOf(String s) throws NumberFormatException {
3.233 + return valueOf(s, 10);
3.234 + }
3.235 +
3.236 + /**
3.237 + * Decodes a {@code String} into a {@code Byte}.
3.238 + * Accepts decimal, hexadecimal, and octal numbers given by
3.239 + * the following grammar:
3.240 + *
3.241 + * <blockquote>
3.242 + * <dl>
3.243 + * <dt><i>DecodableString:</i>
3.244 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
3.245 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
3.246 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
3.247 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
3.248 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
3.249 + * <p>
3.250 + * <dt><i>Sign:</i>
3.251 + * <dd>{@code -}
3.252 + * <dd>{@code +}
3.253 + * </dl>
3.254 + * </blockquote>
3.255 + *
3.256 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
3.257 + * are as defined in section 3.10.1 of
3.258 + * <cite>The Java™ Language Specification</cite>,
3.259 + * except that underscores are not accepted between digits.
3.260 + *
3.261 + * <p>The sequence of characters following an optional
3.262 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
3.263 + * "{@code #}", or leading zero) is parsed as by the {@code
3.264 + * Byte.parseByte} method with the indicated radix (10, 16, or 8).
3.265 + * This sequence of characters must represent a positive value or
3.266 + * a {@link NumberFormatException} will be thrown. The result is
3.267 + * negated if first character of the specified {@code String} is
3.268 + * the minus sign. No whitespace characters are permitted in the
3.269 + * {@code String}.
3.270 + *
3.271 + * @param nm the {@code String} to decode.
3.272 + * @return a {@code Byte} object holding the {@code byte}
3.273 + * value represented by {@code nm}
3.274 + * @throws NumberFormatException if the {@code String} does not
3.275 + * contain a parsable {@code byte}.
3.276 + * @see java.lang.Byte#parseByte(java.lang.String, int)
3.277 + */
3.278 + public static Byte decode(String nm) throws NumberFormatException {
3.279 + int i = Integer.decode(nm);
3.280 + if (i < MIN_VALUE || i > MAX_VALUE)
3.281 + throw new NumberFormatException(
3.282 + "Value " + i + " out of range from input " + nm);
3.283 + return valueOf((byte)i);
3.284 + }
3.285 +
3.286 + /**
3.287 + * The value of the {@code Byte}.
3.288 + *
3.289 + * @serial
3.290 + */
3.291 + private final byte value;
3.292 +
3.293 + /**
3.294 + * Constructs a newly allocated {@code Byte} object that
3.295 + * represents the specified {@code byte} value.
3.296 + *
3.297 + * @param value the value to be represented by the
3.298 + * {@code Byte}.
3.299 + */
3.300 + public Byte(byte value) {
3.301 + this.value = value;
3.302 + }
3.303 +
3.304 + /**
3.305 + * Constructs a newly allocated {@code Byte} object that
3.306 + * represents the {@code byte} value indicated by the
3.307 + * {@code String} parameter. The string is converted to a
3.308 + * {@code byte} value in exactly the manner used by the
3.309 + * {@code parseByte} method for radix 10.
3.310 + *
3.311 + * @param s the {@code String} to be converted to a
3.312 + * {@code Byte}
3.313 + * @throws NumberFormatException If the {@code String}
3.314 + * does not contain a parsable {@code byte}.
3.315 + * @see java.lang.Byte#parseByte(java.lang.String, int)
3.316 + */
3.317 + public Byte(String s) throws NumberFormatException {
3.318 + this.value = parseByte(s, 10);
3.319 + }
3.320 +
3.321 + /**
3.322 + * Returns the value of this {@code Byte} as a
3.323 + * {@code byte}.
3.324 + */
3.325 + public byte byteValue() {
3.326 + return value;
3.327 + }
3.328 +
3.329 + /**
3.330 + * Returns the value of this {@code Byte} as a
3.331 + * {@code short}.
3.332 + */
3.333 + public short shortValue() {
3.334 + return (short)value;
3.335 + }
3.336 +
3.337 + /**
3.338 + * Returns the value of this {@code Byte} as an
3.339 + * {@code int}.
3.340 + */
3.341 + public int intValue() {
3.342 + return (int)value;
3.343 + }
3.344 +
3.345 + /**
3.346 + * Returns the value of this {@code Byte} as a
3.347 + * {@code long}.
3.348 + */
3.349 + public long longValue() {
3.350 + return (long)value;
3.351 + }
3.352 +
3.353 + /**
3.354 + * Returns the value of this {@code Byte} as a
3.355 + * {@code float}.
3.356 + */
3.357 + public float floatValue() {
3.358 + return (float)value;
3.359 + }
3.360 +
3.361 + /**
3.362 + * Returns the value of this {@code Byte} as a
3.363 + * {@code double}.
3.364 + */
3.365 + public double doubleValue() {
3.366 + return (double)value;
3.367 + }
3.368 +
3.369 + /**
3.370 + * Returns a {@code String} object representing this
3.371 + * {@code Byte}'s value. The value is converted to signed
3.372 + * decimal representation and returned as a string, exactly as if
3.373 + * the {@code byte} value were given as an argument to the
3.374 + * {@link java.lang.Byte#toString(byte)} method.
3.375 + *
3.376 + * @return a string representation of the value of this object in
3.377 + * base 10.
3.378 + */
3.379 + public String toString() {
3.380 + return Integer.toString((int)value);
3.381 + }
3.382 +
3.383 + /**
3.384 + * Returns a hash code for this {@code Byte}; equal to the result
3.385 + * of invoking {@code intValue()}.
3.386 + *
3.387 + * @return a hash code value for this {@code Byte}
3.388 + */
3.389 + public int hashCode() {
3.390 + return (int)value;
3.391 + }
3.392 +
3.393 + /**
3.394 + * Compares this object to the specified object. The result is
3.395 + * {@code true} if and only if the argument is not
3.396 + * {@code null} and is a {@code Byte} object that
3.397 + * contains the same {@code byte} value as this object.
3.398 + *
3.399 + * @param obj the object to compare with
3.400 + * @return {@code true} if the objects are the same;
3.401 + * {@code false} otherwise.
3.402 + */
3.403 + public boolean equals(Object obj) {
3.404 + if (obj instanceof Byte) {
3.405 + return value == ((Byte)obj).byteValue();
3.406 + }
3.407 + return false;
3.408 + }
3.409 +
3.410 + /**
3.411 + * Compares two {@code Byte} objects numerically.
3.412 + *
3.413 + * @param anotherByte the {@code Byte} to be compared.
3.414 + * @return the value {@code 0} if this {@code Byte} is
3.415 + * equal to the argument {@code Byte}; a value less than
3.416 + * {@code 0} if this {@code Byte} is numerically less
3.417 + * than the argument {@code Byte}; and a value greater than
3.418 + * {@code 0} if this {@code Byte} is numerically
3.419 + * greater than the argument {@code Byte} (signed
3.420 + * comparison).
3.421 + * @since 1.2
3.422 + */
3.423 + public int compareTo(Byte anotherByte) {
3.424 + return compare(this.value, anotherByte.value);
3.425 + }
3.426 +
3.427 + /**
3.428 + * Compares two {@code byte} values numerically.
3.429 + * The value returned is identical to what would be returned by:
3.430 + * <pre>
3.431 + * Byte.valueOf(x).compareTo(Byte.valueOf(y))
3.432 + * </pre>
3.433 + *
3.434 + * @param x the first {@code byte} to compare
3.435 + * @param y the second {@code byte} to compare
3.436 + * @return the value {@code 0} if {@code x == y};
3.437 + * a value less than {@code 0} if {@code x < y}; and
3.438 + * a value greater than {@code 0} if {@code x > y}
3.439 + * @since 1.7
3.440 + */
3.441 + public static int compare(byte x, byte y) {
3.442 + return x - y;
3.443 + }
3.444 +
3.445 + /**
3.446 + * The number of bits used to represent a {@code byte} value in two's
3.447 + * complement binary form.
3.448 + *
3.449 + * @since 1.5
3.450 + */
3.451 + public static final int SIZE = 8;
3.452 +
3.453 + /** use serialVersionUID from JDK 1.1. for interoperability */
3.454 + private static final long serialVersionUID = -7183698231559129828L;
3.455 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/emul/src/main/java/java/lang/Character.java Sun Sep 30 14:37:39 2012 -0700
4.3 @@ -0,0 +1,7032 @@
4.4 +/*
4.5 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4.7 + *
4.8 + * This code is free software; you can redistribute it and/or modify it
4.9 + * under the terms of the GNU General Public License version 2 only, as
4.10 + * published by the Free Software Foundation. Oracle designates this
4.11 + * particular file as subject to the "Classpath" exception as provided
4.12 + * by Oracle in the LICENSE file that accompanied this code.
4.13 + *
4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4.17 + * version 2 for more details (a copy is included in the LICENSE file that
4.18 + * accompanied this code).
4.19 + *
4.20 + * You should have received a copy of the GNU General Public License version
4.21 + * 2 along with this work; if not, write to the Free Software Foundation,
4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4.23 + *
4.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4.25 + * or visit www.oracle.com if you need additional information or have any
4.26 + * questions.
4.27 + */
4.28 +
4.29 +package java.lang;
4.30 +
4.31 +import java.util.Arrays;
4.32 +import java.util.Map;
4.33 +import java.util.HashMap;
4.34 +import java.util.Locale;
4.35 +
4.36 +/**
4.37 + * The {@code Character} class wraps a value of the primitive
4.38 + * type {@code char} in an object. An object of type
4.39 + * {@code Character} contains a single field whose type is
4.40 + * {@code char}.
4.41 + * <p>
4.42 + * In addition, this class provides several methods for determining
4.43 + * a character's category (lowercase letter, digit, etc.) and for converting
4.44 + * characters from uppercase to lowercase and vice versa.
4.45 + * <p>
4.46 + * Character information is based on the Unicode Standard, version 6.0.0.
4.47 + * <p>
4.48 + * The methods and data of class {@code Character} are defined by
4.49 + * the information in the <i>UnicodeData</i> file that is part of the
4.50 + * Unicode Character Database maintained by the Unicode
4.51 + * Consortium. This file specifies various properties including name
4.52 + * and general category for every defined Unicode code point or
4.53 + * character range.
4.54 + * <p>
4.55 + * The file and its description are available from the Unicode Consortium at:
4.56 + * <ul>
4.57 + * <li><a href="http://www.unicode.org">http://www.unicode.org</a>
4.58 + * </ul>
4.59 + *
4.60 + * <h4><a name="unicode">Unicode Character Representations</a></h4>
4.61 + *
4.62 + * <p>The {@code char} data type (and therefore the value that a
4.63 + * {@code Character} object encapsulates) are based on the
4.64 + * original Unicode specification, which defined characters as
4.65 + * fixed-width 16-bit entities. The Unicode Standard has since been
4.66 + * changed to allow for characters whose representation requires more
4.67 + * than 16 bits. The range of legal <em>code point</em>s is now
4.68 + * U+0000 to U+10FFFF, known as <em>Unicode scalar value</em>.
4.69 + * (Refer to the <a
4.70 + * href="http://www.unicode.org/reports/tr27/#notation"><i>
4.71 + * definition</i></a> of the U+<i>n</i> notation in the Unicode
4.72 + * Standard.)
4.73 + *
4.74 + * <p><a name="BMP">The set of characters from U+0000 to U+FFFF is
4.75 + * sometimes referred to as the <em>Basic Multilingual Plane (BMP)</em>.
4.76 + * <a name="supplementary">Characters</a> whose code points are greater
4.77 + * than U+FFFF are called <em>supplementary character</em>s. The Java
4.78 + * platform uses the UTF-16 representation in {@code char} arrays and
4.79 + * in the {@code String} and {@code StringBuffer} classes. In
4.80 + * this representation, supplementary characters are represented as a pair
4.81 + * of {@code char} values, the first from the <em>high-surrogates</em>
4.82 + * range, (\uD800-\uDBFF), the second from the
4.83 + * <em>low-surrogates</em> range (\uDC00-\uDFFF).
4.84 + *
4.85 + * <p>A {@code char} value, therefore, represents Basic
4.86 + * Multilingual Plane (BMP) code points, including the surrogate
4.87 + * code points, or code units of the UTF-16 encoding. An
4.88 + * {@code int} value represents all Unicode code points,
4.89 + * including supplementary code points. The lower (least significant)
4.90 + * 21 bits of {@code int} are used to represent Unicode code
4.91 + * points and the upper (most significant) 11 bits must be zero.
4.92 + * Unless otherwise specified, the behavior with respect to
4.93 + * supplementary characters and surrogate {@code char} values is
4.94 + * as follows:
4.95 + *
4.96 + * <ul>
4.97 + * <li>The methods that only accept a {@code char} value cannot support
4.98 + * supplementary characters. They treat {@code char} values from the
4.99 + * surrogate ranges as undefined characters. For example,
4.100 + * {@code Character.isLetter('\u005CuD840')} returns {@code false}, even though
4.101 + * this specific value if followed by any low-surrogate value in a string
4.102 + * would represent a letter.
4.103 + *
4.104 + * <li>The methods that accept an {@code int} value support all
4.105 + * Unicode characters, including supplementary characters. For
4.106 + * example, {@code Character.isLetter(0x2F81A)} returns
4.107 + * {@code true} because the code point value represents a letter
4.108 + * (a CJK ideograph).
4.109 + * </ul>
4.110 + *
4.111 + * <p>In the Java SE API documentation, <em>Unicode code point</em> is
4.112 + * used for character values in the range between U+0000 and U+10FFFF,
4.113 + * and <em>Unicode code unit</em> is used for 16-bit
4.114 + * {@code char} values that are code units of the <em>UTF-16</em>
4.115 + * encoding. For more information on Unicode terminology, refer to the
4.116 + * <a href="http://www.unicode.org/glossary/">Unicode Glossary</a>.
4.117 + *
4.118 + * @author Lee Boynton
4.119 + * @author Guy Steele
4.120 + * @author Akira Tanaka
4.121 + * @author Martin Buchholz
4.122 + * @author Ulf Zibis
4.123 + * @since 1.0
4.124 + */
4.125 +public final
4.126 +class Character implements java.io.Serializable, Comparable<Character> {
4.127 + /**
4.128 + * The minimum radix available for conversion to and from strings.
4.129 + * The constant value of this field is the smallest value permitted
4.130 + * for the radix argument in radix-conversion methods such as the
4.131 + * {@code digit} method, the {@code forDigit} method, and the
4.132 + * {@code toString} method of class {@code Integer}.
4.133 + *
4.134 + * @see Character#digit(char, int)
4.135 + * @see Character#forDigit(int, int)
4.136 + * @see Integer#toString(int, int)
4.137 + * @see Integer#valueOf(String)
4.138 + */
4.139 + public static final int MIN_RADIX = 2;
4.140 +
4.141 + /**
4.142 + * The maximum radix available for conversion to and from strings.
4.143 + * The constant value of this field is the largest value permitted
4.144 + * for the radix argument in radix-conversion methods such as the
4.145 + * {@code digit} method, the {@code forDigit} method, and the
4.146 + * {@code toString} method of class {@code Integer}.
4.147 + *
4.148 + * @see Character#digit(char, int)
4.149 + * @see Character#forDigit(int, int)
4.150 + * @see Integer#toString(int, int)
4.151 + * @see Integer#valueOf(String)
4.152 + */
4.153 + public static final int MAX_RADIX = 36;
4.154 +
4.155 + /**
4.156 + * The constant value of this field is the smallest value of type
4.157 + * {@code char}, {@code '\u005Cu0000'}.
4.158 + *
4.159 + * @since 1.0.2
4.160 + */
4.161 + public static final char MIN_VALUE = '\u0000';
4.162 +
4.163 + /**
4.164 + * The constant value of this field is the largest value of type
4.165 + * {@code char}, {@code '\u005CuFFFF'}.
4.166 + *
4.167 + * @since 1.0.2
4.168 + */
4.169 + public static final char MAX_VALUE = '\uFFFF';
4.170 +
4.171 + /**
4.172 + * The {@code Class} instance representing the primitive type
4.173 + * {@code char}.
4.174 + *
4.175 + * @since 1.1
4.176 + */
4.177 + @SuppressWarnings("unchecked")
4.178 + public static final Class<Character> TYPE = Class.getPrimitiveClass("char");
4.179 +
4.180 + /*
4.181 + * Normative general types
4.182 + */
4.183 +
4.184 + /*
4.185 + * General character types
4.186 + */
4.187 +
4.188 + /**
4.189 + * General category "Cn" in the Unicode specification.
4.190 + * @since 1.1
4.191 + */
4.192 + public static final byte UNASSIGNED = 0;
4.193 +
4.194 + /**
4.195 + * General category "Lu" in the Unicode specification.
4.196 + * @since 1.1
4.197 + */
4.198 + public static final byte UPPERCASE_LETTER = 1;
4.199 +
4.200 + /**
4.201 + * General category "Ll" in the Unicode specification.
4.202 + * @since 1.1
4.203 + */
4.204 + public static final byte LOWERCASE_LETTER = 2;
4.205 +
4.206 + /**
4.207 + * General category "Lt" in the Unicode specification.
4.208 + * @since 1.1
4.209 + */
4.210 + public static final byte TITLECASE_LETTER = 3;
4.211 +
4.212 + /**
4.213 + * General category "Lm" in the Unicode specification.
4.214 + * @since 1.1
4.215 + */
4.216 + public static final byte MODIFIER_LETTER = 4;
4.217 +
4.218 + /**
4.219 + * General category "Lo" in the Unicode specification.
4.220 + * @since 1.1
4.221 + */
4.222 + public static final byte OTHER_LETTER = 5;
4.223 +
4.224 + /**
4.225 + * General category "Mn" in the Unicode specification.
4.226 + * @since 1.1
4.227 + */
4.228 + public static final byte NON_SPACING_MARK = 6;
4.229 +
4.230 + /**
4.231 + * General category "Me" in the Unicode specification.
4.232 + * @since 1.1
4.233 + */
4.234 + public static final byte ENCLOSING_MARK = 7;
4.235 +
4.236 + /**
4.237 + * General category "Mc" in the Unicode specification.
4.238 + * @since 1.1
4.239 + */
4.240 + public static final byte COMBINING_SPACING_MARK = 8;
4.241 +
4.242 + /**
4.243 + * General category "Nd" in the Unicode specification.
4.244 + * @since 1.1
4.245 + */
4.246 + public static final byte DECIMAL_DIGIT_NUMBER = 9;
4.247 +
4.248 + /**
4.249 + * General category "Nl" in the Unicode specification.
4.250 + * @since 1.1
4.251 + */
4.252 + public static final byte LETTER_NUMBER = 10;
4.253 +
4.254 + /**
4.255 + * General category "No" in the Unicode specification.
4.256 + * @since 1.1
4.257 + */
4.258 + public static final byte OTHER_NUMBER = 11;
4.259 +
4.260 + /**
4.261 + * General category "Zs" in the Unicode specification.
4.262 + * @since 1.1
4.263 + */
4.264 + public static final byte SPACE_SEPARATOR = 12;
4.265 +
4.266 + /**
4.267 + * General category "Zl" in the Unicode specification.
4.268 + * @since 1.1
4.269 + */
4.270 + public static final byte LINE_SEPARATOR = 13;
4.271 +
4.272 + /**
4.273 + * General category "Zp" in the Unicode specification.
4.274 + * @since 1.1
4.275 + */
4.276 + public static final byte PARAGRAPH_SEPARATOR = 14;
4.277 +
4.278 + /**
4.279 + * General category "Cc" in the Unicode specification.
4.280 + * @since 1.1
4.281 + */
4.282 + public static final byte CONTROL = 15;
4.283 +
4.284 + /**
4.285 + * General category "Cf" in the Unicode specification.
4.286 + * @since 1.1
4.287 + */
4.288 + public static final byte FORMAT = 16;
4.289 +
4.290 + /**
4.291 + * General category "Co" in the Unicode specification.
4.292 + * @since 1.1
4.293 + */
4.294 + public static final byte PRIVATE_USE = 18;
4.295 +
4.296 + /**
4.297 + * General category "Cs" in the Unicode specification.
4.298 + * @since 1.1
4.299 + */
4.300 + public static final byte SURROGATE = 19;
4.301 +
4.302 + /**
4.303 + * General category "Pd" in the Unicode specification.
4.304 + * @since 1.1
4.305 + */
4.306 + public static final byte DASH_PUNCTUATION = 20;
4.307 +
4.308 + /**
4.309 + * General category "Ps" in the Unicode specification.
4.310 + * @since 1.1
4.311 + */
4.312 + public static final byte START_PUNCTUATION = 21;
4.313 +
4.314 + /**
4.315 + * General category "Pe" in the Unicode specification.
4.316 + * @since 1.1
4.317 + */
4.318 + public static final byte END_PUNCTUATION = 22;
4.319 +
4.320 + /**
4.321 + * General category "Pc" in the Unicode specification.
4.322 + * @since 1.1
4.323 + */
4.324 + public static final byte CONNECTOR_PUNCTUATION = 23;
4.325 +
4.326 + /**
4.327 + * General category "Po" in the Unicode specification.
4.328 + * @since 1.1
4.329 + */
4.330 + public static final byte OTHER_PUNCTUATION = 24;
4.331 +
4.332 + /**
4.333 + * General category "Sm" in the Unicode specification.
4.334 + * @since 1.1
4.335 + */
4.336 + public static final byte MATH_SYMBOL = 25;
4.337 +
4.338 + /**
4.339 + * General category "Sc" in the Unicode specification.
4.340 + * @since 1.1
4.341 + */
4.342 + public static final byte CURRENCY_SYMBOL = 26;
4.343 +
4.344 + /**
4.345 + * General category "Sk" in the Unicode specification.
4.346 + * @since 1.1
4.347 + */
4.348 + public static final byte MODIFIER_SYMBOL = 27;
4.349 +
4.350 + /**
4.351 + * General category "So" in the Unicode specification.
4.352 + * @since 1.1
4.353 + */
4.354 + public static final byte OTHER_SYMBOL = 28;
4.355 +
4.356 + /**
4.357 + * General category "Pi" in the Unicode specification.
4.358 + * @since 1.4
4.359 + */
4.360 + public static final byte INITIAL_QUOTE_PUNCTUATION = 29;
4.361 +
4.362 + /**
4.363 + * General category "Pf" in the Unicode specification.
4.364 + * @since 1.4
4.365 + */
4.366 + public static final byte FINAL_QUOTE_PUNCTUATION = 30;
4.367 +
4.368 + /**
4.369 + * Error flag. Use int (code point) to avoid confusion with U+FFFF.
4.370 + */
4.371 + static final int ERROR = 0xFFFFFFFF;
4.372 +
4.373 +
4.374 + /**
4.375 + * Undefined bidirectional character type. Undefined {@code char}
4.376 + * values have undefined directionality in the Unicode specification.
4.377 + * @since 1.4
4.378 + */
4.379 + public static final byte DIRECTIONALITY_UNDEFINED = -1;
4.380 +
4.381 + /**
4.382 + * Strong bidirectional character type "L" in the Unicode specification.
4.383 + * @since 1.4
4.384 + */
4.385 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = 0;
4.386 +
4.387 + /**
4.388 + * Strong bidirectional character type "R" in the Unicode specification.
4.389 + * @since 1.4
4.390 + */
4.391 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = 1;
4.392 +
4.393 + /**
4.394 + * Strong bidirectional character type "AL" in the Unicode specification.
4.395 + * @since 1.4
4.396 + */
4.397 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2;
4.398 +
4.399 + /**
4.400 + * Weak bidirectional character type "EN" in the Unicode specification.
4.401 + * @since 1.4
4.402 + */
4.403 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = 3;
4.404 +
4.405 + /**
4.406 + * Weak bidirectional character type "ES" in the Unicode specification.
4.407 + * @since 1.4
4.408 + */
4.409 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4;
4.410 +
4.411 + /**
4.412 + * Weak bidirectional character type "ET" in the Unicode specification.
4.413 + * @since 1.4
4.414 + */
4.415 + public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5;
4.416 +
4.417 + /**
4.418 + * Weak bidirectional character type "AN" in the Unicode specification.
4.419 + * @since 1.4
4.420 + */
4.421 + public static final byte DIRECTIONALITY_ARABIC_NUMBER = 6;
4.422 +
4.423 + /**
4.424 + * Weak bidirectional character type "CS" in the Unicode specification.
4.425 + * @since 1.4
4.426 + */
4.427 + public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7;
4.428 +
4.429 + /**
4.430 + * Weak bidirectional character type "NSM" in the Unicode specification.
4.431 + * @since 1.4
4.432 + */
4.433 + public static final byte DIRECTIONALITY_NONSPACING_MARK = 8;
4.434 +
4.435 + /**
4.436 + * Weak bidirectional character type "BN" in the Unicode specification.
4.437 + * @since 1.4
4.438 + */
4.439 + public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = 9;
4.440 +
4.441 + /**
4.442 + * Neutral bidirectional character type "B" in the Unicode specification.
4.443 + * @since 1.4
4.444 + */
4.445 + public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10;
4.446 +
4.447 + /**
4.448 + * Neutral bidirectional character type "S" in the Unicode specification.
4.449 + * @since 1.4
4.450 + */
4.451 + public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = 11;
4.452 +
4.453 + /**
4.454 + * Neutral bidirectional character type "WS" in the Unicode specification.
4.455 + * @since 1.4
4.456 + */
4.457 + public static final byte DIRECTIONALITY_WHITESPACE = 12;
4.458 +
4.459 + /**
4.460 + * Neutral bidirectional character type "ON" in the Unicode specification.
4.461 + * @since 1.4
4.462 + */
4.463 + public static final byte DIRECTIONALITY_OTHER_NEUTRALS = 13;
4.464 +
4.465 + /**
4.466 + * Strong bidirectional character type "LRE" in the Unicode specification.
4.467 + * @since 1.4
4.468 + */
4.469 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14;
4.470 +
4.471 + /**
4.472 + * Strong bidirectional character type "LRO" in the Unicode specification.
4.473 + * @since 1.4
4.474 + */
4.475 + public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15;
4.476 +
4.477 + /**
4.478 + * Strong bidirectional character type "RLE" in the Unicode specification.
4.479 + * @since 1.4
4.480 + */
4.481 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16;
4.482 +
4.483 + /**
4.484 + * Strong bidirectional character type "RLO" in the Unicode specification.
4.485 + * @since 1.4
4.486 + */
4.487 + public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17;
4.488 +
4.489 + /**
4.490 + * Weak bidirectional character type "PDF" in the Unicode specification.
4.491 + * @since 1.4
4.492 + */
4.493 + public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18;
4.494 +
4.495 + /**
4.496 + * The minimum value of a
4.497 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
4.498 + * Unicode high-surrogate code unit</a>
4.499 + * in the UTF-16 encoding, constant {@code '\u005CuD800'}.
4.500 + * A high-surrogate is also known as a <i>leading-surrogate</i>.
4.501 + *
4.502 + * @since 1.5
4.503 + */
4.504 + public static final char MIN_HIGH_SURROGATE = '\uD800';
4.505 +
4.506 + /**
4.507 + * The maximum value of a
4.508 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
4.509 + * Unicode high-surrogate code unit</a>
4.510 + * in the UTF-16 encoding, constant {@code '\u005CuDBFF'}.
4.511 + * A high-surrogate is also known as a <i>leading-surrogate</i>.
4.512 + *
4.513 + * @since 1.5
4.514 + */
4.515 + public static final char MAX_HIGH_SURROGATE = '\uDBFF';
4.516 +
4.517 + /**
4.518 + * The minimum value of a
4.519 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
4.520 + * Unicode low-surrogate code unit</a>
4.521 + * in the UTF-16 encoding, constant {@code '\u005CuDC00'}.
4.522 + * A low-surrogate is also known as a <i>trailing-surrogate</i>.
4.523 + *
4.524 + * @since 1.5
4.525 + */
4.526 + public static final char MIN_LOW_SURROGATE = '\uDC00';
4.527 +
4.528 + /**
4.529 + * The maximum value of a
4.530 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
4.531 + * Unicode low-surrogate code unit</a>
4.532 + * in the UTF-16 encoding, constant {@code '\u005CuDFFF'}.
4.533 + * A low-surrogate is also known as a <i>trailing-surrogate</i>.
4.534 + *
4.535 + * @since 1.5
4.536 + */
4.537 + public static final char MAX_LOW_SURROGATE = '\uDFFF';
4.538 +
4.539 + /**
4.540 + * The minimum value of a Unicode surrogate code unit in the
4.541 + * UTF-16 encoding, constant {@code '\u005CuD800'}.
4.542 + *
4.543 + * @since 1.5
4.544 + */
4.545 + public static final char MIN_SURROGATE = MIN_HIGH_SURROGATE;
4.546 +
4.547 + /**
4.548 + * The maximum value of a Unicode surrogate code unit in the
4.549 + * UTF-16 encoding, constant {@code '\u005CuDFFF'}.
4.550 + *
4.551 + * @since 1.5
4.552 + */
4.553 + public static final char MAX_SURROGATE = MAX_LOW_SURROGATE;
4.554 +
4.555 + /**
4.556 + * The minimum value of a
4.557 + * <a href="http://www.unicode.org/glossary/#supplementary_code_point">
4.558 + * Unicode supplementary code point</a>, constant {@code U+10000}.
4.559 + *
4.560 + * @since 1.5
4.561 + */
4.562 + public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000;
4.563 +
4.564 + /**
4.565 + * The minimum value of a
4.566 + * <a href="http://www.unicode.org/glossary/#code_point">
4.567 + * Unicode code point</a>, constant {@code U+0000}.
4.568 + *
4.569 + * @since 1.5
4.570 + */
4.571 + public static final int MIN_CODE_POINT = 0x000000;
4.572 +
4.573 + /**
4.574 + * The maximum value of a
4.575 + * <a href="http://www.unicode.org/glossary/#code_point">
4.576 + * Unicode code point</a>, constant {@code U+10FFFF}.
4.577 + *
4.578 + * @since 1.5
4.579 + */
4.580 + public static final int MAX_CODE_POINT = 0X10FFFF;
4.581 +
4.582 +
4.583 + /**
4.584 + * Instances of this class represent particular subsets of the Unicode
4.585 + * character set. The only family of subsets defined in the
4.586 + * {@code Character} class is {@link Character.UnicodeBlock}.
4.587 + * Other portions of the Java API may define other subsets for their
4.588 + * own purposes.
4.589 + *
4.590 + * @since 1.2
4.591 + */
4.592 + public static class Subset {
4.593 +
4.594 + private String name;
4.595 +
4.596 + /**
4.597 + * Constructs a new {@code Subset} instance.
4.598 + *
4.599 + * @param name The name of this subset
4.600 + * @exception NullPointerException if name is {@code null}
4.601 + */
4.602 + protected Subset(String name) {
4.603 + if (name == null) {
4.604 + throw new NullPointerException("name");
4.605 + }
4.606 + this.name = name;
4.607 + }
4.608 +
4.609 + /**
4.610 + * Compares two {@code Subset} objects for equality.
4.611 + * This method returns {@code true} if and only if
4.612 + * {@code this} and the argument refer to the same
4.613 + * object; since this method is {@code final}, this
4.614 + * guarantee holds for all subclasses.
4.615 + */
4.616 + public final boolean equals(Object obj) {
4.617 + return (this == obj);
4.618 + }
4.619 +
4.620 + /**
4.621 + * Returns the standard hash code as defined by the
4.622 + * {@link Object#hashCode} method. This method
4.623 + * is {@code final} in order to ensure that the
4.624 + * {@code equals} and {@code hashCode} methods will
4.625 + * be consistent in all subclasses.
4.626 + */
4.627 + public final int hashCode() {
4.628 + return super.hashCode();
4.629 + }
4.630 +
4.631 + /**
4.632 + * Returns the name of this subset.
4.633 + */
4.634 + public final String toString() {
4.635 + return name;
4.636 + }
4.637 + }
4.638 +
4.639 + // See http://www.unicode.org/Public/UNIDATA/Blocks.txt
4.640 + // for the latest specification of Unicode Blocks.
4.641 +
4.642 + /**
4.643 + * A family of character subsets representing the character blocks in the
4.644 + * Unicode specification. Character blocks generally define characters
4.645 + * used for a specific script or purpose. A character is contained by
4.646 + * at most one Unicode block.
4.647 + *
4.648 + * @since 1.2
4.649 + */
4.650 + public static final class UnicodeBlock extends Subset {
4.651 +
4.652 + private static Map<String, UnicodeBlock> map = new HashMap<>(256);
4.653 +
4.654 + /**
4.655 + * Creates a UnicodeBlock with the given identifier name.
4.656 + * This name must be the same as the block identifier.
4.657 + */
4.658 + private UnicodeBlock(String idName) {
4.659 + super(idName);
4.660 + map.put(idName, this);
4.661 + }
4.662 +
4.663 + /**
4.664 + * Creates a UnicodeBlock with the given identifier name and
4.665 + * alias name.
4.666 + */
4.667 + private UnicodeBlock(String idName, String alias) {
4.668 + this(idName);
4.669 + map.put(alias, this);
4.670 + }
4.671 +
4.672 + /**
4.673 + * Creates a UnicodeBlock with the given identifier name and
4.674 + * alias names.
4.675 + */
4.676 + private UnicodeBlock(String idName, String... aliases) {
4.677 + this(idName);
4.678 + for (String alias : aliases)
4.679 + map.put(alias, this);
4.680 + }
4.681 +
4.682 + /**
4.683 + * Constant for the "Basic Latin" Unicode character block.
4.684 + * @since 1.2
4.685 + */
4.686 + public static final UnicodeBlock BASIC_LATIN =
4.687 + new UnicodeBlock("BASIC_LATIN",
4.688 + "BASIC LATIN",
4.689 + "BASICLATIN");
4.690 +
4.691 + /**
4.692 + * Constant for the "Latin-1 Supplement" Unicode character block.
4.693 + * @since 1.2
4.694 + */
4.695 + public static final UnicodeBlock LATIN_1_SUPPLEMENT =
4.696 + new UnicodeBlock("LATIN_1_SUPPLEMENT",
4.697 + "LATIN-1 SUPPLEMENT",
4.698 + "LATIN-1SUPPLEMENT");
4.699 +
4.700 + /**
4.701 + * Constant for the "Latin Extended-A" Unicode character block.
4.702 + * @since 1.2
4.703 + */
4.704 + public static final UnicodeBlock LATIN_EXTENDED_A =
4.705 + new UnicodeBlock("LATIN_EXTENDED_A",
4.706 + "LATIN EXTENDED-A",
4.707 + "LATINEXTENDED-A");
4.708 +
4.709 + /**
4.710 + * Constant for the "Latin Extended-B" Unicode character block.
4.711 + * @since 1.2
4.712 + */
4.713 + public static final UnicodeBlock LATIN_EXTENDED_B =
4.714 + new UnicodeBlock("LATIN_EXTENDED_B",
4.715 + "LATIN EXTENDED-B",
4.716 + "LATINEXTENDED-B");
4.717 +
4.718 + /**
4.719 + * Constant for the "IPA Extensions" Unicode character block.
4.720 + * @since 1.2
4.721 + */
4.722 + public static final UnicodeBlock IPA_EXTENSIONS =
4.723 + new UnicodeBlock("IPA_EXTENSIONS",
4.724 + "IPA EXTENSIONS",
4.725 + "IPAEXTENSIONS");
4.726 +
4.727 + /**
4.728 + * Constant for the "Spacing Modifier Letters" Unicode character block.
4.729 + * @since 1.2
4.730 + */
4.731 + public static final UnicodeBlock SPACING_MODIFIER_LETTERS =
4.732 + new UnicodeBlock("SPACING_MODIFIER_LETTERS",
4.733 + "SPACING MODIFIER LETTERS",
4.734 + "SPACINGMODIFIERLETTERS");
4.735 +
4.736 + /**
4.737 + * Constant for the "Combining Diacritical Marks" Unicode character block.
4.738 + * @since 1.2
4.739 + */
4.740 + public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS =
4.741 + new UnicodeBlock("COMBINING_DIACRITICAL_MARKS",
4.742 + "COMBINING DIACRITICAL MARKS",
4.743 + "COMBININGDIACRITICALMARKS");
4.744 +
4.745 + /**
4.746 + * Constant for the "Greek and Coptic" Unicode character block.
4.747 + * <p>
4.748 + * This block was previously known as the "Greek" block.
4.749 + *
4.750 + * @since 1.2
4.751 + */
4.752 + public static final UnicodeBlock GREEK =
4.753 + new UnicodeBlock("GREEK",
4.754 + "GREEK AND COPTIC",
4.755 + "GREEKANDCOPTIC");
4.756 +
4.757 + /**
4.758 + * Constant for the "Cyrillic" Unicode character block.
4.759 + * @since 1.2
4.760 + */
4.761 + public static final UnicodeBlock CYRILLIC =
4.762 + new UnicodeBlock("CYRILLIC");
4.763 +
4.764 + /**
4.765 + * Constant for the "Armenian" Unicode character block.
4.766 + * @since 1.2
4.767 + */
4.768 + public static final UnicodeBlock ARMENIAN =
4.769 + new UnicodeBlock("ARMENIAN");
4.770 +
4.771 + /**
4.772 + * Constant for the "Hebrew" Unicode character block.
4.773 + * @since 1.2
4.774 + */
4.775 + public static final UnicodeBlock HEBREW =
4.776 + new UnicodeBlock("HEBREW");
4.777 +
4.778 + /**
4.779 + * Constant for the "Arabic" Unicode character block.
4.780 + * @since 1.2
4.781 + */
4.782 + public static final UnicodeBlock ARABIC =
4.783 + new UnicodeBlock("ARABIC");
4.784 +
4.785 + /**
4.786 + * Constant for the "Devanagari" Unicode character block.
4.787 + * @since 1.2
4.788 + */
4.789 + public static final UnicodeBlock DEVANAGARI =
4.790 + new UnicodeBlock("DEVANAGARI");
4.791 +
4.792 + /**
4.793 + * Constant for the "Bengali" Unicode character block.
4.794 + * @since 1.2
4.795 + */
4.796 + public static final UnicodeBlock BENGALI =
4.797 + new UnicodeBlock("BENGALI");
4.798 +
4.799 + /**
4.800 + * Constant for the "Gurmukhi" Unicode character block.
4.801 + * @since 1.2
4.802 + */
4.803 + public static final UnicodeBlock GURMUKHI =
4.804 + new UnicodeBlock("GURMUKHI");
4.805 +
4.806 + /**
4.807 + * Constant for the "Gujarati" Unicode character block.
4.808 + * @since 1.2
4.809 + */
4.810 + public static final UnicodeBlock GUJARATI =
4.811 + new UnicodeBlock("GUJARATI");
4.812 +
4.813 + /**
4.814 + * Constant for the "Oriya" Unicode character block.
4.815 + * @since 1.2
4.816 + */
4.817 + public static final UnicodeBlock ORIYA =
4.818 + new UnicodeBlock("ORIYA");
4.819 +
4.820 + /**
4.821 + * Constant for the "Tamil" Unicode character block.
4.822 + * @since 1.2
4.823 + */
4.824 + public static final UnicodeBlock TAMIL =
4.825 + new UnicodeBlock("TAMIL");
4.826 +
4.827 + /**
4.828 + * Constant for the "Telugu" Unicode character block.
4.829 + * @since 1.2
4.830 + */
4.831 + public static final UnicodeBlock TELUGU =
4.832 + new UnicodeBlock("TELUGU");
4.833 +
4.834 + /**
4.835 + * Constant for the "Kannada" Unicode character block.
4.836 + * @since 1.2
4.837 + */
4.838 + public static final UnicodeBlock KANNADA =
4.839 + new UnicodeBlock("KANNADA");
4.840 +
4.841 + /**
4.842 + * Constant for the "Malayalam" Unicode character block.
4.843 + * @since 1.2
4.844 + */
4.845 + public static final UnicodeBlock MALAYALAM =
4.846 + new UnicodeBlock("MALAYALAM");
4.847 +
4.848 + /**
4.849 + * Constant for the "Thai" Unicode character block.
4.850 + * @since 1.2
4.851 + */
4.852 + public static final UnicodeBlock THAI =
4.853 + new UnicodeBlock("THAI");
4.854 +
4.855 + /**
4.856 + * Constant for the "Lao" Unicode character block.
4.857 + * @since 1.2
4.858 + */
4.859 + public static final UnicodeBlock LAO =
4.860 + new UnicodeBlock("LAO");
4.861 +
4.862 + /**
4.863 + * Constant for the "Tibetan" Unicode character block.
4.864 + * @since 1.2
4.865 + */
4.866 + public static final UnicodeBlock TIBETAN =
4.867 + new UnicodeBlock("TIBETAN");
4.868 +
4.869 + /**
4.870 + * Constant for the "Georgian" Unicode character block.
4.871 + * @since 1.2
4.872 + */
4.873 + public static final UnicodeBlock GEORGIAN =
4.874 + new UnicodeBlock("GEORGIAN");
4.875 +
4.876 + /**
4.877 + * Constant for the "Hangul Jamo" Unicode character block.
4.878 + * @since 1.2
4.879 + */
4.880 + public static final UnicodeBlock HANGUL_JAMO =
4.881 + new UnicodeBlock("HANGUL_JAMO",
4.882 + "HANGUL JAMO",
4.883 + "HANGULJAMO");
4.884 +
4.885 + /**
4.886 + * Constant for the "Latin Extended Additional" Unicode character block.
4.887 + * @since 1.2
4.888 + */
4.889 + public static final UnicodeBlock LATIN_EXTENDED_ADDITIONAL =
4.890 + new UnicodeBlock("LATIN_EXTENDED_ADDITIONAL",
4.891 + "LATIN EXTENDED ADDITIONAL",
4.892 + "LATINEXTENDEDADDITIONAL");
4.893 +
4.894 + /**
4.895 + * Constant for the "Greek Extended" Unicode character block.
4.896 + * @since 1.2
4.897 + */
4.898 + public static final UnicodeBlock GREEK_EXTENDED =
4.899 + new UnicodeBlock("GREEK_EXTENDED",
4.900 + "GREEK EXTENDED",
4.901 + "GREEKEXTENDED");
4.902 +
4.903 + /**
4.904 + * Constant for the "General Punctuation" Unicode character block.
4.905 + * @since 1.2
4.906 + */
4.907 + public static final UnicodeBlock GENERAL_PUNCTUATION =
4.908 + new UnicodeBlock("GENERAL_PUNCTUATION",
4.909 + "GENERAL PUNCTUATION",
4.910 + "GENERALPUNCTUATION");
4.911 +
4.912 + /**
4.913 + * Constant for the "Superscripts and Subscripts" Unicode character
4.914 + * block.
4.915 + * @since 1.2
4.916 + */
4.917 + public static final UnicodeBlock SUPERSCRIPTS_AND_SUBSCRIPTS =
4.918 + new UnicodeBlock("SUPERSCRIPTS_AND_SUBSCRIPTS",
4.919 + "SUPERSCRIPTS AND SUBSCRIPTS",
4.920 + "SUPERSCRIPTSANDSUBSCRIPTS");
4.921 +
4.922 + /**
4.923 + * Constant for the "Currency Symbols" Unicode character block.
4.924 + * @since 1.2
4.925 + */
4.926 + public static final UnicodeBlock CURRENCY_SYMBOLS =
4.927 + new UnicodeBlock("CURRENCY_SYMBOLS",
4.928 + "CURRENCY SYMBOLS",
4.929 + "CURRENCYSYMBOLS");
4.930 +
4.931 + /**
4.932 + * Constant for the "Combining Diacritical Marks for Symbols" Unicode
4.933 + * character block.
4.934 + * <p>
4.935 + * This block was previously known as "Combining Marks for Symbols".
4.936 + * @since 1.2
4.937 + */
4.938 + public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS =
4.939 + new UnicodeBlock("COMBINING_MARKS_FOR_SYMBOLS",
4.940 + "COMBINING DIACRITICAL MARKS FOR SYMBOLS",
4.941 + "COMBININGDIACRITICALMARKSFORSYMBOLS",
4.942 + "COMBINING MARKS FOR SYMBOLS",
4.943 + "COMBININGMARKSFORSYMBOLS");
4.944 +
4.945 + /**
4.946 + * Constant for the "Letterlike Symbols" Unicode character block.
4.947 + * @since 1.2
4.948 + */
4.949 + public static final UnicodeBlock LETTERLIKE_SYMBOLS =
4.950 + new UnicodeBlock("LETTERLIKE_SYMBOLS",
4.951 + "LETTERLIKE SYMBOLS",
4.952 + "LETTERLIKESYMBOLS");
4.953 +
4.954 + /**
4.955 + * Constant for the "Number Forms" Unicode character block.
4.956 + * @since 1.2
4.957 + */
4.958 + public static final UnicodeBlock NUMBER_FORMS =
4.959 + new UnicodeBlock("NUMBER_FORMS",
4.960 + "NUMBER FORMS",
4.961 + "NUMBERFORMS");
4.962 +
4.963 + /**
4.964 + * Constant for the "Arrows" Unicode character block.
4.965 + * @since 1.2
4.966 + */
4.967 + public static final UnicodeBlock ARROWS =
4.968 + new UnicodeBlock("ARROWS");
4.969 +
4.970 + /**
4.971 + * Constant for the "Mathematical Operators" Unicode character block.
4.972 + * @since 1.2
4.973 + */
4.974 + public static final UnicodeBlock MATHEMATICAL_OPERATORS =
4.975 + new UnicodeBlock("MATHEMATICAL_OPERATORS",
4.976 + "MATHEMATICAL OPERATORS",
4.977 + "MATHEMATICALOPERATORS");
4.978 +
4.979 + /**
4.980 + * Constant for the "Miscellaneous Technical" Unicode character block.
4.981 + * @since 1.2
4.982 + */
4.983 + public static final UnicodeBlock MISCELLANEOUS_TECHNICAL =
4.984 + new UnicodeBlock("MISCELLANEOUS_TECHNICAL",
4.985 + "MISCELLANEOUS TECHNICAL",
4.986 + "MISCELLANEOUSTECHNICAL");
4.987 +
4.988 + /**
4.989 + * Constant for the "Control Pictures" Unicode character block.
4.990 + * @since 1.2
4.991 + */
4.992 + public static final UnicodeBlock CONTROL_PICTURES =
4.993 + new UnicodeBlock("CONTROL_PICTURES",
4.994 + "CONTROL PICTURES",
4.995 + "CONTROLPICTURES");
4.996 +
4.997 + /**
4.998 + * Constant for the "Optical Character Recognition" Unicode character block.
4.999 + * @since 1.2
4.1000 + */
4.1001 + public static final UnicodeBlock OPTICAL_CHARACTER_RECOGNITION =
4.1002 + new UnicodeBlock("OPTICAL_CHARACTER_RECOGNITION",
4.1003 + "OPTICAL CHARACTER RECOGNITION",
4.1004 + "OPTICALCHARACTERRECOGNITION");
4.1005 +
4.1006 + /**
4.1007 + * Constant for the "Enclosed Alphanumerics" Unicode character block.
4.1008 + * @since 1.2
4.1009 + */
4.1010 + public static final UnicodeBlock ENCLOSED_ALPHANUMERICS =
4.1011 + new UnicodeBlock("ENCLOSED_ALPHANUMERICS",
4.1012 + "ENCLOSED ALPHANUMERICS",
4.1013 + "ENCLOSEDALPHANUMERICS");
4.1014 +
4.1015 + /**
4.1016 + * Constant for the "Box Drawing" Unicode character block.
4.1017 + * @since 1.2
4.1018 + */
4.1019 + public static final UnicodeBlock BOX_DRAWING =
4.1020 + new UnicodeBlock("BOX_DRAWING",
4.1021 + "BOX DRAWING",
4.1022 + "BOXDRAWING");
4.1023 +
4.1024 + /**
4.1025 + * Constant for the "Block Elements" Unicode character block.
4.1026 + * @since 1.2
4.1027 + */
4.1028 + public static final UnicodeBlock BLOCK_ELEMENTS =
4.1029 + new UnicodeBlock("BLOCK_ELEMENTS",
4.1030 + "BLOCK ELEMENTS",
4.1031 + "BLOCKELEMENTS");
4.1032 +
4.1033 + /**
4.1034 + * Constant for the "Geometric Shapes" Unicode character block.
4.1035 + * @since 1.2
4.1036 + */
4.1037 + public static final UnicodeBlock GEOMETRIC_SHAPES =
4.1038 + new UnicodeBlock("GEOMETRIC_SHAPES",
4.1039 + "GEOMETRIC SHAPES",
4.1040 + "GEOMETRICSHAPES");
4.1041 +
4.1042 + /**
4.1043 + * Constant for the "Miscellaneous Symbols" Unicode character block.
4.1044 + * @since 1.2
4.1045 + */
4.1046 + public static final UnicodeBlock MISCELLANEOUS_SYMBOLS =
4.1047 + new UnicodeBlock("MISCELLANEOUS_SYMBOLS",
4.1048 + "MISCELLANEOUS SYMBOLS",
4.1049 + "MISCELLANEOUSSYMBOLS");
4.1050 +
4.1051 + /**
4.1052 + * Constant for the "Dingbats" Unicode character block.
4.1053 + * @since 1.2
4.1054 + */
4.1055 + public static final UnicodeBlock DINGBATS =
4.1056 + new UnicodeBlock("DINGBATS");
4.1057 +
4.1058 + /**
4.1059 + * Constant for the "CJK Symbols and Punctuation" Unicode character block.
4.1060 + * @since 1.2
4.1061 + */
4.1062 + public static final UnicodeBlock CJK_SYMBOLS_AND_PUNCTUATION =
4.1063 + new UnicodeBlock("CJK_SYMBOLS_AND_PUNCTUATION",
4.1064 + "CJK SYMBOLS AND PUNCTUATION",
4.1065 + "CJKSYMBOLSANDPUNCTUATION");
4.1066 +
4.1067 + /**
4.1068 + * Constant for the "Hiragana" Unicode character block.
4.1069 + * @since 1.2
4.1070 + */
4.1071 + public static final UnicodeBlock HIRAGANA =
4.1072 + new UnicodeBlock("HIRAGANA");
4.1073 +
4.1074 + /**
4.1075 + * Constant for the "Katakana" Unicode character block.
4.1076 + * @since 1.2
4.1077 + */
4.1078 + public static final UnicodeBlock KATAKANA =
4.1079 + new UnicodeBlock("KATAKANA");
4.1080 +
4.1081 + /**
4.1082 + * Constant for the "Bopomofo" Unicode character block.
4.1083 + * @since 1.2
4.1084 + */
4.1085 + public static final UnicodeBlock BOPOMOFO =
4.1086 + new UnicodeBlock("BOPOMOFO");
4.1087 +
4.1088 + /**
4.1089 + * Constant for the "Hangul Compatibility Jamo" Unicode character block.
4.1090 + * @since 1.2
4.1091 + */
4.1092 + public static final UnicodeBlock HANGUL_COMPATIBILITY_JAMO =
4.1093 + new UnicodeBlock("HANGUL_COMPATIBILITY_JAMO",
4.1094 + "HANGUL COMPATIBILITY JAMO",
4.1095 + "HANGULCOMPATIBILITYJAMO");
4.1096 +
4.1097 + /**
4.1098 + * Constant for the "Kanbun" Unicode character block.
4.1099 + * @since 1.2
4.1100 + */
4.1101 + public static final UnicodeBlock KANBUN =
4.1102 + new UnicodeBlock("KANBUN");
4.1103 +
4.1104 + /**
4.1105 + * Constant for the "Enclosed CJK Letters and Months" Unicode character block.
4.1106 + * @since 1.2
4.1107 + */
4.1108 + public static final UnicodeBlock ENCLOSED_CJK_LETTERS_AND_MONTHS =
4.1109 + new UnicodeBlock("ENCLOSED_CJK_LETTERS_AND_MONTHS",
4.1110 + "ENCLOSED CJK LETTERS AND MONTHS",
4.1111 + "ENCLOSEDCJKLETTERSANDMONTHS");
4.1112 +
4.1113 + /**
4.1114 + * Constant for the "CJK Compatibility" Unicode character block.
4.1115 + * @since 1.2
4.1116 + */
4.1117 + public static final UnicodeBlock CJK_COMPATIBILITY =
4.1118 + new UnicodeBlock("CJK_COMPATIBILITY",
4.1119 + "CJK COMPATIBILITY",
4.1120 + "CJKCOMPATIBILITY");
4.1121 +
4.1122 + /**
4.1123 + * Constant for the "CJK Unified Ideographs" Unicode character block.
4.1124 + * @since 1.2
4.1125 + */
4.1126 + public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS =
4.1127 + new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS",
4.1128 + "CJK UNIFIED IDEOGRAPHS",
4.1129 + "CJKUNIFIEDIDEOGRAPHS");
4.1130 +
4.1131 + /**
4.1132 + * Constant for the "Hangul Syllables" Unicode character block.
4.1133 + * @since 1.2
4.1134 + */
4.1135 + public static final UnicodeBlock HANGUL_SYLLABLES =
4.1136 + new UnicodeBlock("HANGUL_SYLLABLES",
4.1137 + "HANGUL SYLLABLES",
4.1138 + "HANGULSYLLABLES");
4.1139 +
4.1140 + /**
4.1141 + * Constant for the "Private Use Area" Unicode character block.
4.1142 + * @since 1.2
4.1143 + */
4.1144 + public static final UnicodeBlock PRIVATE_USE_AREA =
4.1145 + new UnicodeBlock("PRIVATE_USE_AREA",
4.1146 + "PRIVATE USE AREA",
4.1147 + "PRIVATEUSEAREA");
4.1148 +
4.1149 + /**
4.1150 + * Constant for the "CJK Compatibility Ideographs" Unicode character
4.1151 + * block.
4.1152 + * @since 1.2
4.1153 + */
4.1154 + public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS =
4.1155 + new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS",
4.1156 + "CJK COMPATIBILITY IDEOGRAPHS",
4.1157 + "CJKCOMPATIBILITYIDEOGRAPHS");
4.1158 +
4.1159 + /**
4.1160 + * Constant for the "Alphabetic Presentation Forms" Unicode character block.
4.1161 + * @since 1.2
4.1162 + */
4.1163 + public static final UnicodeBlock ALPHABETIC_PRESENTATION_FORMS =
4.1164 + new UnicodeBlock("ALPHABETIC_PRESENTATION_FORMS",
4.1165 + "ALPHABETIC PRESENTATION FORMS",
4.1166 + "ALPHABETICPRESENTATIONFORMS");
4.1167 +
4.1168 + /**
4.1169 + * Constant for the "Arabic Presentation Forms-A" Unicode character
4.1170 + * block.
4.1171 + * @since 1.2
4.1172 + */
4.1173 + public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_A =
4.1174 + new UnicodeBlock("ARABIC_PRESENTATION_FORMS_A",
4.1175 + "ARABIC PRESENTATION FORMS-A",
4.1176 + "ARABICPRESENTATIONFORMS-A");
4.1177 +
4.1178 + /**
4.1179 + * Constant for the "Combining Half Marks" Unicode character block.
4.1180 + * @since 1.2
4.1181 + */
4.1182 + public static final UnicodeBlock COMBINING_HALF_MARKS =
4.1183 + new UnicodeBlock("COMBINING_HALF_MARKS",
4.1184 + "COMBINING HALF MARKS",
4.1185 + "COMBININGHALFMARKS");
4.1186 +
4.1187 + /**
4.1188 + * Constant for the "CJK Compatibility Forms" Unicode character block.
4.1189 + * @since 1.2
4.1190 + */
4.1191 + public static final UnicodeBlock CJK_COMPATIBILITY_FORMS =
4.1192 + new UnicodeBlock("CJK_COMPATIBILITY_FORMS",
4.1193 + "CJK COMPATIBILITY FORMS",
4.1194 + "CJKCOMPATIBILITYFORMS");
4.1195 +
4.1196 + /**
4.1197 + * Constant for the "Small Form Variants" Unicode character block.
4.1198 + * @since 1.2
4.1199 + */
4.1200 + public static final UnicodeBlock SMALL_FORM_VARIANTS =
4.1201 + new UnicodeBlock("SMALL_FORM_VARIANTS",
4.1202 + "SMALL FORM VARIANTS",
4.1203 + "SMALLFORMVARIANTS");
4.1204 +
4.1205 + /**
4.1206 + * Constant for the "Arabic Presentation Forms-B" Unicode character block.
4.1207 + * @since 1.2
4.1208 + */
4.1209 + public static final UnicodeBlock ARABIC_PRESENTATION_FORMS_B =
4.1210 + new UnicodeBlock("ARABIC_PRESENTATION_FORMS_B",
4.1211 + "ARABIC PRESENTATION FORMS-B",
4.1212 + "ARABICPRESENTATIONFORMS-B");
4.1213 +
4.1214 + /**
4.1215 + * Constant for the "Halfwidth and Fullwidth Forms" Unicode character
4.1216 + * block.
4.1217 + * @since 1.2
4.1218 + */
4.1219 + public static final UnicodeBlock HALFWIDTH_AND_FULLWIDTH_FORMS =
4.1220 + new UnicodeBlock("HALFWIDTH_AND_FULLWIDTH_FORMS",
4.1221 + "HALFWIDTH AND FULLWIDTH FORMS",
4.1222 + "HALFWIDTHANDFULLWIDTHFORMS");
4.1223 +
4.1224 + /**
4.1225 + * Constant for the "Specials" Unicode character block.
4.1226 + * @since 1.2
4.1227 + */
4.1228 + public static final UnicodeBlock SPECIALS =
4.1229 + new UnicodeBlock("SPECIALS");
4.1230 +
4.1231 + /**
4.1232 + * @deprecated As of J2SE 5, use {@link #HIGH_SURROGATES},
4.1233 + * {@link #HIGH_PRIVATE_USE_SURROGATES}, and
4.1234 + * {@link #LOW_SURROGATES}. These new constants match
4.1235 + * the block definitions of the Unicode Standard.
4.1236 + * The {@link #of(char)} and {@link #of(int)} methods
4.1237 + * return the new constants, not SURROGATES_AREA.
4.1238 + */
4.1239 + @Deprecated
4.1240 + public static final UnicodeBlock SURROGATES_AREA =
4.1241 + new UnicodeBlock("SURROGATES_AREA");
4.1242 +
4.1243 + /**
4.1244 + * Constant for the "Syriac" Unicode character block.
4.1245 + * @since 1.4
4.1246 + */
4.1247 + public static final UnicodeBlock SYRIAC =
4.1248 + new UnicodeBlock("SYRIAC");
4.1249 +
4.1250 + /**
4.1251 + * Constant for the "Thaana" Unicode character block.
4.1252 + * @since 1.4
4.1253 + */
4.1254 + public static final UnicodeBlock THAANA =
4.1255 + new UnicodeBlock("THAANA");
4.1256 +
4.1257 + /**
4.1258 + * Constant for the "Sinhala" Unicode character block.
4.1259 + * @since 1.4
4.1260 + */
4.1261 + public static final UnicodeBlock SINHALA =
4.1262 + new UnicodeBlock("SINHALA");
4.1263 +
4.1264 + /**
4.1265 + * Constant for the "Myanmar" Unicode character block.
4.1266 + * @since 1.4
4.1267 + */
4.1268 + public static final UnicodeBlock MYANMAR =
4.1269 + new UnicodeBlock("MYANMAR");
4.1270 +
4.1271 + /**
4.1272 + * Constant for the "Ethiopic" Unicode character block.
4.1273 + * @since 1.4
4.1274 + */
4.1275 + public static final UnicodeBlock ETHIOPIC =
4.1276 + new UnicodeBlock("ETHIOPIC");
4.1277 +
4.1278 + /**
4.1279 + * Constant for the "Cherokee" Unicode character block.
4.1280 + * @since 1.4
4.1281 + */
4.1282 + public static final UnicodeBlock CHEROKEE =
4.1283 + new UnicodeBlock("CHEROKEE");
4.1284 +
4.1285 + /**
4.1286 + * Constant for the "Unified Canadian Aboriginal Syllabics" Unicode character block.
4.1287 + * @since 1.4
4.1288 + */
4.1289 + public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS =
4.1290 + new UnicodeBlock("UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS",
4.1291 + "UNIFIED CANADIAN ABORIGINAL SYLLABICS",
4.1292 + "UNIFIEDCANADIANABORIGINALSYLLABICS");
4.1293 +
4.1294 + /**
4.1295 + * Constant for the "Ogham" Unicode character block.
4.1296 + * @since 1.4
4.1297 + */
4.1298 + public static final UnicodeBlock OGHAM =
4.1299 + new UnicodeBlock("OGHAM");
4.1300 +
4.1301 + /**
4.1302 + * Constant for the "Runic" Unicode character block.
4.1303 + * @since 1.4
4.1304 + */
4.1305 + public static final UnicodeBlock RUNIC =
4.1306 + new UnicodeBlock("RUNIC");
4.1307 +
4.1308 + /**
4.1309 + * Constant for the "Khmer" Unicode character block.
4.1310 + * @since 1.4
4.1311 + */
4.1312 + public static final UnicodeBlock KHMER =
4.1313 + new UnicodeBlock("KHMER");
4.1314 +
4.1315 + /**
4.1316 + * Constant for the "Mongolian" Unicode character block.
4.1317 + * @since 1.4
4.1318 + */
4.1319 + public static final UnicodeBlock MONGOLIAN =
4.1320 + new UnicodeBlock("MONGOLIAN");
4.1321 +
4.1322 + /**
4.1323 + * Constant for the "Braille Patterns" Unicode character block.
4.1324 + * @since 1.4
4.1325 + */
4.1326 + public static final UnicodeBlock BRAILLE_PATTERNS =
4.1327 + new UnicodeBlock("BRAILLE_PATTERNS",
4.1328 + "BRAILLE PATTERNS",
4.1329 + "BRAILLEPATTERNS");
4.1330 +
4.1331 + /**
4.1332 + * Constant for the "CJK Radicals Supplement" Unicode character block.
4.1333 + * @since 1.4
4.1334 + */
4.1335 + public static final UnicodeBlock CJK_RADICALS_SUPPLEMENT =
4.1336 + new UnicodeBlock("CJK_RADICALS_SUPPLEMENT",
4.1337 + "CJK RADICALS SUPPLEMENT",
4.1338 + "CJKRADICALSSUPPLEMENT");
4.1339 +
4.1340 + /**
4.1341 + * Constant for the "Kangxi Radicals" Unicode character block.
4.1342 + * @since 1.4
4.1343 + */
4.1344 + public static final UnicodeBlock KANGXI_RADICALS =
4.1345 + new UnicodeBlock("KANGXI_RADICALS",
4.1346 + "KANGXI RADICALS",
4.1347 + "KANGXIRADICALS");
4.1348 +
4.1349 + /**
4.1350 + * Constant for the "Ideographic Description Characters" Unicode character block.
4.1351 + * @since 1.4
4.1352 + */
4.1353 + public static final UnicodeBlock IDEOGRAPHIC_DESCRIPTION_CHARACTERS =
4.1354 + new UnicodeBlock("IDEOGRAPHIC_DESCRIPTION_CHARACTERS",
4.1355 + "IDEOGRAPHIC DESCRIPTION CHARACTERS",
4.1356 + "IDEOGRAPHICDESCRIPTIONCHARACTERS");
4.1357 +
4.1358 + /**
4.1359 + * Constant for the "Bopomofo Extended" Unicode character block.
4.1360 + * @since 1.4
4.1361 + */
4.1362 + public static final UnicodeBlock BOPOMOFO_EXTENDED =
4.1363 + new UnicodeBlock("BOPOMOFO_EXTENDED",
4.1364 + "BOPOMOFO EXTENDED",
4.1365 + "BOPOMOFOEXTENDED");
4.1366 +
4.1367 + /**
4.1368 + * Constant for the "CJK Unified Ideographs Extension A" Unicode character block.
4.1369 + * @since 1.4
4.1370 + */
4.1371 + public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A =
4.1372 + new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A",
4.1373 + "CJK UNIFIED IDEOGRAPHS EXTENSION A",
4.1374 + "CJKUNIFIEDIDEOGRAPHSEXTENSIONA");
4.1375 +
4.1376 + /**
4.1377 + * Constant for the "Yi Syllables" Unicode character block.
4.1378 + * @since 1.4
4.1379 + */
4.1380 + public static final UnicodeBlock YI_SYLLABLES =
4.1381 + new UnicodeBlock("YI_SYLLABLES",
4.1382 + "YI SYLLABLES",
4.1383 + "YISYLLABLES");
4.1384 +
4.1385 + /**
4.1386 + * Constant for the "Yi Radicals" Unicode character block.
4.1387 + * @since 1.4
4.1388 + */
4.1389 + public static final UnicodeBlock YI_RADICALS =
4.1390 + new UnicodeBlock("YI_RADICALS",
4.1391 + "YI RADICALS",
4.1392 + "YIRADICALS");
4.1393 +
4.1394 + /**
4.1395 + * Constant for the "Cyrillic Supplementary" Unicode character block.
4.1396 + * @since 1.5
4.1397 + */
4.1398 + public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY =
4.1399 + new UnicodeBlock("CYRILLIC_SUPPLEMENTARY",
4.1400 + "CYRILLIC SUPPLEMENTARY",
4.1401 + "CYRILLICSUPPLEMENTARY",
4.1402 + "CYRILLIC SUPPLEMENT",
4.1403 + "CYRILLICSUPPLEMENT");
4.1404 +
4.1405 + /**
4.1406 + * Constant for the "Tagalog" Unicode character block.
4.1407 + * @since 1.5
4.1408 + */
4.1409 + public static final UnicodeBlock TAGALOG =
4.1410 + new UnicodeBlock("TAGALOG");
4.1411 +
4.1412 + /**
4.1413 + * Constant for the "Hanunoo" Unicode character block.
4.1414 + * @since 1.5
4.1415 + */
4.1416 + public static final UnicodeBlock HANUNOO =
4.1417 + new UnicodeBlock("HANUNOO");
4.1418 +
4.1419 + /**
4.1420 + * Constant for the "Buhid" Unicode character block.
4.1421 + * @since 1.5
4.1422 + */
4.1423 + public static final UnicodeBlock BUHID =
4.1424 + new UnicodeBlock("BUHID");
4.1425 +
4.1426 + /**
4.1427 + * Constant for the "Tagbanwa" Unicode character block.
4.1428 + * @since 1.5
4.1429 + */
4.1430 + public static final UnicodeBlock TAGBANWA =
4.1431 + new UnicodeBlock("TAGBANWA");
4.1432 +
4.1433 + /**
4.1434 + * Constant for the "Limbu" Unicode character block.
4.1435 + * @since 1.5
4.1436 + */
4.1437 + public static final UnicodeBlock LIMBU =
4.1438 + new UnicodeBlock("LIMBU");
4.1439 +
4.1440 + /**
4.1441 + * Constant for the "Tai Le" Unicode character block.
4.1442 + * @since 1.5
4.1443 + */
4.1444 + public static final UnicodeBlock TAI_LE =
4.1445 + new UnicodeBlock("TAI_LE",
4.1446 + "TAI LE",
4.1447 + "TAILE");
4.1448 +
4.1449 + /**
4.1450 + * Constant for the "Khmer Symbols" Unicode character block.
4.1451 + * @since 1.5
4.1452 + */
4.1453 + public static final UnicodeBlock KHMER_SYMBOLS =
4.1454 + new UnicodeBlock("KHMER_SYMBOLS",
4.1455 + "KHMER SYMBOLS",
4.1456 + "KHMERSYMBOLS");
4.1457 +
4.1458 + /**
4.1459 + * Constant for the "Phonetic Extensions" Unicode character block.
4.1460 + * @since 1.5
4.1461 + */
4.1462 + public static final UnicodeBlock PHONETIC_EXTENSIONS =
4.1463 + new UnicodeBlock("PHONETIC_EXTENSIONS",
4.1464 + "PHONETIC EXTENSIONS",
4.1465 + "PHONETICEXTENSIONS");
4.1466 +
4.1467 + /**
4.1468 + * Constant for the "Miscellaneous Mathematical Symbols-A" Unicode character block.
4.1469 + * @since 1.5
4.1470 + */
4.1471 + public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A =
4.1472 + new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A",
4.1473 + "MISCELLANEOUS MATHEMATICAL SYMBOLS-A",
4.1474 + "MISCELLANEOUSMATHEMATICALSYMBOLS-A");
4.1475 +
4.1476 + /**
4.1477 + * Constant for the "Supplemental Arrows-A" Unicode character block.
4.1478 + * @since 1.5
4.1479 + */
4.1480 + public static final UnicodeBlock SUPPLEMENTAL_ARROWS_A =
4.1481 + new UnicodeBlock("SUPPLEMENTAL_ARROWS_A",
4.1482 + "SUPPLEMENTAL ARROWS-A",
4.1483 + "SUPPLEMENTALARROWS-A");
4.1484 +
4.1485 + /**
4.1486 + * Constant for the "Supplemental Arrows-B" Unicode character block.
4.1487 + * @since 1.5
4.1488 + */
4.1489 + public static final UnicodeBlock SUPPLEMENTAL_ARROWS_B =
4.1490 + new UnicodeBlock("SUPPLEMENTAL_ARROWS_B",
4.1491 + "SUPPLEMENTAL ARROWS-B",
4.1492 + "SUPPLEMENTALARROWS-B");
4.1493 +
4.1494 + /**
4.1495 + * Constant for the "Miscellaneous Mathematical Symbols-B" Unicode
4.1496 + * character block.
4.1497 + * @since 1.5
4.1498 + */
4.1499 + public static final UnicodeBlock MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B =
4.1500 + new UnicodeBlock("MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B",
4.1501 + "MISCELLANEOUS MATHEMATICAL SYMBOLS-B",
4.1502 + "MISCELLANEOUSMATHEMATICALSYMBOLS-B");
4.1503 +
4.1504 + /**
4.1505 + * Constant for the "Supplemental Mathematical Operators" Unicode
4.1506 + * character block.
4.1507 + * @since 1.5
4.1508 + */
4.1509 + public static final UnicodeBlock SUPPLEMENTAL_MATHEMATICAL_OPERATORS =
4.1510 + new UnicodeBlock("SUPPLEMENTAL_MATHEMATICAL_OPERATORS",
4.1511 + "SUPPLEMENTAL MATHEMATICAL OPERATORS",
4.1512 + "SUPPLEMENTALMATHEMATICALOPERATORS");
4.1513 +
4.1514 + /**
4.1515 + * Constant for the "Miscellaneous Symbols and Arrows" Unicode character
4.1516 + * block.
4.1517 + * @since 1.5
4.1518 + */
4.1519 + public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_ARROWS =
4.1520 + new UnicodeBlock("MISCELLANEOUS_SYMBOLS_AND_ARROWS",
4.1521 + "MISCELLANEOUS SYMBOLS AND ARROWS",
4.1522 + "MISCELLANEOUSSYMBOLSANDARROWS");
4.1523 +
4.1524 + /**
4.1525 + * Constant for the "Katakana Phonetic Extensions" Unicode character
4.1526 + * block.
4.1527 + * @since 1.5
4.1528 + */
4.1529 + public static final UnicodeBlock KATAKANA_PHONETIC_EXTENSIONS =
4.1530 + new UnicodeBlock("KATAKANA_PHONETIC_EXTENSIONS",
4.1531 + "KATAKANA PHONETIC EXTENSIONS",
4.1532 + "KATAKANAPHONETICEXTENSIONS");
4.1533 +
4.1534 + /**
4.1535 + * Constant for the "Yijing Hexagram Symbols" Unicode character block.
4.1536 + * @since 1.5
4.1537 + */
4.1538 + public static final UnicodeBlock YIJING_HEXAGRAM_SYMBOLS =
4.1539 + new UnicodeBlock("YIJING_HEXAGRAM_SYMBOLS",
4.1540 + "YIJING HEXAGRAM SYMBOLS",
4.1541 + "YIJINGHEXAGRAMSYMBOLS");
4.1542 +
4.1543 + /**
4.1544 + * Constant for the "Variation Selectors" Unicode character block.
4.1545 + * @since 1.5
4.1546 + */
4.1547 + public static final UnicodeBlock VARIATION_SELECTORS =
4.1548 + new UnicodeBlock("VARIATION_SELECTORS",
4.1549 + "VARIATION SELECTORS",
4.1550 + "VARIATIONSELECTORS");
4.1551 +
4.1552 + /**
4.1553 + * Constant for the "Linear B Syllabary" Unicode character block.
4.1554 + * @since 1.5
4.1555 + */
4.1556 + public static final UnicodeBlock LINEAR_B_SYLLABARY =
4.1557 + new UnicodeBlock("LINEAR_B_SYLLABARY",
4.1558 + "LINEAR B SYLLABARY",
4.1559 + "LINEARBSYLLABARY");
4.1560 +
4.1561 + /**
4.1562 + * Constant for the "Linear B Ideograms" Unicode character block.
4.1563 + * @since 1.5
4.1564 + */
4.1565 + public static final UnicodeBlock LINEAR_B_IDEOGRAMS =
4.1566 + new UnicodeBlock("LINEAR_B_IDEOGRAMS",
4.1567 + "LINEAR B IDEOGRAMS",
4.1568 + "LINEARBIDEOGRAMS");
4.1569 +
4.1570 + /**
4.1571 + * Constant for the "Aegean Numbers" Unicode character block.
4.1572 + * @since 1.5
4.1573 + */
4.1574 + public static final UnicodeBlock AEGEAN_NUMBERS =
4.1575 + new UnicodeBlock("AEGEAN_NUMBERS",
4.1576 + "AEGEAN NUMBERS",
4.1577 + "AEGEANNUMBERS");
4.1578 +
4.1579 + /**
4.1580 + * Constant for the "Old Italic" Unicode character block.
4.1581 + * @since 1.5
4.1582 + */
4.1583 + public static final UnicodeBlock OLD_ITALIC =
4.1584 + new UnicodeBlock("OLD_ITALIC",
4.1585 + "OLD ITALIC",
4.1586 + "OLDITALIC");
4.1587 +
4.1588 + /**
4.1589 + * Constant for the "Gothic" Unicode character block.
4.1590 + * @since 1.5
4.1591 + */
4.1592 + public static final UnicodeBlock GOTHIC =
4.1593 + new UnicodeBlock("GOTHIC");
4.1594 +
4.1595 + /**
4.1596 + * Constant for the "Ugaritic" Unicode character block.
4.1597 + * @since 1.5
4.1598 + */
4.1599 + public static final UnicodeBlock UGARITIC =
4.1600 + new UnicodeBlock("UGARITIC");
4.1601 +
4.1602 + /**
4.1603 + * Constant for the "Deseret" Unicode character block.
4.1604 + * @since 1.5
4.1605 + */
4.1606 + public static final UnicodeBlock DESERET =
4.1607 + new UnicodeBlock("DESERET");
4.1608 +
4.1609 + /**
4.1610 + * Constant for the "Shavian" Unicode character block.
4.1611 + * @since 1.5
4.1612 + */
4.1613 + public static final UnicodeBlock SHAVIAN =
4.1614 + new UnicodeBlock("SHAVIAN");
4.1615 +
4.1616 + /**
4.1617 + * Constant for the "Osmanya" Unicode character block.
4.1618 + * @since 1.5
4.1619 + */
4.1620 + public static final UnicodeBlock OSMANYA =
4.1621 + new UnicodeBlock("OSMANYA");
4.1622 +
4.1623 + /**
4.1624 + * Constant for the "Cypriot Syllabary" Unicode character block.
4.1625 + * @since 1.5
4.1626 + */
4.1627 + public static final UnicodeBlock CYPRIOT_SYLLABARY =
4.1628 + new UnicodeBlock("CYPRIOT_SYLLABARY",
4.1629 + "CYPRIOT SYLLABARY",
4.1630 + "CYPRIOTSYLLABARY");
4.1631 +
4.1632 + /**
4.1633 + * Constant for the "Byzantine Musical Symbols" Unicode character block.
4.1634 + * @since 1.5
4.1635 + */
4.1636 + public static final UnicodeBlock BYZANTINE_MUSICAL_SYMBOLS =
4.1637 + new UnicodeBlock("BYZANTINE_MUSICAL_SYMBOLS",
4.1638 + "BYZANTINE MUSICAL SYMBOLS",
4.1639 + "BYZANTINEMUSICALSYMBOLS");
4.1640 +
4.1641 + /**
4.1642 + * Constant for the "Musical Symbols" Unicode character block.
4.1643 + * @since 1.5
4.1644 + */
4.1645 + public static final UnicodeBlock MUSICAL_SYMBOLS =
4.1646 + new UnicodeBlock("MUSICAL_SYMBOLS",
4.1647 + "MUSICAL SYMBOLS",
4.1648 + "MUSICALSYMBOLS");
4.1649 +
4.1650 + /**
4.1651 + * Constant for the "Tai Xuan Jing Symbols" Unicode character block.
4.1652 + * @since 1.5
4.1653 + */
4.1654 + public static final UnicodeBlock TAI_XUAN_JING_SYMBOLS =
4.1655 + new UnicodeBlock("TAI_XUAN_JING_SYMBOLS",
4.1656 + "TAI XUAN JING SYMBOLS",
4.1657 + "TAIXUANJINGSYMBOLS");
4.1658 +
4.1659 + /**
4.1660 + * Constant for the "Mathematical Alphanumeric Symbols" Unicode
4.1661 + * character block.
4.1662 + * @since 1.5
4.1663 + */
4.1664 + public static final UnicodeBlock MATHEMATICAL_ALPHANUMERIC_SYMBOLS =
4.1665 + new UnicodeBlock("MATHEMATICAL_ALPHANUMERIC_SYMBOLS",
4.1666 + "MATHEMATICAL ALPHANUMERIC SYMBOLS",
4.1667 + "MATHEMATICALALPHANUMERICSYMBOLS");
4.1668 +
4.1669 + /**
4.1670 + * Constant for the "CJK Unified Ideographs Extension B" Unicode
4.1671 + * character block.
4.1672 + * @since 1.5
4.1673 + */
4.1674 + public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B =
4.1675 + new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B",
4.1676 + "CJK UNIFIED IDEOGRAPHS EXTENSION B",
4.1677 + "CJKUNIFIEDIDEOGRAPHSEXTENSIONB");
4.1678 +
4.1679 + /**
4.1680 + * Constant for the "CJK Compatibility Ideographs Supplement" Unicode character block.
4.1681 + * @since 1.5
4.1682 + */
4.1683 + public static final UnicodeBlock CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT =
4.1684 + new UnicodeBlock("CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT",
4.1685 + "CJK COMPATIBILITY IDEOGRAPHS SUPPLEMENT",
4.1686 + "CJKCOMPATIBILITYIDEOGRAPHSSUPPLEMENT");
4.1687 +
4.1688 + /**
4.1689 + * Constant for the "Tags" Unicode character block.
4.1690 + * @since 1.5
4.1691 + */
4.1692 + public static final UnicodeBlock TAGS =
4.1693 + new UnicodeBlock("TAGS");
4.1694 +
4.1695 + /**
4.1696 + * Constant for the "Variation Selectors Supplement" Unicode character
4.1697 + * block.
4.1698 + * @since 1.5
4.1699 + */
4.1700 + public static final UnicodeBlock VARIATION_SELECTORS_SUPPLEMENT =
4.1701 + new UnicodeBlock("VARIATION_SELECTORS_SUPPLEMENT",
4.1702 + "VARIATION SELECTORS SUPPLEMENT",
4.1703 + "VARIATIONSELECTORSSUPPLEMENT");
4.1704 +
4.1705 + /**
4.1706 + * Constant for the "Supplementary Private Use Area-A" Unicode character
4.1707 + * block.
4.1708 + * @since 1.5
4.1709 + */
4.1710 + public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_A =
4.1711 + new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_A",
4.1712 + "SUPPLEMENTARY PRIVATE USE AREA-A",
4.1713 + "SUPPLEMENTARYPRIVATEUSEAREA-A");
4.1714 +
4.1715 + /**
4.1716 + * Constant for the "Supplementary Private Use Area-B" Unicode character
4.1717 + * block.
4.1718 + * @since 1.5
4.1719 + */
4.1720 + public static final UnicodeBlock SUPPLEMENTARY_PRIVATE_USE_AREA_B =
4.1721 + new UnicodeBlock("SUPPLEMENTARY_PRIVATE_USE_AREA_B",
4.1722 + "SUPPLEMENTARY PRIVATE USE AREA-B",
4.1723 + "SUPPLEMENTARYPRIVATEUSEAREA-B");
4.1724 +
4.1725 + /**
4.1726 + * Constant for the "High Surrogates" Unicode character block.
4.1727 + * This block represents codepoint values in the high surrogate
4.1728 + * range: U+D800 through U+DB7F
4.1729 + *
4.1730 + * @since 1.5
4.1731 + */
4.1732 + public static final UnicodeBlock HIGH_SURROGATES =
4.1733 + new UnicodeBlock("HIGH_SURROGATES",
4.1734 + "HIGH SURROGATES",
4.1735 + "HIGHSURROGATES");
4.1736 +
4.1737 + /**
4.1738 + * Constant for the "High Private Use Surrogates" Unicode character
4.1739 + * block.
4.1740 + * This block represents codepoint values in the private use high
4.1741 + * surrogate range: U+DB80 through U+DBFF
4.1742 + *
4.1743 + * @since 1.5
4.1744 + */
4.1745 + public static final UnicodeBlock HIGH_PRIVATE_USE_SURROGATES =
4.1746 + new UnicodeBlock("HIGH_PRIVATE_USE_SURROGATES",
4.1747 + "HIGH PRIVATE USE SURROGATES",
4.1748 + "HIGHPRIVATEUSESURROGATES");
4.1749 +
4.1750 + /**
4.1751 + * Constant for the "Low Surrogates" Unicode character block.
4.1752 + * This block represents codepoint values in the low surrogate
4.1753 + * range: U+DC00 through U+DFFF
4.1754 + *
4.1755 + * @since 1.5
4.1756 + */
4.1757 + public static final UnicodeBlock LOW_SURROGATES =
4.1758 + new UnicodeBlock("LOW_SURROGATES",
4.1759 + "LOW SURROGATES",
4.1760 + "LOWSURROGATES");
4.1761 +
4.1762 + /**
4.1763 + * Constant for the "Arabic Supplement" Unicode character block.
4.1764 + * @since 1.7
4.1765 + */
4.1766 + public static final UnicodeBlock ARABIC_SUPPLEMENT =
4.1767 + new UnicodeBlock("ARABIC_SUPPLEMENT",
4.1768 + "ARABIC SUPPLEMENT",
4.1769 + "ARABICSUPPLEMENT");
4.1770 +
4.1771 + /**
4.1772 + * Constant for the "NKo" Unicode character block.
4.1773 + * @since 1.7
4.1774 + */
4.1775 + public static final UnicodeBlock NKO =
4.1776 + new UnicodeBlock("NKO");
4.1777 +
4.1778 + /**
4.1779 + * Constant for the "Samaritan" Unicode character block.
4.1780 + * @since 1.7
4.1781 + */
4.1782 + public static final UnicodeBlock SAMARITAN =
4.1783 + new UnicodeBlock("SAMARITAN");
4.1784 +
4.1785 + /**
4.1786 + * Constant for the "Mandaic" Unicode character block.
4.1787 + * @since 1.7
4.1788 + */
4.1789 + public static final UnicodeBlock MANDAIC =
4.1790 + new UnicodeBlock("MANDAIC");
4.1791 +
4.1792 + /**
4.1793 + * Constant for the "Ethiopic Supplement" Unicode character block.
4.1794 + * @since 1.7
4.1795 + */
4.1796 + public static final UnicodeBlock ETHIOPIC_SUPPLEMENT =
4.1797 + new UnicodeBlock("ETHIOPIC_SUPPLEMENT",
4.1798 + "ETHIOPIC SUPPLEMENT",
4.1799 + "ETHIOPICSUPPLEMENT");
4.1800 +
4.1801 + /**
4.1802 + * Constant for the "Unified Canadian Aboriginal Syllabics Extended"
4.1803 + * Unicode character block.
4.1804 + * @since 1.7
4.1805 + */
4.1806 + public static final UnicodeBlock UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED =
4.1807 + new UnicodeBlock("UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED",
4.1808 + "UNIFIED CANADIAN ABORIGINAL SYLLABICS EXTENDED",
4.1809 + "UNIFIEDCANADIANABORIGINALSYLLABICSEXTENDED");
4.1810 +
4.1811 + /**
4.1812 + * Constant for the "New Tai Lue" Unicode character block.
4.1813 + * @since 1.7
4.1814 + */
4.1815 + public static final UnicodeBlock NEW_TAI_LUE =
4.1816 + new UnicodeBlock("NEW_TAI_LUE",
4.1817 + "NEW TAI LUE",
4.1818 + "NEWTAILUE");
4.1819 +
4.1820 + /**
4.1821 + * Constant for the "Buginese" Unicode character block.
4.1822 + * @since 1.7
4.1823 + */
4.1824 + public static final UnicodeBlock BUGINESE =
4.1825 + new UnicodeBlock("BUGINESE");
4.1826 +
4.1827 + /**
4.1828 + * Constant for the "Tai Tham" Unicode character block.
4.1829 + * @since 1.7
4.1830 + */
4.1831 + public static final UnicodeBlock TAI_THAM =
4.1832 + new UnicodeBlock("TAI_THAM",
4.1833 + "TAI THAM",
4.1834 + "TAITHAM");
4.1835 +
4.1836 + /**
4.1837 + * Constant for the "Balinese" Unicode character block.
4.1838 + * @since 1.7
4.1839 + */
4.1840 + public static final UnicodeBlock BALINESE =
4.1841 + new UnicodeBlock("BALINESE");
4.1842 +
4.1843 + /**
4.1844 + * Constant for the "Sundanese" Unicode character block.
4.1845 + * @since 1.7
4.1846 + */
4.1847 + public static final UnicodeBlock SUNDANESE =
4.1848 + new UnicodeBlock("SUNDANESE");
4.1849 +
4.1850 + /**
4.1851 + * Constant for the "Batak" Unicode character block.
4.1852 + * @since 1.7
4.1853 + */
4.1854 + public static final UnicodeBlock BATAK =
4.1855 + new UnicodeBlock("BATAK");
4.1856 +
4.1857 + /**
4.1858 + * Constant for the "Lepcha" Unicode character block.
4.1859 + * @since 1.7
4.1860 + */
4.1861 + public static final UnicodeBlock LEPCHA =
4.1862 + new UnicodeBlock("LEPCHA");
4.1863 +
4.1864 + /**
4.1865 + * Constant for the "Ol Chiki" Unicode character block.
4.1866 + * @since 1.7
4.1867 + */
4.1868 + public static final UnicodeBlock OL_CHIKI =
4.1869 + new UnicodeBlock("OL_CHIKI",
4.1870 + "OL CHIKI",
4.1871 + "OLCHIKI");
4.1872 +
4.1873 + /**
4.1874 + * Constant for the "Vedic Extensions" Unicode character block.
4.1875 + * @since 1.7
4.1876 + */
4.1877 + public static final UnicodeBlock VEDIC_EXTENSIONS =
4.1878 + new UnicodeBlock("VEDIC_EXTENSIONS",
4.1879 + "VEDIC EXTENSIONS",
4.1880 + "VEDICEXTENSIONS");
4.1881 +
4.1882 + /**
4.1883 + * Constant for the "Phonetic Extensions Supplement" Unicode character
4.1884 + * block.
4.1885 + * @since 1.7
4.1886 + */
4.1887 + public static final UnicodeBlock PHONETIC_EXTENSIONS_SUPPLEMENT =
4.1888 + new UnicodeBlock("PHONETIC_EXTENSIONS_SUPPLEMENT",
4.1889 + "PHONETIC EXTENSIONS SUPPLEMENT",
4.1890 + "PHONETICEXTENSIONSSUPPLEMENT");
4.1891 +
4.1892 + /**
4.1893 + * Constant for the "Combining Diacritical Marks Supplement" Unicode
4.1894 + * character block.
4.1895 + * @since 1.7
4.1896 + */
4.1897 + public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS_SUPPLEMENT =
4.1898 + new UnicodeBlock("COMBINING_DIACRITICAL_MARKS_SUPPLEMENT",
4.1899 + "COMBINING DIACRITICAL MARKS SUPPLEMENT",
4.1900 + "COMBININGDIACRITICALMARKSSUPPLEMENT");
4.1901 +
4.1902 + /**
4.1903 + * Constant for the "Glagolitic" Unicode character block.
4.1904 + * @since 1.7
4.1905 + */
4.1906 + public static final UnicodeBlock GLAGOLITIC =
4.1907 + new UnicodeBlock("GLAGOLITIC");
4.1908 +
4.1909 + /**
4.1910 + * Constant for the "Latin Extended-C" Unicode character block.
4.1911 + * @since 1.7
4.1912 + */
4.1913 + public static final UnicodeBlock LATIN_EXTENDED_C =
4.1914 + new UnicodeBlock("LATIN_EXTENDED_C",
4.1915 + "LATIN EXTENDED-C",
4.1916 + "LATINEXTENDED-C");
4.1917 +
4.1918 + /**
4.1919 + * Constant for the "Coptic" Unicode character block.
4.1920 + * @since 1.7
4.1921 + */
4.1922 + public static final UnicodeBlock COPTIC =
4.1923 + new UnicodeBlock("COPTIC");
4.1924 +
4.1925 + /**
4.1926 + * Constant for the "Georgian Supplement" Unicode character block.
4.1927 + * @since 1.7
4.1928 + */
4.1929 + public static final UnicodeBlock GEORGIAN_SUPPLEMENT =
4.1930 + new UnicodeBlock("GEORGIAN_SUPPLEMENT",
4.1931 + "GEORGIAN SUPPLEMENT",
4.1932 + "GEORGIANSUPPLEMENT");
4.1933 +
4.1934 + /**
4.1935 + * Constant for the "Tifinagh" Unicode character block.
4.1936 + * @since 1.7
4.1937 + */
4.1938 + public static final UnicodeBlock TIFINAGH =
4.1939 + new UnicodeBlock("TIFINAGH");
4.1940 +
4.1941 + /**
4.1942 + * Constant for the "Ethiopic Extended" Unicode character block.
4.1943 + * @since 1.7
4.1944 + */
4.1945 + public static final UnicodeBlock ETHIOPIC_EXTENDED =
4.1946 + new UnicodeBlock("ETHIOPIC_EXTENDED",
4.1947 + "ETHIOPIC EXTENDED",
4.1948 + "ETHIOPICEXTENDED");
4.1949 +
4.1950 + /**
4.1951 + * Constant for the "Cyrillic Extended-A" Unicode character block.
4.1952 + * @since 1.7
4.1953 + */
4.1954 + public static final UnicodeBlock CYRILLIC_EXTENDED_A =
4.1955 + new UnicodeBlock("CYRILLIC_EXTENDED_A",
4.1956 + "CYRILLIC EXTENDED-A",
4.1957 + "CYRILLICEXTENDED-A");
4.1958 +
4.1959 + /**
4.1960 + * Constant for the "Supplemental Punctuation" Unicode character block.
4.1961 + * @since 1.7
4.1962 + */
4.1963 + public static final UnicodeBlock SUPPLEMENTAL_PUNCTUATION =
4.1964 + new UnicodeBlock("SUPPLEMENTAL_PUNCTUATION",
4.1965 + "SUPPLEMENTAL PUNCTUATION",
4.1966 + "SUPPLEMENTALPUNCTUATION");
4.1967 +
4.1968 + /**
4.1969 + * Constant for the "CJK Strokes" Unicode character block.
4.1970 + * @since 1.7
4.1971 + */
4.1972 + public static final UnicodeBlock CJK_STROKES =
4.1973 + new UnicodeBlock("CJK_STROKES",
4.1974 + "CJK STROKES",
4.1975 + "CJKSTROKES");
4.1976 +
4.1977 + /**
4.1978 + * Constant for the "Lisu" Unicode character block.
4.1979 + * @since 1.7
4.1980 + */
4.1981 + public static final UnicodeBlock LISU =
4.1982 + new UnicodeBlock("LISU");
4.1983 +
4.1984 + /**
4.1985 + * Constant for the "Vai" Unicode character block.
4.1986 + * @since 1.7
4.1987 + */
4.1988 + public static final UnicodeBlock VAI =
4.1989 + new UnicodeBlock("VAI");
4.1990 +
4.1991 + /**
4.1992 + * Constant for the "Cyrillic Extended-B" Unicode character block.
4.1993 + * @since 1.7
4.1994 + */
4.1995 + public static final UnicodeBlock CYRILLIC_EXTENDED_B =
4.1996 + new UnicodeBlock("CYRILLIC_EXTENDED_B",
4.1997 + "CYRILLIC EXTENDED-B",
4.1998 + "CYRILLICEXTENDED-B");
4.1999 +
4.2000 + /**
4.2001 + * Constant for the "Bamum" Unicode character block.
4.2002 + * @since 1.7
4.2003 + */
4.2004 + public static final UnicodeBlock BAMUM =
4.2005 + new UnicodeBlock("BAMUM");
4.2006 +
4.2007 + /**
4.2008 + * Constant for the "Modifier Tone Letters" Unicode character block.
4.2009 + * @since 1.7
4.2010 + */
4.2011 + public static final UnicodeBlock MODIFIER_TONE_LETTERS =
4.2012 + new UnicodeBlock("MODIFIER_TONE_LETTERS",
4.2013 + "MODIFIER TONE LETTERS",
4.2014 + "MODIFIERTONELETTERS");
4.2015 +
4.2016 + /**
4.2017 + * Constant for the "Latin Extended-D" Unicode character block.
4.2018 + * @since 1.7
4.2019 + */
4.2020 + public static final UnicodeBlock LATIN_EXTENDED_D =
4.2021 + new UnicodeBlock("LATIN_EXTENDED_D",
4.2022 + "LATIN EXTENDED-D",
4.2023 + "LATINEXTENDED-D");
4.2024 +
4.2025 + /**
4.2026 + * Constant for the "Syloti Nagri" Unicode character block.
4.2027 + * @since 1.7
4.2028 + */
4.2029 + public static final UnicodeBlock SYLOTI_NAGRI =
4.2030 + new UnicodeBlock("SYLOTI_NAGRI",
4.2031 + "SYLOTI NAGRI",
4.2032 + "SYLOTINAGRI");
4.2033 +
4.2034 + /**
4.2035 + * Constant for the "Common Indic Number Forms" Unicode character block.
4.2036 + * @since 1.7
4.2037 + */
4.2038 + public static final UnicodeBlock COMMON_INDIC_NUMBER_FORMS =
4.2039 + new UnicodeBlock("COMMON_INDIC_NUMBER_FORMS",
4.2040 + "COMMON INDIC NUMBER FORMS",
4.2041 + "COMMONINDICNUMBERFORMS");
4.2042 +
4.2043 + /**
4.2044 + * Constant for the "Phags-pa" Unicode character block.
4.2045 + * @since 1.7
4.2046 + */
4.2047 + public static final UnicodeBlock PHAGS_PA =
4.2048 + new UnicodeBlock("PHAGS_PA",
4.2049 + "PHAGS-PA");
4.2050 +
4.2051 + /**
4.2052 + * Constant for the "Saurashtra" Unicode character block.
4.2053 + * @since 1.7
4.2054 + */
4.2055 + public static final UnicodeBlock SAURASHTRA =
4.2056 + new UnicodeBlock("SAURASHTRA");
4.2057 +
4.2058 + /**
4.2059 + * Constant for the "Devanagari Extended" Unicode character block.
4.2060 + * @since 1.7
4.2061 + */
4.2062 + public static final UnicodeBlock DEVANAGARI_EXTENDED =
4.2063 + new UnicodeBlock("DEVANAGARI_EXTENDED",
4.2064 + "DEVANAGARI EXTENDED",
4.2065 + "DEVANAGARIEXTENDED");
4.2066 +
4.2067 + /**
4.2068 + * Constant for the "Kayah Li" Unicode character block.
4.2069 + * @since 1.7
4.2070 + */
4.2071 + public static final UnicodeBlock KAYAH_LI =
4.2072 + new UnicodeBlock("KAYAH_LI",
4.2073 + "KAYAH LI",
4.2074 + "KAYAHLI");
4.2075 +
4.2076 + /**
4.2077 + * Constant for the "Rejang" Unicode character block.
4.2078 + * @since 1.7
4.2079 + */
4.2080 + public static final UnicodeBlock REJANG =
4.2081 + new UnicodeBlock("REJANG");
4.2082 +
4.2083 + /**
4.2084 + * Constant for the "Hangul Jamo Extended-A" Unicode character block.
4.2085 + * @since 1.7
4.2086 + */
4.2087 + public static final UnicodeBlock HANGUL_JAMO_EXTENDED_A =
4.2088 + new UnicodeBlock("HANGUL_JAMO_EXTENDED_A",
4.2089 + "HANGUL JAMO EXTENDED-A",
4.2090 + "HANGULJAMOEXTENDED-A");
4.2091 +
4.2092 + /**
4.2093 + * Constant for the "Javanese" Unicode character block.
4.2094 + * @since 1.7
4.2095 + */
4.2096 + public static final UnicodeBlock JAVANESE =
4.2097 + new UnicodeBlock("JAVANESE");
4.2098 +
4.2099 + /**
4.2100 + * Constant for the "Cham" Unicode character block.
4.2101 + * @since 1.7
4.2102 + */
4.2103 + public static final UnicodeBlock CHAM =
4.2104 + new UnicodeBlock("CHAM");
4.2105 +
4.2106 + /**
4.2107 + * Constant for the "Myanmar Extended-A" Unicode character block.
4.2108 + * @since 1.7
4.2109 + */
4.2110 + public static final UnicodeBlock MYANMAR_EXTENDED_A =
4.2111 + new UnicodeBlock("MYANMAR_EXTENDED_A",
4.2112 + "MYANMAR EXTENDED-A",
4.2113 + "MYANMAREXTENDED-A");
4.2114 +
4.2115 + /**
4.2116 + * Constant for the "Tai Viet" Unicode character block.
4.2117 + * @since 1.7
4.2118 + */
4.2119 + public static final UnicodeBlock TAI_VIET =
4.2120 + new UnicodeBlock("TAI_VIET",
4.2121 + "TAI VIET",
4.2122 + "TAIVIET");
4.2123 +
4.2124 + /**
4.2125 + * Constant for the "Ethiopic Extended-A" Unicode character block.
4.2126 + * @since 1.7
4.2127 + */
4.2128 + public static final UnicodeBlock ETHIOPIC_EXTENDED_A =
4.2129 + new UnicodeBlock("ETHIOPIC_EXTENDED_A",
4.2130 + "ETHIOPIC EXTENDED-A",
4.2131 + "ETHIOPICEXTENDED-A");
4.2132 +
4.2133 + /**
4.2134 + * Constant for the "Meetei Mayek" Unicode character block.
4.2135 + * @since 1.7
4.2136 + */
4.2137 + public static final UnicodeBlock MEETEI_MAYEK =
4.2138 + new UnicodeBlock("MEETEI_MAYEK",
4.2139 + "MEETEI MAYEK",
4.2140 + "MEETEIMAYEK");
4.2141 +
4.2142 + /**
4.2143 + * Constant for the "Hangul Jamo Extended-B" Unicode character block.
4.2144 + * @since 1.7
4.2145 + */
4.2146 + public static final UnicodeBlock HANGUL_JAMO_EXTENDED_B =
4.2147 + new UnicodeBlock("HANGUL_JAMO_EXTENDED_B",
4.2148 + "HANGUL JAMO EXTENDED-B",
4.2149 + "HANGULJAMOEXTENDED-B");
4.2150 +
4.2151 + /**
4.2152 + * Constant for the "Vertical Forms" Unicode character block.
4.2153 + * @since 1.7
4.2154 + */
4.2155 + public static final UnicodeBlock VERTICAL_FORMS =
4.2156 + new UnicodeBlock("VERTICAL_FORMS",
4.2157 + "VERTICAL FORMS",
4.2158 + "VERTICALFORMS");
4.2159 +
4.2160 + /**
4.2161 + * Constant for the "Ancient Greek Numbers" Unicode character block.
4.2162 + * @since 1.7
4.2163 + */
4.2164 + public static final UnicodeBlock ANCIENT_GREEK_NUMBERS =
4.2165 + new UnicodeBlock("ANCIENT_GREEK_NUMBERS",
4.2166 + "ANCIENT GREEK NUMBERS",
4.2167 + "ANCIENTGREEKNUMBERS");
4.2168 +
4.2169 + /**
4.2170 + * Constant for the "Ancient Symbols" Unicode character block.
4.2171 + * @since 1.7
4.2172 + */
4.2173 + public static final UnicodeBlock ANCIENT_SYMBOLS =
4.2174 + new UnicodeBlock("ANCIENT_SYMBOLS",
4.2175 + "ANCIENT SYMBOLS",
4.2176 + "ANCIENTSYMBOLS");
4.2177 +
4.2178 + /**
4.2179 + * Constant for the "Phaistos Disc" Unicode character block.
4.2180 + * @since 1.7
4.2181 + */
4.2182 + public static final UnicodeBlock PHAISTOS_DISC =
4.2183 + new UnicodeBlock("PHAISTOS_DISC",
4.2184 + "PHAISTOS DISC",
4.2185 + "PHAISTOSDISC");
4.2186 +
4.2187 + /**
4.2188 + * Constant for the "Lycian" Unicode character block.
4.2189 + * @since 1.7
4.2190 + */
4.2191 + public static final UnicodeBlock LYCIAN =
4.2192 + new UnicodeBlock("LYCIAN");
4.2193 +
4.2194 + /**
4.2195 + * Constant for the "Carian" Unicode character block.
4.2196 + * @since 1.7
4.2197 + */
4.2198 + public static final UnicodeBlock CARIAN =
4.2199 + new UnicodeBlock("CARIAN");
4.2200 +
4.2201 + /**
4.2202 + * Constant for the "Old Persian" Unicode character block.
4.2203 + * @since 1.7
4.2204 + */
4.2205 + public static final UnicodeBlock OLD_PERSIAN =
4.2206 + new UnicodeBlock("OLD_PERSIAN",
4.2207 + "OLD PERSIAN",
4.2208 + "OLDPERSIAN");
4.2209 +
4.2210 + /**
4.2211 + * Constant for the "Imperial Aramaic" Unicode character block.
4.2212 + * @since 1.7
4.2213 + */
4.2214 + public static final UnicodeBlock IMPERIAL_ARAMAIC =
4.2215 + new UnicodeBlock("IMPERIAL_ARAMAIC",
4.2216 + "IMPERIAL ARAMAIC",
4.2217 + "IMPERIALARAMAIC");
4.2218 +
4.2219 + /**
4.2220 + * Constant for the "Phoenician" Unicode character block.
4.2221 + * @since 1.7
4.2222 + */
4.2223 + public static final UnicodeBlock PHOENICIAN =
4.2224 + new UnicodeBlock("PHOENICIAN");
4.2225 +
4.2226 + /**
4.2227 + * Constant for the "Lydian" Unicode character block.
4.2228 + * @since 1.7
4.2229 + */
4.2230 + public static final UnicodeBlock LYDIAN =
4.2231 + new UnicodeBlock("LYDIAN");
4.2232 +
4.2233 + /**
4.2234 + * Constant for the "Kharoshthi" Unicode character block.
4.2235 + * @since 1.7
4.2236 + */
4.2237 + public static final UnicodeBlock KHAROSHTHI =
4.2238 + new UnicodeBlock("KHAROSHTHI");
4.2239 +
4.2240 + /**
4.2241 + * Constant for the "Old South Arabian" Unicode character block.
4.2242 + * @since 1.7
4.2243 + */
4.2244 + public static final UnicodeBlock OLD_SOUTH_ARABIAN =
4.2245 + new UnicodeBlock("OLD_SOUTH_ARABIAN",
4.2246 + "OLD SOUTH ARABIAN",
4.2247 + "OLDSOUTHARABIAN");
4.2248 +
4.2249 + /**
4.2250 + * Constant for the "Avestan" Unicode character block.
4.2251 + * @since 1.7
4.2252 + */
4.2253 + public static final UnicodeBlock AVESTAN =
4.2254 + new UnicodeBlock("AVESTAN");
4.2255 +
4.2256 + /**
4.2257 + * Constant for the "Inscriptional Parthian" Unicode character block.
4.2258 + * @since 1.7
4.2259 + */
4.2260 + public static final UnicodeBlock INSCRIPTIONAL_PARTHIAN =
4.2261 + new UnicodeBlock("INSCRIPTIONAL_PARTHIAN",
4.2262 + "INSCRIPTIONAL PARTHIAN",
4.2263 + "INSCRIPTIONALPARTHIAN");
4.2264 +
4.2265 + /**
4.2266 + * Constant for the "Inscriptional Pahlavi" Unicode character block.
4.2267 + * @since 1.7
4.2268 + */
4.2269 + public static final UnicodeBlock INSCRIPTIONAL_PAHLAVI =
4.2270 + new UnicodeBlock("INSCRIPTIONAL_PAHLAVI",
4.2271 + "INSCRIPTIONAL PAHLAVI",
4.2272 + "INSCRIPTIONALPAHLAVI");
4.2273 +
4.2274 + /**
4.2275 + * Constant for the "Old Turkic" Unicode character block.
4.2276 + * @since 1.7
4.2277 + */
4.2278 + public static final UnicodeBlock OLD_TURKIC =
4.2279 + new UnicodeBlock("OLD_TURKIC",
4.2280 + "OLD TURKIC",
4.2281 + "OLDTURKIC");
4.2282 +
4.2283 + /**
4.2284 + * Constant for the "Rumi Numeral Symbols" Unicode character block.
4.2285 + * @since 1.7
4.2286 + */
4.2287 + public static final UnicodeBlock RUMI_NUMERAL_SYMBOLS =
4.2288 + new UnicodeBlock("RUMI_NUMERAL_SYMBOLS",
4.2289 + "RUMI NUMERAL SYMBOLS",
4.2290 + "RUMINUMERALSYMBOLS");
4.2291 +
4.2292 + /**
4.2293 + * Constant for the "Brahmi" Unicode character block.
4.2294 + * @since 1.7
4.2295 + */
4.2296 + public static final UnicodeBlock BRAHMI =
4.2297 + new UnicodeBlock("BRAHMI");
4.2298 +
4.2299 + /**
4.2300 + * Constant for the "Kaithi" Unicode character block.
4.2301 + * @since 1.7
4.2302 + */
4.2303 + public static final UnicodeBlock KAITHI =
4.2304 + new UnicodeBlock("KAITHI");
4.2305 +
4.2306 + /**
4.2307 + * Constant for the "Cuneiform" Unicode character block.
4.2308 + * @since 1.7
4.2309 + */
4.2310 + public static final UnicodeBlock CUNEIFORM =
4.2311 + new UnicodeBlock("CUNEIFORM");
4.2312 +
4.2313 + /**
4.2314 + * Constant for the "Cuneiform Numbers and Punctuation" Unicode
4.2315 + * character block.
4.2316 + * @since 1.7
4.2317 + */
4.2318 + public static final UnicodeBlock CUNEIFORM_NUMBERS_AND_PUNCTUATION =
4.2319 + new UnicodeBlock("CUNEIFORM_NUMBERS_AND_PUNCTUATION",
4.2320 + "CUNEIFORM NUMBERS AND PUNCTUATION",
4.2321 + "CUNEIFORMNUMBERSANDPUNCTUATION");
4.2322 +
4.2323 + /**
4.2324 + * Constant for the "Egyptian Hieroglyphs" Unicode character block.
4.2325 + * @since 1.7
4.2326 + */
4.2327 + public static final UnicodeBlock EGYPTIAN_HIEROGLYPHS =
4.2328 + new UnicodeBlock("EGYPTIAN_HIEROGLYPHS",
4.2329 + "EGYPTIAN HIEROGLYPHS",
4.2330 + "EGYPTIANHIEROGLYPHS");
4.2331 +
4.2332 + /**
4.2333 + * Constant for the "Bamum Supplement" Unicode character block.
4.2334 + * @since 1.7
4.2335 + */
4.2336 + public static final UnicodeBlock BAMUM_SUPPLEMENT =
4.2337 + new UnicodeBlock("BAMUM_SUPPLEMENT",
4.2338 + "BAMUM SUPPLEMENT",
4.2339 + "BAMUMSUPPLEMENT");
4.2340 +
4.2341 + /**
4.2342 + * Constant for the "Kana Supplement" Unicode character block.
4.2343 + * @since 1.7
4.2344 + */
4.2345 + public static final UnicodeBlock KANA_SUPPLEMENT =
4.2346 + new UnicodeBlock("KANA_SUPPLEMENT",
4.2347 + "KANA SUPPLEMENT",
4.2348 + "KANASUPPLEMENT");
4.2349 +
4.2350 + /**
4.2351 + * Constant for the "Ancient Greek Musical Notation" Unicode character
4.2352 + * block.
4.2353 + * @since 1.7
4.2354 + */
4.2355 + public static final UnicodeBlock ANCIENT_GREEK_MUSICAL_NOTATION =
4.2356 + new UnicodeBlock("ANCIENT_GREEK_MUSICAL_NOTATION",
4.2357 + "ANCIENT GREEK MUSICAL NOTATION",
4.2358 + "ANCIENTGREEKMUSICALNOTATION");
4.2359 +
4.2360 + /**
4.2361 + * Constant for the "Counting Rod Numerals" Unicode character block.
4.2362 + * @since 1.7
4.2363 + */
4.2364 + public static final UnicodeBlock COUNTING_ROD_NUMERALS =
4.2365 + new UnicodeBlock("COUNTING_ROD_NUMERALS",
4.2366 + "COUNTING ROD NUMERALS",
4.2367 + "COUNTINGRODNUMERALS");
4.2368 +
4.2369 + /**
4.2370 + * Constant for the "Mahjong Tiles" Unicode character block.
4.2371 + * @since 1.7
4.2372 + */
4.2373 + public static final UnicodeBlock MAHJONG_TILES =
4.2374 + new UnicodeBlock("MAHJONG_TILES",
4.2375 + "MAHJONG TILES",
4.2376 + "MAHJONGTILES");
4.2377 +
4.2378 + /**
4.2379 + * Constant for the "Domino Tiles" Unicode character block.
4.2380 + * @since 1.7
4.2381 + */
4.2382 + public static final UnicodeBlock DOMINO_TILES =
4.2383 + new UnicodeBlock("DOMINO_TILES",
4.2384 + "DOMINO TILES",
4.2385 + "DOMINOTILES");
4.2386 +
4.2387 + /**
4.2388 + * Constant for the "Playing Cards" Unicode character block.
4.2389 + * @since 1.7
4.2390 + */
4.2391 + public static final UnicodeBlock PLAYING_CARDS =
4.2392 + new UnicodeBlock("PLAYING_CARDS",
4.2393 + "PLAYING CARDS",
4.2394 + "PLAYINGCARDS");
4.2395 +
4.2396 + /**
4.2397 + * Constant for the "Enclosed Alphanumeric Supplement" Unicode character
4.2398 + * block.
4.2399 + * @since 1.7
4.2400 + */
4.2401 + public static final UnicodeBlock ENCLOSED_ALPHANUMERIC_SUPPLEMENT =
4.2402 + new UnicodeBlock("ENCLOSED_ALPHANUMERIC_SUPPLEMENT",
4.2403 + "ENCLOSED ALPHANUMERIC SUPPLEMENT",
4.2404 + "ENCLOSEDALPHANUMERICSUPPLEMENT");
4.2405 +
4.2406 + /**
4.2407 + * Constant for the "Enclosed Ideographic Supplement" Unicode character
4.2408 + * block.
4.2409 + * @since 1.7
4.2410 + */
4.2411 + public static final UnicodeBlock ENCLOSED_IDEOGRAPHIC_SUPPLEMENT =
4.2412 + new UnicodeBlock("ENCLOSED_IDEOGRAPHIC_SUPPLEMENT",
4.2413 + "ENCLOSED IDEOGRAPHIC SUPPLEMENT",
4.2414 + "ENCLOSEDIDEOGRAPHICSUPPLEMENT");
4.2415 +
4.2416 + /**
4.2417 + * Constant for the "Miscellaneous Symbols And Pictographs" Unicode
4.2418 + * character block.
4.2419 + * @since 1.7
4.2420 + */
4.2421 + public static final UnicodeBlock MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS =
4.2422 + new UnicodeBlock("MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS",
4.2423 + "MISCELLANEOUS SYMBOLS AND PICTOGRAPHS",
4.2424 + "MISCELLANEOUSSYMBOLSANDPICTOGRAPHS");
4.2425 +
4.2426 + /**
4.2427 + * Constant for the "Emoticons" Unicode character block.
4.2428 + * @since 1.7
4.2429 + */
4.2430 + public static final UnicodeBlock EMOTICONS =
4.2431 + new UnicodeBlock("EMOTICONS");
4.2432 +
4.2433 + /**
4.2434 + * Constant for the "Transport And Map Symbols" Unicode character block.
4.2435 + * @since 1.7
4.2436 + */
4.2437 + public static final UnicodeBlock TRANSPORT_AND_MAP_SYMBOLS =
4.2438 + new UnicodeBlock("TRANSPORT_AND_MAP_SYMBOLS",
4.2439 + "TRANSPORT AND MAP SYMBOLS",
4.2440 + "TRANSPORTANDMAPSYMBOLS");
4.2441 +
4.2442 + /**
4.2443 + * Constant for the "Alchemical Symbols" Unicode character block.
4.2444 + * @since 1.7
4.2445 + */
4.2446 + public static final UnicodeBlock ALCHEMICAL_SYMBOLS =
4.2447 + new UnicodeBlock("ALCHEMICAL_SYMBOLS",
4.2448 + "ALCHEMICAL SYMBOLS",
4.2449 + "ALCHEMICALSYMBOLS");
4.2450 +
4.2451 + /**
4.2452 + * Constant for the "CJK Unified Ideographs Extension C" Unicode
4.2453 + * character block.
4.2454 + * @since 1.7
4.2455 + */
4.2456 + public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C =
4.2457 + new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C",
4.2458 + "CJK UNIFIED IDEOGRAPHS EXTENSION C",
4.2459 + "CJKUNIFIEDIDEOGRAPHSEXTENSIONC");
4.2460 +
4.2461 + /**
4.2462 + * Constant for the "CJK Unified Ideographs Extension D" Unicode
4.2463 + * character block.
4.2464 + * @since 1.7
4.2465 + */
4.2466 + public static final UnicodeBlock CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D =
4.2467 + new UnicodeBlock("CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D",
4.2468 + "CJK UNIFIED IDEOGRAPHS EXTENSION D",
4.2469 + "CJKUNIFIEDIDEOGRAPHSEXTENSIOND");
4.2470 +
4.2471 + private static final int blockStarts[] = {
4.2472 + 0x0000, // 0000..007F; Basic Latin
4.2473 + 0x0080, // 0080..00FF; Latin-1 Supplement
4.2474 + 0x0100, // 0100..017F; Latin Extended-A
4.2475 + 0x0180, // 0180..024F; Latin Extended-B
4.2476 + 0x0250, // 0250..02AF; IPA Extensions
4.2477 + 0x02B0, // 02B0..02FF; Spacing Modifier Letters
4.2478 + 0x0300, // 0300..036F; Combining Diacritical Marks
4.2479 + 0x0370, // 0370..03FF; Greek and Coptic
4.2480 + 0x0400, // 0400..04FF; Cyrillic
4.2481 + 0x0500, // 0500..052F; Cyrillic Supplement
4.2482 + 0x0530, // 0530..058F; Armenian
4.2483 + 0x0590, // 0590..05FF; Hebrew
4.2484 + 0x0600, // 0600..06FF; Arabic
4.2485 + 0x0700, // 0700..074F; Syriac
4.2486 + 0x0750, // 0750..077F; Arabic Supplement
4.2487 + 0x0780, // 0780..07BF; Thaana
4.2488 + 0x07C0, // 07C0..07FF; NKo
4.2489 + 0x0800, // 0800..083F; Samaritan
4.2490 + 0x0840, // 0840..085F; Mandaic
4.2491 + 0x0860, // unassigned
4.2492 + 0x0900, // 0900..097F; Devanagari
4.2493 + 0x0980, // 0980..09FF; Bengali
4.2494 + 0x0A00, // 0A00..0A7F; Gurmukhi
4.2495 + 0x0A80, // 0A80..0AFF; Gujarati
4.2496 + 0x0B00, // 0B00..0B7F; Oriya
4.2497 + 0x0B80, // 0B80..0BFF; Tamil
4.2498 + 0x0C00, // 0C00..0C7F; Telugu
4.2499 + 0x0C80, // 0C80..0CFF; Kannada
4.2500 + 0x0D00, // 0D00..0D7F; Malayalam
4.2501 + 0x0D80, // 0D80..0DFF; Sinhala
4.2502 + 0x0E00, // 0E00..0E7F; Thai
4.2503 + 0x0E80, // 0E80..0EFF; Lao
4.2504 + 0x0F00, // 0F00..0FFF; Tibetan
4.2505 + 0x1000, // 1000..109F; Myanmar
4.2506 + 0x10A0, // 10A0..10FF; Georgian
4.2507 + 0x1100, // 1100..11FF; Hangul Jamo
4.2508 + 0x1200, // 1200..137F; Ethiopic
4.2509 + 0x1380, // 1380..139F; Ethiopic Supplement
4.2510 + 0x13A0, // 13A0..13FF; Cherokee
4.2511 + 0x1400, // 1400..167F; Unified Canadian Aboriginal Syllabics
4.2512 + 0x1680, // 1680..169F; Ogham
4.2513 + 0x16A0, // 16A0..16FF; Runic
4.2514 + 0x1700, // 1700..171F; Tagalog
4.2515 + 0x1720, // 1720..173F; Hanunoo
4.2516 + 0x1740, // 1740..175F; Buhid
4.2517 + 0x1760, // 1760..177F; Tagbanwa
4.2518 + 0x1780, // 1780..17FF; Khmer
4.2519 + 0x1800, // 1800..18AF; Mongolian
4.2520 + 0x18B0, // 18B0..18FF; Unified Canadian Aboriginal Syllabics Extended
4.2521 + 0x1900, // 1900..194F; Limbu
4.2522 + 0x1950, // 1950..197F; Tai Le
4.2523 + 0x1980, // 1980..19DF; New Tai Lue
4.2524 + 0x19E0, // 19E0..19FF; Khmer Symbols
4.2525 + 0x1A00, // 1A00..1A1F; Buginese
4.2526 + 0x1A20, // 1A20..1AAF; Tai Tham
4.2527 + 0x1AB0, // unassigned
4.2528 + 0x1B00, // 1B00..1B7F; Balinese
4.2529 + 0x1B80, // 1B80..1BBF; Sundanese
4.2530 + 0x1BC0, // 1BC0..1BFF; Batak
4.2531 + 0x1C00, // 1C00..1C4F; Lepcha
4.2532 + 0x1C50, // 1C50..1C7F; Ol Chiki
4.2533 + 0x1C80, // unassigned
4.2534 + 0x1CD0, // 1CD0..1CFF; Vedic Extensions
4.2535 + 0x1D00, // 1D00..1D7F; Phonetic Extensions
4.2536 + 0x1D80, // 1D80..1DBF; Phonetic Extensions Supplement
4.2537 + 0x1DC0, // 1DC0..1DFF; Combining Diacritical Marks Supplement
4.2538 + 0x1E00, // 1E00..1EFF; Latin Extended Additional
4.2539 + 0x1F00, // 1F00..1FFF; Greek Extended
4.2540 + 0x2000, // 2000..206F; General Punctuation
4.2541 + 0x2070, // 2070..209F; Superscripts and Subscripts
4.2542 + 0x20A0, // 20A0..20CF; Currency Symbols
4.2543 + 0x20D0, // 20D0..20FF; Combining Diacritical Marks for Symbols
4.2544 + 0x2100, // 2100..214F; Letterlike Symbols
4.2545 + 0x2150, // 2150..218F; Number Forms
4.2546 + 0x2190, // 2190..21FF; Arrows
4.2547 + 0x2200, // 2200..22FF; Mathematical Operators
4.2548 + 0x2300, // 2300..23FF; Miscellaneous Technical
4.2549 + 0x2400, // 2400..243F; Control Pictures
4.2550 + 0x2440, // 2440..245F; Optical Character Recognition
4.2551 + 0x2460, // 2460..24FF; Enclosed Alphanumerics
4.2552 + 0x2500, // 2500..257F; Box Drawing
4.2553 + 0x2580, // 2580..259F; Block Elements
4.2554 + 0x25A0, // 25A0..25FF; Geometric Shapes
4.2555 + 0x2600, // 2600..26FF; Miscellaneous Symbols
4.2556 + 0x2700, // 2700..27BF; Dingbats
4.2557 + 0x27C0, // 27C0..27EF; Miscellaneous Mathematical Symbols-A
4.2558 + 0x27F0, // 27F0..27FF; Supplemental Arrows-A
4.2559 + 0x2800, // 2800..28FF; Braille Patterns
4.2560 + 0x2900, // 2900..297F; Supplemental Arrows-B
4.2561 + 0x2980, // 2980..29FF; Miscellaneous Mathematical Symbols-B
4.2562 + 0x2A00, // 2A00..2AFF; Supplemental Mathematical Operators
4.2563 + 0x2B00, // 2B00..2BFF; Miscellaneous Symbols and Arrows
4.2564 + 0x2C00, // 2C00..2C5F; Glagolitic
4.2565 + 0x2C60, // 2C60..2C7F; Latin Extended-C
4.2566 + 0x2C80, // 2C80..2CFF; Coptic
4.2567 + 0x2D00, // 2D00..2D2F; Georgian Supplement
4.2568 + 0x2D30, // 2D30..2D7F; Tifinagh
4.2569 + 0x2D80, // 2D80..2DDF; Ethiopic Extended
4.2570 + 0x2DE0, // 2DE0..2DFF; Cyrillic Extended-A
4.2571 + 0x2E00, // 2E00..2E7F; Supplemental Punctuation
4.2572 + 0x2E80, // 2E80..2EFF; CJK Radicals Supplement
4.2573 + 0x2F00, // 2F00..2FDF; Kangxi Radicals
4.2574 + 0x2FE0, // unassigned
4.2575 + 0x2FF0, // 2FF0..2FFF; Ideographic Description Characters
4.2576 + 0x3000, // 3000..303F; CJK Symbols and Punctuation
4.2577 + 0x3040, // 3040..309F; Hiragana
4.2578 + 0x30A0, // 30A0..30FF; Katakana
4.2579 + 0x3100, // 3100..312F; Bopomofo
4.2580 + 0x3130, // 3130..318F; Hangul Compatibility Jamo
4.2581 + 0x3190, // 3190..319F; Kanbun
4.2582 + 0x31A0, // 31A0..31BF; Bopomofo Extended
4.2583 + 0x31C0, // 31C0..31EF; CJK Strokes
4.2584 + 0x31F0, // 31F0..31FF; Katakana Phonetic Extensions
4.2585 + 0x3200, // 3200..32FF; Enclosed CJK Letters and Months
4.2586 + 0x3300, // 3300..33FF; CJK Compatibility
4.2587 + 0x3400, // 3400..4DBF; CJK Unified Ideographs Extension A
4.2588 + 0x4DC0, // 4DC0..4DFF; Yijing Hexagram Symbols
4.2589 + 0x4E00, // 4E00..9FFF; CJK Unified Ideographs
4.2590 + 0xA000, // A000..A48F; Yi Syllables
4.2591 + 0xA490, // A490..A4CF; Yi Radicals
4.2592 + 0xA4D0, // A4D0..A4FF; Lisu
4.2593 + 0xA500, // A500..A63F; Vai
4.2594 + 0xA640, // A640..A69F; Cyrillic Extended-B
4.2595 + 0xA6A0, // A6A0..A6FF; Bamum
4.2596 + 0xA700, // A700..A71F; Modifier Tone Letters
4.2597 + 0xA720, // A720..A7FF; Latin Extended-D
4.2598 + 0xA800, // A800..A82F; Syloti Nagri
4.2599 + 0xA830, // A830..A83F; Common Indic Number Forms
4.2600 + 0xA840, // A840..A87F; Phags-pa
4.2601 + 0xA880, // A880..A8DF; Saurashtra
4.2602 + 0xA8E0, // A8E0..A8FF; Devanagari Extended
4.2603 + 0xA900, // A900..A92F; Kayah Li
4.2604 + 0xA930, // A930..A95F; Rejang
4.2605 + 0xA960, // A960..A97F; Hangul Jamo Extended-A
4.2606 + 0xA980, // A980..A9DF; Javanese
4.2607 + 0xA9E0, // unassigned
4.2608 + 0xAA00, // AA00..AA5F; Cham
4.2609 + 0xAA60, // AA60..AA7F; Myanmar Extended-A
4.2610 + 0xAA80, // AA80..AADF; Tai Viet
4.2611 + 0xAAE0, // unassigned
4.2612 + 0xAB00, // AB00..AB2F; Ethiopic Extended-A
4.2613 + 0xAB30, // unassigned
4.2614 + 0xABC0, // ABC0..ABFF; Meetei Mayek
4.2615 + 0xAC00, // AC00..D7AF; Hangul Syllables
4.2616 + 0xD7B0, // D7B0..D7FF; Hangul Jamo Extended-B
4.2617 + 0xD800, // D800..DB7F; High Surrogates
4.2618 + 0xDB80, // DB80..DBFF; High Private Use Surrogates
4.2619 + 0xDC00, // DC00..DFFF; Low Surrogates
4.2620 + 0xE000, // E000..F8FF; Private Use Area
4.2621 + 0xF900, // F900..FAFF; CJK Compatibility Ideographs
4.2622 + 0xFB00, // FB00..FB4F; Alphabetic Presentation Forms
4.2623 + 0xFB50, // FB50..FDFF; Arabic Presentation Forms-A
4.2624 + 0xFE00, // FE00..FE0F; Variation Selectors
4.2625 + 0xFE10, // FE10..FE1F; Vertical Forms
4.2626 + 0xFE20, // FE20..FE2F; Combining Half Marks
4.2627 + 0xFE30, // FE30..FE4F; CJK Compatibility Forms
4.2628 + 0xFE50, // FE50..FE6F; Small Form Variants
4.2629 + 0xFE70, // FE70..FEFF; Arabic Presentation Forms-B
4.2630 + 0xFF00, // FF00..FFEF; Halfwidth and Fullwidth Forms
4.2631 + 0xFFF0, // FFF0..FFFF; Specials
4.2632 + 0x10000, // 10000..1007F; Linear B Syllabary
4.2633 + 0x10080, // 10080..100FF; Linear B Ideograms
4.2634 + 0x10100, // 10100..1013F; Aegean Numbers
4.2635 + 0x10140, // 10140..1018F; Ancient Greek Numbers
4.2636 + 0x10190, // 10190..101CF; Ancient Symbols
4.2637 + 0x101D0, // 101D0..101FF; Phaistos Disc
4.2638 + 0x10200, // unassigned
4.2639 + 0x10280, // 10280..1029F; Lycian
4.2640 + 0x102A0, // 102A0..102DF; Carian
4.2641 + 0x102E0, // unassigned
4.2642 + 0x10300, // 10300..1032F; Old Italic
4.2643 + 0x10330, // 10330..1034F; Gothic
4.2644 + 0x10350, // unassigned
4.2645 + 0x10380, // 10380..1039F; Ugaritic
4.2646 + 0x103A0, // 103A0..103DF; Old Persian
4.2647 + 0x103E0, // unassigned
4.2648 + 0x10400, // 10400..1044F; Deseret
4.2649 + 0x10450, // 10450..1047F; Shavian
4.2650 + 0x10480, // 10480..104AF; Osmanya
4.2651 + 0x104B0, // unassigned
4.2652 + 0x10800, // 10800..1083F; Cypriot Syllabary
4.2653 + 0x10840, // 10840..1085F; Imperial Aramaic
4.2654 + 0x10860, // unassigned
4.2655 + 0x10900, // 10900..1091F; Phoenician
4.2656 + 0x10920, // 10920..1093F; Lydian
4.2657 + 0x10940, // unassigned
4.2658 + 0x10A00, // 10A00..10A5F; Kharoshthi
4.2659 + 0x10A60, // 10A60..10A7F; Old South Arabian
4.2660 + 0x10A80, // unassigned
4.2661 + 0x10B00, // 10B00..10B3F; Avestan
4.2662 + 0x10B40, // 10B40..10B5F; Inscriptional Parthian
4.2663 + 0x10B60, // 10B60..10B7F; Inscriptional Pahlavi
4.2664 + 0x10B80, // unassigned
4.2665 + 0x10C00, // 10C00..10C4F; Old Turkic
4.2666 + 0x10C50, // unassigned
4.2667 + 0x10E60, // 10E60..10E7F; Rumi Numeral Symbols
4.2668 + 0x10E80, // unassigned
4.2669 + 0x11000, // 11000..1107F; Brahmi
4.2670 + 0x11080, // 11080..110CF; Kaithi
4.2671 + 0x110D0, // unassigned
4.2672 + 0x12000, // 12000..123FF; Cuneiform
4.2673 + 0x12400, // 12400..1247F; Cuneiform Numbers and Punctuation
4.2674 + 0x12480, // unassigned
4.2675 + 0x13000, // 13000..1342F; Egyptian Hieroglyphs
4.2676 + 0x13430, // unassigned
4.2677 + 0x16800, // 16800..16A3F; Bamum Supplement
4.2678 + 0x16A40, // unassigned
4.2679 + 0x1B000, // 1B000..1B0FF; Kana Supplement
4.2680 + 0x1B100, // unassigned
4.2681 + 0x1D000, // 1D000..1D0FF; Byzantine Musical Symbols
4.2682 + 0x1D100, // 1D100..1D1FF; Musical Symbols
4.2683 + 0x1D200, // 1D200..1D24F; Ancient Greek Musical Notation
4.2684 + 0x1D250, // unassigned
4.2685 + 0x1D300, // 1D300..1D35F; Tai Xuan Jing Symbols
4.2686 + 0x1D360, // 1D360..1D37F; Counting Rod Numerals
4.2687 + 0x1D380, // unassigned
4.2688 + 0x1D400, // 1D400..1D7FF; Mathematical Alphanumeric Symbols
4.2689 + 0x1D800, // unassigned
4.2690 + 0x1F000, // 1F000..1F02F; Mahjong Tiles
4.2691 + 0x1F030, // 1F030..1F09F; Domino Tiles
4.2692 + 0x1F0A0, // 1F0A0..1F0FF; Playing Cards
4.2693 + 0x1F100, // 1F100..1F1FF; Enclosed Alphanumeric Supplement
4.2694 + 0x1F200, // 1F200..1F2FF; Enclosed Ideographic Supplement
4.2695 + 0x1F300, // 1F300..1F5FF; Miscellaneous Symbols And Pictographs
4.2696 + 0x1F600, // 1F600..1F64F; Emoticons
4.2697 + 0x1F650, // unassigned
4.2698 + 0x1F680, // 1F680..1F6FF; Transport And Map Symbols
4.2699 + 0x1F700, // 1F700..1F77F; Alchemical Symbols
4.2700 + 0x1F780, // unassigned
4.2701 + 0x20000, // 20000..2A6DF; CJK Unified Ideographs Extension B
4.2702 + 0x2A6E0, // unassigned
4.2703 + 0x2A700, // 2A700..2B73F; CJK Unified Ideographs Extension C
4.2704 + 0x2B740, // 2B740..2B81F; CJK Unified Ideographs Extension D
4.2705 + 0x2B820, // unassigned
4.2706 + 0x2F800, // 2F800..2FA1F; CJK Compatibility Ideographs Supplement
4.2707 + 0x2FA20, // unassigned
4.2708 + 0xE0000, // E0000..E007F; Tags
4.2709 + 0xE0080, // unassigned
4.2710 + 0xE0100, // E0100..E01EF; Variation Selectors Supplement
4.2711 + 0xE01F0, // unassigned
4.2712 + 0xF0000, // F0000..FFFFF; Supplementary Private Use Area-A
4.2713 + 0x100000 // 100000..10FFFF; Supplementary Private Use Area-B
4.2714 + };
4.2715 +
4.2716 + private static final UnicodeBlock[] blocks = {
4.2717 + BASIC_LATIN,
4.2718 + LATIN_1_SUPPLEMENT,
4.2719 + LATIN_EXTENDED_A,
4.2720 + LATIN_EXTENDED_B,
4.2721 + IPA_EXTENSIONS,
4.2722 + SPACING_MODIFIER_LETTERS,
4.2723 + COMBINING_DIACRITICAL_MARKS,
4.2724 + GREEK,
4.2725 + CYRILLIC,
4.2726 + CYRILLIC_SUPPLEMENTARY,
4.2727 + ARMENIAN,
4.2728 + HEBREW,
4.2729 + ARABIC,
4.2730 + SYRIAC,
4.2731 + ARABIC_SUPPLEMENT,
4.2732 + THAANA,
4.2733 + NKO,
4.2734 + SAMARITAN,
4.2735 + MANDAIC,
4.2736 + null,
4.2737 + DEVANAGARI,
4.2738 + BENGALI,
4.2739 + GURMUKHI,
4.2740 + GUJARATI,
4.2741 + ORIYA,
4.2742 + TAMIL,
4.2743 + TELUGU,
4.2744 + KANNADA,
4.2745 + MALAYALAM,
4.2746 + SINHALA,
4.2747 + THAI,
4.2748 + LAO,
4.2749 + TIBETAN,
4.2750 + MYANMAR,
4.2751 + GEORGIAN,
4.2752 + HANGUL_JAMO,
4.2753 + ETHIOPIC,
4.2754 + ETHIOPIC_SUPPLEMENT,
4.2755 + CHEROKEE,
4.2756 + UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
4.2757 + OGHAM,
4.2758 + RUNIC,
4.2759 + TAGALOG,
4.2760 + HANUNOO,
4.2761 + BUHID,
4.2762 + TAGBANWA,
4.2763 + KHMER,
4.2764 + MONGOLIAN,
4.2765 + UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED,
4.2766 + LIMBU,
4.2767 + TAI_LE,
4.2768 + NEW_TAI_LUE,
4.2769 + KHMER_SYMBOLS,
4.2770 + BUGINESE,
4.2771 + TAI_THAM,
4.2772 + null,
4.2773 + BALINESE,
4.2774 + SUNDANESE,
4.2775 + BATAK,
4.2776 + LEPCHA,
4.2777 + OL_CHIKI,
4.2778 + null,
4.2779 + VEDIC_EXTENSIONS,
4.2780 + PHONETIC_EXTENSIONS,
4.2781 + PHONETIC_EXTENSIONS_SUPPLEMENT,
4.2782 + COMBINING_DIACRITICAL_MARKS_SUPPLEMENT,
4.2783 + LATIN_EXTENDED_ADDITIONAL,
4.2784 + GREEK_EXTENDED,
4.2785 + GENERAL_PUNCTUATION,
4.2786 + SUPERSCRIPTS_AND_SUBSCRIPTS,
4.2787 + CURRENCY_SYMBOLS,
4.2788 + COMBINING_MARKS_FOR_SYMBOLS,
4.2789 + LETTERLIKE_SYMBOLS,
4.2790 + NUMBER_FORMS,
4.2791 + ARROWS,
4.2792 + MATHEMATICAL_OPERATORS,
4.2793 + MISCELLANEOUS_TECHNICAL,
4.2794 + CONTROL_PICTURES,
4.2795 + OPTICAL_CHARACTER_RECOGNITION,
4.2796 + ENCLOSED_ALPHANUMERICS,
4.2797 + BOX_DRAWING,
4.2798 + BLOCK_ELEMENTS,
4.2799 + GEOMETRIC_SHAPES,
4.2800 + MISCELLANEOUS_SYMBOLS,
4.2801 + DINGBATS,
4.2802 + MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A,
4.2803 + SUPPLEMENTAL_ARROWS_A,
4.2804 + BRAILLE_PATTERNS,
4.2805 + SUPPLEMENTAL_ARROWS_B,
4.2806 + MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B,
4.2807 + SUPPLEMENTAL_MATHEMATICAL_OPERATORS,
4.2808 + MISCELLANEOUS_SYMBOLS_AND_ARROWS,
4.2809 + GLAGOLITIC,
4.2810 + LATIN_EXTENDED_C,
4.2811 + COPTIC,
4.2812 + GEORGIAN_SUPPLEMENT,
4.2813 + TIFINAGH,
4.2814 + ETHIOPIC_EXTENDED,
4.2815 + CYRILLIC_EXTENDED_A,
4.2816 + SUPPLEMENTAL_PUNCTUATION,
4.2817 + CJK_RADICALS_SUPPLEMENT,
4.2818 + KANGXI_RADICALS,
4.2819 + null,
4.2820 + IDEOGRAPHIC_DESCRIPTION_CHARACTERS,
4.2821 + CJK_SYMBOLS_AND_PUNCTUATION,
4.2822 + HIRAGANA,
4.2823 + KATAKANA,
4.2824 + BOPOMOFO,
4.2825 + HANGUL_COMPATIBILITY_JAMO,
4.2826 + KANBUN,
4.2827 + BOPOMOFO_EXTENDED,
4.2828 + CJK_STROKES,
4.2829 + KATAKANA_PHONETIC_EXTENSIONS,
4.2830 + ENCLOSED_CJK_LETTERS_AND_MONTHS,
4.2831 + CJK_COMPATIBILITY,
4.2832 + CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
4.2833 + YIJING_HEXAGRAM_SYMBOLS,
4.2834 + CJK_UNIFIED_IDEOGRAPHS,
4.2835 + YI_SYLLABLES,
4.2836 + YI_RADICALS,
4.2837 + LISU,
4.2838 + VAI,
4.2839 + CYRILLIC_EXTENDED_B,
4.2840 + BAMUM,
4.2841 + MODIFIER_TONE_LETTERS,
4.2842 + LATIN_EXTENDED_D,
4.2843 + SYLOTI_NAGRI,
4.2844 + COMMON_INDIC_NUMBER_FORMS,
4.2845 + PHAGS_PA,
4.2846 + SAURASHTRA,
4.2847 + DEVANAGARI_EXTENDED,
4.2848 + KAYAH_LI,
4.2849 + REJANG,
4.2850 + HANGUL_JAMO_EXTENDED_A,
4.2851 + JAVANESE,
4.2852 + null,
4.2853 + CHAM,
4.2854 + MYANMAR_EXTENDED_A,
4.2855 + TAI_VIET,
4.2856 + null,
4.2857 + ETHIOPIC_EXTENDED_A,
4.2858 + null,
4.2859 + MEETEI_MAYEK,
4.2860 + HANGUL_SYLLABLES,
4.2861 + HANGUL_JAMO_EXTENDED_B,
4.2862 + HIGH_SURROGATES,
4.2863 + HIGH_PRIVATE_USE_SURROGATES,
4.2864 + LOW_SURROGATES,
4.2865 + PRIVATE_USE_AREA,
4.2866 + CJK_COMPATIBILITY_IDEOGRAPHS,
4.2867 + ALPHABETIC_PRESENTATION_FORMS,
4.2868 + ARABIC_PRESENTATION_FORMS_A,
4.2869 + VARIATION_SELECTORS,
4.2870 + VERTICAL_FORMS,
4.2871 + COMBINING_HALF_MARKS,
4.2872 + CJK_COMPATIBILITY_FORMS,
4.2873 + SMALL_FORM_VARIANTS,
4.2874 + ARABIC_PRESENTATION_FORMS_B,
4.2875 + HALFWIDTH_AND_FULLWIDTH_FORMS,
4.2876 + SPECIALS,
4.2877 + LINEAR_B_SYLLABARY,
4.2878 + LINEAR_B_IDEOGRAMS,
4.2879 + AEGEAN_NUMBERS,
4.2880 + ANCIENT_GREEK_NUMBERS,
4.2881 + ANCIENT_SYMBOLS,
4.2882 + PHAISTOS_DISC,
4.2883 + null,
4.2884 + LYCIAN,
4.2885 + CARIAN,
4.2886 + null,
4.2887 + OLD_ITALIC,
4.2888 + GOTHIC,
4.2889 + null,
4.2890 + UGARITIC,
4.2891 + OLD_PERSIAN,
4.2892 + null,
4.2893 + DESERET,
4.2894 + SHAVIAN,
4.2895 + OSMANYA,
4.2896 + null,
4.2897 + CYPRIOT_SYLLABARY,
4.2898 + IMPERIAL_ARAMAIC,
4.2899 + null,
4.2900 + PHOENICIAN,
4.2901 + LYDIAN,
4.2902 + null,
4.2903 + KHAROSHTHI,
4.2904 + OLD_SOUTH_ARABIAN,
4.2905 + null,
4.2906 + AVESTAN,
4.2907 + INSCRIPTIONAL_PARTHIAN,
4.2908 + INSCRIPTIONAL_PAHLAVI,
4.2909 + null,
4.2910 + OLD_TURKIC,
4.2911 + null,
4.2912 + RUMI_NUMERAL_SYMBOLS,
4.2913 + null,
4.2914 + BRAHMI,
4.2915 + KAITHI,
4.2916 + null,
4.2917 + CUNEIFORM,
4.2918 + CUNEIFORM_NUMBERS_AND_PUNCTUATION,
4.2919 + null,
4.2920 + EGYPTIAN_HIEROGLYPHS,
4.2921 + null,
4.2922 + BAMUM_SUPPLEMENT,
4.2923 + null,
4.2924 + KANA_SUPPLEMENT,
4.2925 + null,
4.2926 + BYZANTINE_MUSICAL_SYMBOLS,
4.2927 + MUSICAL_SYMBOLS,
4.2928 + ANCIENT_GREEK_MUSICAL_NOTATION,
4.2929 + null,
4.2930 + TAI_XUAN_JING_SYMBOLS,
4.2931 + COUNTING_ROD_NUMERALS,
4.2932 + null,
4.2933 + MATHEMATICAL_ALPHANUMERIC_SYMBOLS,
4.2934 + null,
4.2935 + MAHJONG_TILES,
4.2936 + DOMINO_TILES,
4.2937 + PLAYING_CARDS,
4.2938 + ENCLOSED_ALPHANUMERIC_SUPPLEMENT,
4.2939 + ENCLOSED_IDEOGRAPHIC_SUPPLEMENT,
4.2940 + MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS,
4.2941 + EMOTICONS,
4.2942 + null,
4.2943 + TRANSPORT_AND_MAP_SYMBOLS,
4.2944 + ALCHEMICAL_SYMBOLS,
4.2945 + null,
4.2946 + CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B,
4.2947 + null,
4.2948 + CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C,
4.2949 + CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D,
4.2950 + null,
4.2951 + CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
4.2952 + null,
4.2953 + TAGS,
4.2954 + null,
4.2955 + VARIATION_SELECTORS_SUPPLEMENT,
4.2956 + null,
4.2957 + SUPPLEMENTARY_PRIVATE_USE_AREA_A,
4.2958 + SUPPLEMENTARY_PRIVATE_USE_AREA_B
4.2959 + };
4.2960 +
4.2961 +
4.2962 + /**
4.2963 + * Returns the object representing the Unicode block containing the
4.2964 + * given character, or {@code null} if the character is not a
4.2965 + * member of a defined block.
4.2966 + *
4.2967 + * <p><b>Note:</b> This method cannot handle
4.2968 + * <a href="Character.html#supplementary"> supplementary
4.2969 + * characters</a>. To support all Unicode characters, including
4.2970 + * supplementary characters, use the {@link #of(int)} method.
4.2971 + *
4.2972 + * @param c The character in question
4.2973 + * @return The {@code UnicodeBlock} instance representing the
4.2974 + * Unicode block of which this character is a member, or
4.2975 + * {@code null} if the character is not a member of any
4.2976 + * Unicode block
4.2977 + */
4.2978 + public static UnicodeBlock of(char c) {
4.2979 + return of((int)c);
4.2980 + }
4.2981 +
4.2982 + /**
4.2983 + * Returns the object representing the Unicode block
4.2984 + * containing the given character (Unicode code point), or
4.2985 + * {@code null} if the character is not a member of a
4.2986 + * defined block.
4.2987 + *
4.2988 + * @param codePoint the character (Unicode code point) in question.
4.2989 + * @return The {@code UnicodeBlock} instance representing the
4.2990 + * Unicode block of which this character is a member, or
4.2991 + * {@code null} if the character is not a member of any
4.2992 + * Unicode block
4.2993 + * @exception IllegalArgumentException if the specified
4.2994 + * {@code codePoint} is an invalid Unicode code point.
4.2995 + * @see Character#isValidCodePoint(int)
4.2996 + * @since 1.5
4.2997 + */
4.2998 + public static UnicodeBlock of(int codePoint) {
4.2999 + if (!isValidCodePoint(codePoint)) {
4.3000 + throw new IllegalArgumentException();
4.3001 + }
4.3002 +
4.3003 + int top, bottom, current;
4.3004 + bottom = 0;
4.3005 + top = blockStarts.length;
4.3006 + current = top/2;
4.3007 +
4.3008 + // invariant: top > current >= bottom && codePoint >= unicodeBlockStarts[bottom]
4.3009 + while (top - bottom > 1) {
4.3010 + if (codePoint >= blockStarts[current]) {
4.3011 + bottom = current;
4.3012 + } else {
4.3013 + top = current;
4.3014 + }
4.3015 + current = (top + bottom) / 2;
4.3016 + }
4.3017 + return blocks[current];
4.3018 + }
4.3019 +
4.3020 + /**
4.3021 + * Returns the UnicodeBlock with the given name. Block
4.3022 + * names are determined by The Unicode Standard. The file
4.3023 + * Blocks-<version>.txt defines blocks for a particular
4.3024 + * version of the standard. The {@link Character} class specifies
4.3025 + * the version of the standard that it supports.
4.3026 + * <p>
4.3027 + * This method accepts block names in the following forms:
4.3028 + * <ol>
4.3029 + * <li> Canonical block names as defined by the Unicode Standard.
4.3030 + * For example, the standard defines a "Basic Latin" block. Therefore, this
4.3031 + * method accepts "Basic Latin" as a valid block name. The documentation of
4.3032 + * each UnicodeBlock provides the canonical name.
4.3033 + * <li>Canonical block names with all spaces removed. For example, "BasicLatin"
4.3034 + * is a valid block name for the "Basic Latin" block.
4.3035 + * <li>The text representation of each constant UnicodeBlock identifier.
4.3036 + * For example, this method will return the {@link #BASIC_LATIN} block if
4.3037 + * provided with the "BASIC_LATIN" name. This form replaces all spaces and
4.3038 + * hyphens in the canonical name with underscores.
4.3039 + * </ol>
4.3040 + * Finally, character case is ignored for all of the valid block name forms.
4.3041 + * For example, "BASIC_LATIN" and "basic_latin" are both valid block names.
4.3042 + * The en_US locale's case mapping rules are used to provide case-insensitive
4.3043 + * string comparisons for block name validation.
4.3044 + * <p>
4.3045 + * If the Unicode Standard changes block names, both the previous and
4.3046 + * current names will be accepted.
4.3047 + *
4.3048 + * @param blockName A {@code UnicodeBlock} name.
4.3049 + * @return The {@code UnicodeBlock} instance identified
4.3050 + * by {@code blockName}
4.3051 + * @throws IllegalArgumentException if {@code blockName} is an
4.3052 + * invalid name
4.3053 + * @throws NullPointerException if {@code blockName} is null
4.3054 + * @since 1.5
4.3055 + */
4.3056 + public static final UnicodeBlock forName(String blockName) {
4.3057 + UnicodeBlock block = map.get(blockName.toUpperCase(Locale.US));
4.3058 + if (block == null) {
4.3059 + throw new IllegalArgumentException();
4.3060 + }
4.3061 + return block;
4.3062 + }
4.3063 + }
4.3064 +
4.3065 +
4.3066 + /**
4.3067 + * A family of character subsets representing the character scripts
4.3068 + * defined in the <a href="http://www.unicode.org/reports/tr24/">
4.3069 + * <i>Unicode Standard Annex #24: Script Names</i></a>. Every Unicode
4.3070 + * character is assigned to a single Unicode script, either a specific
4.3071 + * script, such as {@link Character.UnicodeScript#LATIN Latin}, or
4.3072 + * one of the following three special values,
4.3073 + * {@link Character.UnicodeScript#INHERITED Inherited},
4.3074 + * {@link Character.UnicodeScript#COMMON Common} or
4.3075 + * {@link Character.UnicodeScript#UNKNOWN Unknown}.
4.3076 + *
4.3077 + * @since 1.7
4.3078 + */
4.3079 + public static enum UnicodeScript {
4.3080 + /**
4.3081 + * Unicode script "Common".
4.3082 + */
4.3083 + COMMON,
4.3084 +
4.3085 + /**
4.3086 + * Unicode script "Latin".
4.3087 + */
4.3088 + LATIN,
4.3089 +
4.3090 + /**
4.3091 + * Unicode script "Greek".
4.3092 + */
4.3093 + GREEK,
4.3094 +
4.3095 + /**
4.3096 + * Unicode script "Cyrillic".
4.3097 + */
4.3098 + CYRILLIC,
4.3099 +
4.3100 + /**
4.3101 + * Unicode script "Armenian".
4.3102 + */
4.3103 + ARMENIAN,
4.3104 +
4.3105 + /**
4.3106 + * Unicode script "Hebrew".
4.3107 + */
4.3108 + HEBREW,
4.3109 +
4.3110 + /**
4.3111 + * Unicode script "Arabic".
4.3112 + */
4.3113 + ARABIC,
4.3114 +
4.3115 + /**
4.3116 + * Unicode script "Syriac".
4.3117 + */
4.3118 + SYRIAC,
4.3119 +
4.3120 + /**
4.3121 + * Unicode script "Thaana".
4.3122 + */
4.3123 + THAANA,
4.3124 +
4.3125 + /**
4.3126 + * Unicode script "Devanagari".
4.3127 + */
4.3128 + DEVANAGARI,
4.3129 +
4.3130 + /**
4.3131 + * Unicode script "Bengali".
4.3132 + */
4.3133 + BENGALI,
4.3134 +
4.3135 + /**
4.3136 + * Unicode script "Gurmukhi".
4.3137 + */
4.3138 + GURMUKHI,
4.3139 +
4.3140 + /**
4.3141 + * Unicode script "Gujarati".
4.3142 + */
4.3143 + GUJARATI,
4.3144 +
4.3145 + /**
4.3146 + * Unicode script "Oriya".
4.3147 + */
4.3148 + ORIYA,
4.3149 +
4.3150 + /**
4.3151 + * Unicode script "Tamil".
4.3152 + */
4.3153 + TAMIL,
4.3154 +
4.3155 + /**
4.3156 + * Unicode script "Telugu".
4.3157 + */
4.3158 + TELUGU,
4.3159 +
4.3160 + /**
4.3161 + * Unicode script "Kannada".
4.3162 + */
4.3163 + KANNADA,
4.3164 +
4.3165 + /**
4.3166 + * Unicode script "Malayalam".
4.3167 + */
4.3168 + MALAYALAM,
4.3169 +
4.3170 + /**
4.3171 + * Unicode script "Sinhala".
4.3172 + */
4.3173 + SINHALA,
4.3174 +
4.3175 + /**
4.3176 + * Unicode script "Thai".
4.3177 + */
4.3178 + THAI,
4.3179 +
4.3180 + /**
4.3181 + * Unicode script "Lao".
4.3182 + */
4.3183 + LAO,
4.3184 +
4.3185 + /**
4.3186 + * Unicode script "Tibetan".
4.3187 + */
4.3188 + TIBETAN,
4.3189 +
4.3190 + /**
4.3191 + * Unicode script "Myanmar".
4.3192 + */
4.3193 + MYANMAR,
4.3194 +
4.3195 + /**
4.3196 + * Unicode script "Georgian".
4.3197 + */
4.3198 + GEORGIAN,
4.3199 +
4.3200 + /**
4.3201 + * Unicode script "Hangul".
4.3202 + */
4.3203 + HANGUL,
4.3204 +
4.3205 + /**
4.3206 + * Unicode script "Ethiopic".
4.3207 + */
4.3208 + ETHIOPIC,
4.3209 +
4.3210 + /**
4.3211 + * Unicode script "Cherokee".
4.3212 + */
4.3213 + CHEROKEE,
4.3214 +
4.3215 + /**
4.3216 + * Unicode script "Canadian_Aboriginal".
4.3217 + */
4.3218 + CANADIAN_ABORIGINAL,
4.3219 +
4.3220 + /**
4.3221 + * Unicode script "Ogham".
4.3222 + */
4.3223 + OGHAM,
4.3224 +
4.3225 + /**
4.3226 + * Unicode script "Runic".
4.3227 + */
4.3228 + RUNIC,
4.3229 +
4.3230 + /**
4.3231 + * Unicode script "Khmer".
4.3232 + */
4.3233 + KHMER,
4.3234 +
4.3235 + /**
4.3236 + * Unicode script "Mongolian".
4.3237 + */
4.3238 + MONGOLIAN,
4.3239 +
4.3240 + /**
4.3241 + * Unicode script "Hiragana".
4.3242 + */
4.3243 + HIRAGANA,
4.3244 +
4.3245 + /**
4.3246 + * Unicode script "Katakana".
4.3247 + */
4.3248 + KATAKANA,
4.3249 +
4.3250 + /**
4.3251 + * Unicode script "Bopomofo".
4.3252 + */
4.3253 + BOPOMOFO,
4.3254 +
4.3255 + /**
4.3256 + * Unicode script "Han".
4.3257 + */
4.3258 + HAN,
4.3259 +
4.3260 + /**
4.3261 + * Unicode script "Yi".
4.3262 + */
4.3263 + YI,
4.3264 +
4.3265 + /**
4.3266 + * Unicode script "Old_Italic".
4.3267 + */
4.3268 + OLD_ITALIC,
4.3269 +
4.3270 + /**
4.3271 + * Unicode script "Gothic".
4.3272 + */
4.3273 + GOTHIC,
4.3274 +
4.3275 + /**
4.3276 + * Unicode script "Deseret".
4.3277 + */
4.3278 + DESERET,
4.3279 +
4.3280 + /**
4.3281 + * Unicode script "Inherited".
4.3282 + */
4.3283 + INHERITED,
4.3284 +
4.3285 + /**
4.3286 + * Unicode script "Tagalog".
4.3287 + */
4.3288 + TAGALOG,
4.3289 +
4.3290 + /**
4.3291 + * Unicode script "Hanunoo".
4.3292 + */
4.3293 + HANUNOO,
4.3294 +
4.3295 + /**
4.3296 + * Unicode script "Buhid".
4.3297 + */
4.3298 + BUHID,
4.3299 +
4.3300 + /**
4.3301 + * Unicode script "Tagbanwa".
4.3302 + */
4.3303 + TAGBANWA,
4.3304 +
4.3305 + /**
4.3306 + * Unicode script "Limbu".
4.3307 + */
4.3308 + LIMBU,
4.3309 +
4.3310 + /**
4.3311 + * Unicode script "Tai_Le".
4.3312 + */
4.3313 + TAI_LE,
4.3314 +
4.3315 + /**
4.3316 + * Unicode script "Linear_B".
4.3317 + */
4.3318 + LINEAR_B,
4.3319 +
4.3320 + /**
4.3321 + * Unicode script "Ugaritic".
4.3322 + */
4.3323 + UGARITIC,
4.3324 +
4.3325 + /**
4.3326 + * Unicode script "Shavian".
4.3327 + */
4.3328 + SHAVIAN,
4.3329 +
4.3330 + /**
4.3331 + * Unicode script "Osmanya".
4.3332 + */
4.3333 + OSMANYA,
4.3334 +
4.3335 + /**
4.3336 + * Unicode script "Cypriot".
4.3337 + */
4.3338 + CYPRIOT,
4.3339 +
4.3340 + /**
4.3341 + * Unicode script "Braille".
4.3342 + */
4.3343 + BRAILLE,
4.3344 +
4.3345 + /**
4.3346 + * Unicode script "Buginese".
4.3347 + */
4.3348 + BUGINESE,
4.3349 +
4.3350 + /**
4.3351 + * Unicode script "Coptic".
4.3352 + */
4.3353 + COPTIC,
4.3354 +
4.3355 + /**
4.3356 + * Unicode script "New_Tai_Lue".
4.3357 + */
4.3358 + NEW_TAI_LUE,
4.3359 +
4.3360 + /**
4.3361 + * Unicode script "Glagolitic".
4.3362 + */
4.3363 + GLAGOLITIC,
4.3364 +
4.3365 + /**
4.3366 + * Unicode script "Tifinagh".
4.3367 + */
4.3368 + TIFINAGH,
4.3369 +
4.3370 + /**
4.3371 + * Unicode script "Syloti_Nagri".
4.3372 + */
4.3373 + SYLOTI_NAGRI,
4.3374 +
4.3375 + /**
4.3376 + * Unicode script "Old_Persian".
4.3377 + */
4.3378 + OLD_PERSIAN,
4.3379 +
4.3380 + /**
4.3381 + * Unicode script "Kharoshthi".
4.3382 + */
4.3383 + KHAROSHTHI,
4.3384 +
4.3385 + /**
4.3386 + * Unicode script "Balinese".
4.3387 + */
4.3388 + BALINESE,
4.3389 +
4.3390 + /**
4.3391 + * Unicode script "Cuneiform".
4.3392 + */
4.3393 + CUNEIFORM,
4.3394 +
4.3395 + /**
4.3396 + * Unicode script "Phoenician".
4.3397 + */
4.3398 + PHOENICIAN,
4.3399 +
4.3400 + /**
4.3401 + * Unicode script "Phags_Pa".
4.3402 + */
4.3403 + PHAGS_PA,
4.3404 +
4.3405 + /**
4.3406 + * Unicode script "Nko".
4.3407 + */
4.3408 + NKO,
4.3409 +
4.3410 + /**
4.3411 + * Unicode script "Sundanese".
4.3412 + */
4.3413 + SUNDANESE,
4.3414 +
4.3415 + /**
4.3416 + * Unicode script "Batak".
4.3417 + */
4.3418 + BATAK,
4.3419 +
4.3420 + /**
4.3421 + * Unicode script "Lepcha".
4.3422 + */
4.3423 + LEPCHA,
4.3424 +
4.3425 + /**
4.3426 + * Unicode script "Ol_Chiki".
4.3427 + */
4.3428 + OL_CHIKI,
4.3429 +
4.3430 + /**
4.3431 + * Unicode script "Vai".
4.3432 + */
4.3433 + VAI,
4.3434 +
4.3435 + /**
4.3436 + * Unicode script "Saurashtra".
4.3437 + */
4.3438 + SAURASHTRA,
4.3439 +
4.3440 + /**
4.3441 + * Unicode script "Kayah_Li".
4.3442 + */
4.3443 + KAYAH_LI,
4.3444 +
4.3445 + /**
4.3446 + * Unicode script "Rejang".
4.3447 + */
4.3448 + REJANG,
4.3449 +
4.3450 + /**
4.3451 + * Unicode script "Lycian".
4.3452 + */
4.3453 + LYCIAN,
4.3454 +
4.3455 + /**
4.3456 + * Unicode script "Carian".
4.3457 + */
4.3458 + CARIAN,
4.3459 +
4.3460 + /**
4.3461 + * Unicode script "Lydian".
4.3462 + */
4.3463 + LYDIAN,
4.3464 +
4.3465 + /**
4.3466 + * Unicode script "Cham".
4.3467 + */
4.3468 + CHAM,
4.3469 +
4.3470 + /**
4.3471 + * Unicode script "Tai_Tham".
4.3472 + */
4.3473 + TAI_THAM,
4.3474 +
4.3475 + /**
4.3476 + * Unicode script "Tai_Viet".
4.3477 + */
4.3478 + TAI_VIET,
4.3479 +
4.3480 + /**
4.3481 + * Unicode script "Avestan".
4.3482 + */
4.3483 + AVESTAN,
4.3484 +
4.3485 + /**
4.3486 + * Unicode script "Egyptian_Hieroglyphs".
4.3487 + */
4.3488 + EGYPTIAN_HIEROGLYPHS,
4.3489 +
4.3490 + /**
4.3491 + * Unicode script "Samaritan".
4.3492 + */
4.3493 + SAMARITAN,
4.3494 +
4.3495 + /**
4.3496 + * Unicode script "Mandaic".
4.3497 + */
4.3498 + MANDAIC,
4.3499 +
4.3500 + /**
4.3501 + * Unicode script "Lisu".
4.3502 + */
4.3503 + LISU,
4.3504 +
4.3505 + /**
4.3506 + * Unicode script "Bamum".
4.3507 + */
4.3508 + BAMUM,
4.3509 +
4.3510 + /**
4.3511 + * Unicode script "Javanese".
4.3512 + */
4.3513 + JAVANESE,
4.3514 +
4.3515 + /**
4.3516 + * Unicode script "Meetei_Mayek".
4.3517 + */
4.3518 + MEETEI_MAYEK,
4.3519 +
4.3520 + /**
4.3521 + * Unicode script "Imperial_Aramaic".
4.3522 + */
4.3523 + IMPERIAL_ARAMAIC,
4.3524 +
4.3525 + /**
4.3526 + * Unicode script "Old_South_Arabian".
4.3527 + */
4.3528 + OLD_SOUTH_ARABIAN,
4.3529 +
4.3530 + /**
4.3531 + * Unicode script "Inscriptional_Parthian".
4.3532 + */
4.3533 + INSCRIPTIONAL_PARTHIAN,
4.3534 +
4.3535 + /**
4.3536 + * Unicode script "Inscriptional_Pahlavi".
4.3537 + */
4.3538 + INSCRIPTIONAL_PAHLAVI,
4.3539 +
4.3540 + /**
4.3541 + * Unicode script "Old_Turkic".
4.3542 + */
4.3543 + OLD_TURKIC,
4.3544 +
4.3545 + /**
4.3546 + * Unicode script "Brahmi".
4.3547 + */
4.3548 + BRAHMI,
4.3549 +
4.3550 + /**
4.3551 + * Unicode script "Kaithi".
4.3552 + */
4.3553 + KAITHI,
4.3554 +
4.3555 + /**
4.3556 + * Unicode script "Unknown".
4.3557 + */
4.3558 + UNKNOWN;
4.3559 +
4.3560 + private static final int[] scriptStarts = {
4.3561 + 0x0000, // 0000..0040; COMMON
4.3562 + 0x0041, // 0041..005A; LATIN
4.3563 + 0x005B, // 005B..0060; COMMON
4.3564 + 0x0061, // 0061..007A; LATIN
4.3565 + 0x007B, // 007B..00A9; COMMON
4.3566 + 0x00AA, // 00AA..00AA; LATIN
4.3567 + 0x00AB, // 00AB..00B9; COMMON
4.3568 + 0x00BA, // 00BA..00BA; LATIN
4.3569 + 0x00BB, // 00BB..00BF; COMMON
4.3570 + 0x00C0, // 00C0..00D6; LATIN
4.3571 + 0x00D7, // 00D7..00D7; COMMON
4.3572 + 0x00D8, // 00D8..00F6; LATIN
4.3573 + 0x00F7, // 00F7..00F7; COMMON
4.3574 + 0x00F8, // 00F8..02B8; LATIN
4.3575 + 0x02B9, // 02B9..02DF; COMMON
4.3576 + 0x02E0, // 02E0..02E4; LATIN
4.3577 + 0x02E5, // 02E5..02E9; COMMON
4.3578 + 0x02EA, // 02EA..02EB; BOPOMOFO
4.3579 + 0x02EC, // 02EC..02FF; COMMON
4.3580 + 0x0300, // 0300..036F; INHERITED
4.3581 + 0x0370, // 0370..0373; GREEK
4.3582 + 0x0374, // 0374..0374; COMMON
4.3583 + 0x0375, // 0375..037D; GREEK
4.3584 + 0x037E, // 037E..0383; COMMON
4.3585 + 0x0384, // 0384..0384; GREEK
4.3586 + 0x0385, // 0385..0385; COMMON
4.3587 + 0x0386, // 0386..0386; GREEK
4.3588 + 0x0387, // 0387..0387; COMMON
4.3589 + 0x0388, // 0388..03E1; GREEK
4.3590 + 0x03E2, // 03E2..03EF; COPTIC
4.3591 + 0x03F0, // 03F0..03FF; GREEK
4.3592 + 0x0400, // 0400..0484; CYRILLIC
4.3593 + 0x0485, // 0485..0486; INHERITED
4.3594 + 0x0487, // 0487..0530; CYRILLIC
4.3595 + 0x0531, // 0531..0588; ARMENIAN
4.3596 + 0x0589, // 0589..0589; COMMON
4.3597 + 0x058A, // 058A..0590; ARMENIAN
4.3598 + 0x0591, // 0591..05FF; HEBREW
4.3599 + 0x0600, // 0600..060B; ARABIC
4.3600 + 0x060C, // 060C..060C; COMMON
4.3601 + 0x060D, // 060D..061A; ARABIC
4.3602 + 0x061B, // 061B..061D; COMMON
4.3603 + 0x061E, // 061E..061E; ARABIC
4.3604 + 0x061F, // 061F..061F; COMMON
4.3605 + 0x0620, // 0620..063F; ARABIC
4.3606 + 0x0640, // 0640..0640; COMMON
4.3607 + 0x0641, // 0641..064A; ARABIC
4.3608 + 0x064B, // 064B..0655; INHERITED
4.3609 + 0x0656, // 0656..065E; ARABIC
4.3610 + 0x065F, // 065F..065F; INHERITED
4.3611 + 0x0660, // 0660..0669; COMMON
4.3612 + 0x066A, // 066A..066F; ARABIC
4.3613 + 0x0670, // 0670..0670; INHERITED
4.3614 + 0x0671, // 0671..06DC; ARABIC
4.3615 + 0x06DD, // 06DD..06DD; COMMON
4.3616 + 0x06DE, // 06DE..06FF; ARABIC
4.3617 + 0x0700, // 0700..074F; SYRIAC
4.3618 + 0x0750, // 0750..077F; ARABIC
4.3619 + 0x0780, // 0780..07BF; THAANA
4.3620 + 0x07C0, // 07C0..07FF; NKO
4.3621 + 0x0800, // 0800..083F; SAMARITAN
4.3622 + 0x0840, // 0840..08FF; MANDAIC
4.3623 + 0x0900, // 0900..0950; DEVANAGARI
4.3624 + 0x0951, // 0951..0952; INHERITED
4.3625 + 0x0953, // 0953..0963; DEVANAGARI
4.3626 + 0x0964, // 0964..0965; COMMON
4.3627 + 0x0966, // 0966..096F; DEVANAGARI
4.3628 + 0x0970, // 0970..0970; COMMON
4.3629 + 0x0971, // 0971..0980; DEVANAGARI
4.3630 + 0x0981, // 0981..0A00; BENGALI
4.3631 + 0x0A01, // 0A01..0A80; GURMUKHI
4.3632 + 0x0A81, // 0A81..0B00; GUJARATI
4.3633 + 0x0B01, // 0B01..0B81; ORIYA
4.3634 + 0x0B82, // 0B82..0C00; TAMIL
4.3635 + 0x0C01, // 0C01..0C81; TELUGU
4.3636 + 0x0C82, // 0C82..0CF0; KANNADA
4.3637 + 0x0D02, // 0D02..0D81; MALAYALAM
4.3638 + 0x0D82, // 0D82..0E00; SINHALA
4.3639 + 0x0E01, // 0E01..0E3E; THAI
4.3640 + 0x0E3F, // 0E3F..0E3F; COMMON
4.3641 + 0x0E40, // 0E40..0E80; THAI
4.3642 + 0x0E81, // 0E81..0EFF; LAO
4.3643 + 0x0F00, // 0F00..0FD4; TIBETAN
4.3644 + 0x0FD5, // 0FD5..0FD8; COMMON
4.3645 + 0x0FD9, // 0FD9..0FFF; TIBETAN
4.3646 + 0x1000, // 1000..109F; MYANMAR
4.3647 + 0x10A0, // 10A0..10FA; GEORGIAN
4.3648 + 0x10FB, // 10FB..10FB; COMMON
4.3649 + 0x10FC, // 10FC..10FF; GEORGIAN
4.3650 + 0x1100, // 1100..11FF; HANGUL
4.3651 + 0x1200, // 1200..139F; ETHIOPIC
4.3652 + 0x13A0, // 13A0..13FF; CHEROKEE
4.3653 + 0x1400, // 1400..167F; CANADIAN_ABORIGINAL
4.3654 + 0x1680, // 1680..169F; OGHAM
4.3655 + 0x16A0, // 16A0..16EA; RUNIC
4.3656 + 0x16EB, // 16EB..16ED; COMMON
4.3657 + 0x16EE, // 16EE..16FF; RUNIC
4.3658 + 0x1700, // 1700..171F; TAGALOG
4.3659 + 0x1720, // 1720..1734; HANUNOO
4.3660 + 0x1735, // 1735..173F; COMMON
4.3661 + 0x1740, // 1740..175F; BUHID
4.3662 + 0x1760, // 1760..177F; TAGBANWA
4.3663 + 0x1780, // 1780..17FF; KHMER
4.3664 + 0x1800, // 1800..1801; MONGOLIAN
4.3665 + 0x1802, // 1802..1803; COMMON
4.3666 + 0x1804, // 1804..1804; MONGOLIAN
4.3667 + 0x1805, // 1805..1805; COMMON
4.3668 + 0x1806, // 1806..18AF; MONGOLIAN
4.3669 + 0x18B0, // 18B0..18FF; CANADIAN_ABORIGINAL
4.3670 + 0x1900, // 1900..194F; LIMBU
4.3671 + 0x1950, // 1950..197F; TAI_LE
4.3672 + 0x1980, // 1980..19DF; NEW_TAI_LUE
4.3673 + 0x19E0, // 19E0..19FF; KHMER
4.3674 + 0x1A00, // 1A00..1A1F; BUGINESE
4.3675 + 0x1A20, // 1A20..1AFF; TAI_THAM
4.3676 + 0x1B00, // 1B00..1B7F; BALINESE
4.3677 + 0x1B80, // 1B80..1BBF; SUNDANESE
4.3678 + 0x1BC0, // 1BC0..1BFF; BATAK
4.3679 + 0x1C00, // 1C00..1C4F; LEPCHA
4.3680 + 0x1C50, // 1C50..1CCF; OL_CHIKI
4.3681 + 0x1CD0, // 1CD0..1CD2; INHERITED
4.3682 + 0x1CD3, // 1CD3..1CD3; COMMON
4.3683 + 0x1CD4, // 1CD4..1CE0; INHERITED
4.3684 + 0x1CE1, // 1CE1..1CE1; COMMON
4.3685 + 0x1CE2, // 1CE2..1CE8; INHERITED
4.3686 + 0x1CE9, // 1CE9..1CEC; COMMON
4.3687 + 0x1CED, // 1CED..1CED; INHERITED
4.3688 + 0x1CEE, // 1CEE..1CFF; COMMON
4.3689 + 0x1D00, // 1D00..1D25; LATIN
4.3690 + 0x1D26, // 1D26..1D2A; GREEK
4.3691 + 0x1D2B, // 1D2B..1D2B; CYRILLIC
4.3692 + 0x1D2C, // 1D2C..1D5C; LATIN
4.3693 + 0x1D5D, // 1D5D..1D61; GREEK
4.3694 + 0x1D62, // 1D62..1D65; LATIN
4.3695 + 0x1D66, // 1D66..1D6A; GREEK
4.3696 + 0x1D6B, // 1D6B..1D77; LATIN
4.3697 + 0x1D78, // 1D78..1D78; CYRILLIC
4.3698 + 0x1D79, // 1D79..1DBE; LATIN
4.3699 + 0x1DBF, // 1DBF..1DBF; GREEK
4.3700 + 0x1DC0, // 1DC0..1DFF; INHERITED
4.3701 + 0x1E00, // 1E00..1EFF; LATIN
4.3702 + 0x1F00, // 1F00..1FFF; GREEK
4.3703 + 0x2000, // 2000..200B; COMMON
4.3704 + 0x200C, // 200C..200D; INHERITED
4.3705 + 0x200E, // 200E..2070; COMMON
4.3706 + 0x2071, // 2071..2073; LATIN
4.3707 + 0x2074, // 2074..207E; COMMON
4.3708 + 0x207F, // 207F..207F; LATIN
4.3709 + 0x2080, // 2080..208F; COMMON
4.3710 + 0x2090, // 2090..209F; LATIN
4.3711 + 0x20A0, // 20A0..20CF; COMMON
4.3712 + 0x20D0, // 20D0..20FF; INHERITED
4.3713 + 0x2100, // 2100..2125; COMMON
4.3714 + 0x2126, // 2126..2126; GREEK
4.3715 + 0x2127, // 2127..2129; COMMON
4.3716 + 0x212A, // 212A..212B; LATIN
4.3717 + 0x212C, // 212C..2131; COMMON
4.3718 + 0x2132, // 2132..2132; LATIN
4.3719 + 0x2133, // 2133..214D; COMMON
4.3720 + 0x214E, // 214E..214E; LATIN
4.3721 + 0x214F, // 214F..215F; COMMON
4.3722 + 0x2160, // 2160..2188; LATIN
4.3723 + 0x2189, // 2189..27FF; COMMON
4.3724 + 0x2800, // 2800..28FF; BRAILLE
4.3725 + 0x2900, // 2900..2BFF; COMMON
4.3726 + 0x2C00, // 2C00..2C5F; GLAGOLITIC
4.3727 + 0x2C60, // 2C60..2C7F; LATIN
4.3728 + 0x2C80, // 2C80..2CFF; COPTIC
4.3729 + 0x2D00, // 2D00..2D2F; GEORGIAN
4.3730 + 0x2D30, // 2D30..2D7F; TIFINAGH
4.3731 + 0x2D80, // 2D80..2DDF; ETHIOPIC
4.3732 + 0x2DE0, // 2DE0..2DFF; CYRILLIC
4.3733 + 0x2E00, // 2E00..2E7F; COMMON
4.3734 + 0x2E80, // 2E80..2FEF; HAN
4.3735 + 0x2FF0, // 2FF0..3004; COMMON
4.3736 + 0x3005, // 3005..3005; HAN
4.3737 + 0x3006, // 3006..3006; COMMON
4.3738 + 0x3007, // 3007..3007; HAN
4.3739 + 0x3008, // 3008..3020; COMMON
4.3740 + 0x3021, // 3021..3029; HAN
4.3741 + 0x302A, // 302A..302D; INHERITED
4.3742 + 0x302E, // 302E..302F; HANGUL
4.3743 + 0x3030, // 3030..3037; COMMON
4.3744 + 0x3038, // 3038..303B; HAN
4.3745 + 0x303C, // 303C..3040; COMMON
4.3746 + 0x3041, // 3041..3098; HIRAGANA
4.3747 + 0x3099, // 3099..309A; INHERITED
4.3748 + 0x309B, // 309B..309C; COMMON
4.3749 + 0x309D, // 309D..309F; HIRAGANA
4.3750 + 0x30A0, // 30A0..30A0; COMMON
4.3751 + 0x30A1, // 30A1..30FA; KATAKANA
4.3752 + 0x30FB, // 30FB..30FC; COMMON
4.3753 + 0x30FD, // 30FD..3104; KATAKANA
4.3754 + 0x3105, // 3105..3130; BOPOMOFO
4.3755 + 0x3131, // 3131..318F; HANGUL
4.3756 + 0x3190, // 3190..319F; COMMON
4.3757 + 0x31A0, // 31A0..31BF; BOPOMOFO
4.3758 + 0x31C0, // 31C0..31EF; COMMON
4.3759 + 0x31F0, // 31F0..31FF; KATAKANA
4.3760 + 0x3200, // 3200..321F; HANGUL
4.3761 + 0x3220, // 3220..325F; COMMON
4.3762 + 0x3260, // 3260..327E; HANGUL
4.3763 + 0x327F, // 327F..32CF; COMMON
4.3764 + 0x32D0, // 32D0..3357; KATAKANA
4.3765 + 0x3358, // 3358..33FF; COMMON
4.3766 + 0x3400, // 3400..4DBF; HAN
4.3767 + 0x4DC0, // 4DC0..4DFF; COMMON
4.3768 + 0x4E00, // 4E00..9FFF; HAN
4.3769 + 0xA000, // A000..A4CF; YI
4.3770 + 0xA4D0, // A4D0..A4FF; LISU
4.3771 + 0xA500, // A500..A63F; VAI
4.3772 + 0xA640, // A640..A69F; CYRILLIC
4.3773 + 0xA6A0, // A6A0..A6FF; BAMUM
4.3774 + 0xA700, // A700..A721; COMMON
4.3775 + 0xA722, // A722..A787; LATIN
4.3776 + 0xA788, // A788..A78A; COMMON
4.3777 + 0xA78B, // A78B..A7FF; LATIN
4.3778 + 0xA800, // A800..A82F; SYLOTI_NAGRI
4.3779 + 0xA830, // A830..A83F; COMMON
4.3780 + 0xA840, // A840..A87F; PHAGS_PA
4.3781 + 0xA880, // A880..A8DF; SAURASHTRA
4.3782 + 0xA8E0, // A8E0..A8FF; DEVANAGARI
4.3783 + 0xA900, // A900..A92F; KAYAH_LI
4.3784 + 0xA930, // A930..A95F; REJANG
4.3785 + 0xA960, // A960..A97F; HANGUL
4.3786 + 0xA980, // A980..A9FF; JAVANESE
4.3787 + 0xAA00, // AA00..AA5F; CHAM
4.3788 + 0xAA60, // AA60..AA7F; MYANMAR
4.3789 + 0xAA80, // AA80..AB00; TAI_VIET
4.3790 + 0xAB01, // AB01..ABBF; ETHIOPIC
4.3791 + 0xABC0, // ABC0..ABFF; MEETEI_MAYEK
4.3792 + 0xAC00, // AC00..D7FB; HANGUL
4.3793 + 0xD7FC, // D7FC..F8FF; UNKNOWN
4.3794 + 0xF900, // F900..FAFF; HAN
4.3795 + 0xFB00, // FB00..FB12; LATIN
4.3796 + 0xFB13, // FB13..FB1C; ARMENIAN
4.3797 + 0xFB1D, // FB1D..FB4F; HEBREW
4.3798 + 0xFB50, // FB50..FD3D; ARABIC
4.3799 + 0xFD3E, // FD3E..FD4F; COMMON
4.3800 + 0xFD50, // FD50..FDFC; ARABIC
4.3801 + 0xFDFD, // FDFD..FDFF; COMMON
4.3802 + 0xFE00, // FE00..FE0F; INHERITED
4.3803 + 0xFE10, // FE10..FE1F; COMMON
4.3804 + 0xFE20, // FE20..FE2F; INHERITED
4.3805 + 0xFE30, // FE30..FE6F; COMMON
4.3806 + 0xFE70, // FE70..FEFE; ARABIC
4.3807 + 0xFEFF, // FEFF..FF20; COMMON
4.3808 + 0xFF21, // FF21..FF3A; LATIN
4.3809 + 0xFF3B, // FF3B..FF40; COMMON
4.3810 + 0xFF41, // FF41..FF5A; LATIN
4.3811 + 0xFF5B, // FF5B..FF65; COMMON
4.3812 + 0xFF66, // FF66..FF6F; KATAKANA
4.3813 + 0xFF70, // FF70..FF70; COMMON
4.3814 + 0xFF71, // FF71..FF9D; KATAKANA
4.3815 + 0xFF9E, // FF9E..FF9F; COMMON
4.3816 + 0xFFA0, // FFA0..FFDF; HANGUL
4.3817 + 0xFFE0, // FFE0..FFFF; COMMON
4.3818 + 0x10000, // 10000..100FF; LINEAR_B
4.3819 + 0x10100, // 10100..1013F; COMMON
4.3820 + 0x10140, // 10140..1018F; GREEK
4.3821 + 0x10190, // 10190..101FC; COMMON
4.3822 + 0x101FD, // 101FD..1027F; INHERITED
4.3823 + 0x10280, // 10280..1029F; LYCIAN
4.3824 + 0x102A0, // 102A0..102FF; CARIAN
4.3825 + 0x10300, // 10300..1032F; OLD_ITALIC
4.3826 + 0x10330, // 10330..1037F; GOTHIC
4.3827 + 0x10380, // 10380..1039F; UGARITIC
4.3828 + 0x103A0, // 103A0..103FF; OLD_PERSIAN
4.3829 + 0x10400, // 10400..1044F; DESERET
4.3830 + 0x10450, // 10450..1047F; SHAVIAN
4.3831 + 0x10480, // 10480..107FF; OSMANYA
4.3832 + 0x10800, // 10800..1083F; CYPRIOT
4.3833 + 0x10840, // 10840..108FF; IMPERIAL_ARAMAIC
4.3834 + 0x10900, // 10900..1091F; PHOENICIAN
4.3835 + 0x10920, // 10920..109FF; LYDIAN
4.3836 + 0x10A00, // 10A00..10A5F; KHAROSHTHI
4.3837 + 0x10A60, // 10A60..10AFF; OLD_SOUTH_ARABIAN
4.3838 + 0x10B00, // 10B00..10B3F; AVESTAN
4.3839 + 0x10B40, // 10B40..10B5F; INSCRIPTIONAL_PARTHIAN
4.3840 + 0x10B60, // 10B60..10BFF; INSCRIPTIONAL_PAHLAVI
4.3841 + 0x10C00, // 10C00..10E5F; OLD_TURKIC
4.3842 + 0x10E60, // 10E60..10FFF; ARABIC
4.3843 + 0x11000, // 11000..1107F; BRAHMI
4.3844 + 0x11080, // 11080..11FFF; KAITHI
4.3845 + 0x12000, // 12000..12FFF; CUNEIFORM
4.3846 + 0x13000, // 13000..167FF; EGYPTIAN_HIEROGLYPHS
4.3847 + 0x16800, // 16800..16A38; BAMUM
4.3848 + 0x1B000, // 1B000..1B000; KATAKANA
4.3849 + 0x1B001, // 1B001..1CFFF; HIRAGANA
4.3850 + 0x1D000, // 1D000..1D166; COMMON
4.3851 + 0x1D167, // 1D167..1D169; INHERITED
4.3852 + 0x1D16A, // 1D16A..1D17A; COMMON
4.3853 + 0x1D17B, // 1D17B..1D182; INHERITED
4.3854 + 0x1D183, // 1D183..1D184; COMMON
4.3855 + 0x1D185, // 1D185..1D18B; INHERITED
4.3856 + 0x1D18C, // 1D18C..1D1A9; COMMON
4.3857 + 0x1D1AA, // 1D1AA..1D1AD; INHERITED
4.3858 + 0x1D1AE, // 1D1AE..1D1FF; COMMON
4.3859 + 0x1D200, // 1D200..1D2FF; GREEK
4.3860 + 0x1D300, // 1D300..1F1FF; COMMON
4.3861 + 0x1F200, // 1F200..1F200; HIRAGANA
4.3862 + 0x1F201, // 1F210..1FFFF; COMMON
4.3863 + 0x20000, // 20000..E0000; HAN
4.3864 + 0xE0001, // E0001..E00FF; COMMON
4.3865 + 0xE0100, // E0100..E01EF; INHERITED
4.3866 + 0xE01F0 // E01F0..10FFFF; UNKNOWN
4.3867 +
4.3868 + };
4.3869 +
4.3870 + private static final UnicodeScript[] scripts = {
4.3871 + COMMON,
4.3872 + LATIN,
4.3873 + COMMON,
4.3874 + LATIN,
4.3875 + COMMON,
4.3876 + LATIN,
4.3877 + COMMON,
4.3878 + LATIN,
4.3879 + COMMON,
4.3880 + LATIN,
4.3881 + COMMON,
4.3882 + LATIN,
4.3883 + COMMON,
4.3884 + LATIN,
4.3885 + COMMON,
4.3886 + LATIN,
4.3887 + COMMON,
4.3888 + BOPOMOFO,
4.3889 + COMMON,
4.3890 + INHERITED,
4.3891 + GREEK,
4.3892 + COMMON,
4.3893 + GREEK,
4.3894 + COMMON,
4.3895 + GREEK,
4.3896 + COMMON,
4.3897 + GREEK,
4.3898 + COMMON,
4.3899 + GREEK,
4.3900 + COPTIC,
4.3901 + GREEK,
4.3902 + CYRILLIC,
4.3903 + INHERITED,
4.3904 + CYRILLIC,
4.3905 + ARMENIAN,
4.3906 + COMMON,
4.3907 + ARMENIAN,
4.3908 + HEBREW,
4.3909 + ARABIC,
4.3910 + COMMON,
4.3911 + ARABIC,
4.3912 + COMMON,
4.3913 + ARABIC,
4.3914 + COMMON,
4.3915 + ARABIC,
4.3916 + COMMON,
4.3917 + ARABIC,
4.3918 + INHERITED,
4.3919 + ARABIC,
4.3920 + INHERITED,
4.3921 + COMMON,
4.3922 + ARABIC,
4.3923 + INHERITED,
4.3924 + ARABIC,
4.3925 + COMMON,
4.3926 + ARABIC,
4.3927 + SYRIAC,
4.3928 + ARABIC,
4.3929 + THAANA,
4.3930 + NKO,
4.3931 + SAMARITAN,
4.3932 + MANDAIC,
4.3933 + DEVANAGARI,
4.3934 + INHERITED,
4.3935 + DEVANAGARI,
4.3936 + COMMON,
4.3937 + DEVANAGARI,
4.3938 + COMMON,
4.3939 + DEVANAGARI,
4.3940 + BENGALI,
4.3941 + GURMUKHI,
4.3942 + GUJARATI,
4.3943 + ORIYA,
4.3944 + TAMIL,
4.3945 + TELUGU,
4.3946 + KANNADA,
4.3947 + MALAYALAM,
4.3948 + SINHALA,
4.3949 + THAI,
4.3950 + COMMON,
4.3951 + THAI,
4.3952 + LAO,
4.3953 + TIBETAN,
4.3954 + COMMON,
4.3955 + TIBETAN,
4.3956 + MYANMAR,
4.3957 + GEORGIAN,
4.3958 + COMMON,
4.3959 + GEORGIAN,
4.3960 + HANGUL,
4.3961 + ETHIOPIC,
4.3962 + CHEROKEE,
4.3963 + CANADIAN_ABORIGINAL,
4.3964 + OGHAM,
4.3965 + RUNIC,
4.3966 + COMMON,
4.3967 + RUNIC,
4.3968 + TAGALOG,
4.3969 + HANUNOO,
4.3970 + COMMON,
4.3971 + BUHID,
4.3972 + TAGBANWA,
4.3973 + KHMER,
4.3974 + MONGOLIAN,
4.3975 + COMMON,
4.3976 + MONGOLIAN,
4.3977 + COMMON,
4.3978 + MONGOLIAN,
4.3979 + CANADIAN_ABORIGINAL,
4.3980 + LIMBU,
4.3981 + TAI_LE,
4.3982 + NEW_TAI_LUE,
4.3983 + KHMER,
4.3984 + BUGINESE,
4.3985 + TAI_THAM,
4.3986 + BALINESE,
4.3987 + SUNDANESE,
4.3988 + BATAK,
4.3989 + LEPCHA,
4.3990 + OL_CHIKI,
4.3991 + INHERITED,
4.3992 + COMMON,
4.3993 + INHERITED,
4.3994 + COMMON,
4.3995 + INHERITED,
4.3996 + COMMON,
4.3997 + INHERITED,
4.3998 + COMMON,
4.3999 + LATIN,
4.4000 + GREEK,
4.4001 + CYRILLIC,
4.4002 + LATIN,
4.4003 + GREEK,
4.4004 + LATIN,
4.4005 + GREEK,
4.4006 + LATIN,
4.4007 + CYRILLIC,
4.4008 + LATIN,
4.4009 + GREEK,
4.4010 + INHERITED,
4.4011 + LATIN,
4.4012 + GREEK,
4.4013 + COMMON,
4.4014 + INHERITED,
4.4015 + COMMON,
4.4016 + LATIN,
4.4017 + COMMON,
4.4018 + LATIN,
4.4019 + COMMON,
4.4020 + LATIN,
4.4021 + COMMON,
4.4022 + INHERITED,
4.4023 + COMMON,
4.4024 + GREEK,
4.4025 + COMMON,
4.4026 + LATIN,
4.4027 + COMMON,
4.4028 + LATIN,
4.4029 + COMMON,
4.4030 + LATIN,
4.4031 + COMMON,
4.4032 + LATIN,
4.4033 + COMMON,
4.4034 + BRAILLE,
4.4035 + COMMON,
4.4036 + GLAGOLITIC,
4.4037 + LATIN,
4.4038 + COPTIC,
4.4039 + GEORGIAN,
4.4040 + TIFINAGH,
4.4041 + ETHIOPIC,
4.4042 + CYRILLIC,
4.4043 + COMMON,
4.4044 + HAN,
4.4045 + COMMON,
4.4046 + HAN,
4.4047 + COMMON,
4.4048 + HAN,
4.4049 + COMMON,
4.4050 + HAN,
4.4051 + INHERITED,
4.4052 + HANGUL,
4.4053 + COMMON,
4.4054 + HAN,
4.4055 + COMMON,
4.4056 + HIRAGANA,
4.4057 + INHERITED,
4.4058 + COMMON,
4.4059 + HIRAGANA,
4.4060 + COMMON,
4.4061 + KATAKANA,
4.4062 + COMMON,
4.4063 + KATAKANA,
4.4064 + BOPOMOFO,
4.4065 + HANGUL,
4.4066 + COMMON,
4.4067 + BOPOMOFO,
4.4068 + COMMON,
4.4069 + KATAKANA,
4.4070 + HANGUL,
4.4071 + COMMON,
4.4072 + HANGUL,
4.4073 + COMMON,
4.4074 + KATAKANA,
4.4075 + COMMON,
4.4076 + HAN,
4.4077 + COMMON,
4.4078 + HAN,
4.4079 + YI,
4.4080 + LISU,
4.4081 + VAI,
4.4082 + CYRILLIC,
4.4083 + BAMUM,
4.4084 + COMMON,
4.4085 + LATIN,
4.4086 + COMMON,
4.4087 + LATIN,
4.4088 + SYLOTI_NAGRI,
4.4089 + COMMON,
4.4090 + PHAGS_PA,
4.4091 + SAURASHTRA,
4.4092 + DEVANAGARI,
4.4093 + KAYAH_LI,
4.4094 + REJANG,
4.4095 + HANGUL,
4.4096 + JAVANESE,
4.4097 + CHAM,
4.4098 + MYANMAR,
4.4099 + TAI_VIET,
4.4100 + ETHIOPIC,
4.4101 + MEETEI_MAYEK,
4.4102 + HANGUL,
4.4103 + UNKNOWN,
4.4104 + HAN,
4.4105 + LATIN,
4.4106 + ARMENIAN,
4.4107 + HEBREW,
4.4108 + ARABIC,
4.4109 + COMMON,
4.4110 + ARABIC,
4.4111 + COMMON,
4.4112 + INHERITED,
4.4113 + COMMON,
4.4114 + INHERITED,
4.4115 + COMMON,
4.4116 + ARABIC,
4.4117 + COMMON,
4.4118 + LATIN,
4.4119 + COMMON,
4.4120 + LATIN,
4.4121 + COMMON,
4.4122 + KATAKANA,
4.4123 + COMMON,
4.4124 + KATAKANA,
4.4125 + COMMON,
4.4126 + HANGUL,
4.4127 + COMMON,
4.4128 + LINEAR_B,
4.4129 + COMMON,
4.4130 + GREEK,
4.4131 + COMMON,
4.4132 + INHERITED,
4.4133 + LYCIAN,
4.4134 + CARIAN,
4.4135 + OLD_ITALIC,
4.4136 + GOTHIC,
4.4137 + UGARITIC,
4.4138 + OLD_PERSIAN,
4.4139 + DESERET,
4.4140 + SHAVIAN,
4.4141 + OSMANYA,
4.4142 + CYPRIOT,
4.4143 + IMPERIAL_ARAMAIC,
4.4144 + PHOENICIAN,
4.4145 + LYDIAN,
4.4146 + KHAROSHTHI,
4.4147 + OLD_SOUTH_ARABIAN,
4.4148 + AVESTAN,
4.4149 + INSCRIPTIONAL_PARTHIAN,
4.4150 + INSCRIPTIONAL_PAHLAVI,
4.4151 + OLD_TURKIC,
4.4152 + ARABIC,
4.4153 + BRAHMI,
4.4154 + KAITHI,
4.4155 + CUNEIFORM,
4.4156 + EGYPTIAN_HIEROGLYPHS,
4.4157 + BAMUM,
4.4158 + KATAKANA,
4.4159 + HIRAGANA,
4.4160 + COMMON,
4.4161 + INHERITED,
4.4162 + COMMON,
4.4163 + INHERITED,
4.4164 + COMMON,
4.4165 + INHERITED,
4.4166 + COMMON,
4.4167 + INHERITED,
4.4168 + COMMON,
4.4169 + GREEK,
4.4170 + COMMON,
4.4171 + HIRAGANA,
4.4172 + COMMON,
4.4173 + HAN,
4.4174 + COMMON,
4.4175 + INHERITED,
4.4176 + UNKNOWN
4.4177 + };
4.4178 +
4.4179 + private static HashMap<String, Character.UnicodeScript> aliases;
4.4180 + static {
4.4181 + aliases = new HashMap<>(128);
4.4182 + aliases.put("ARAB", ARABIC);
4.4183 + aliases.put("ARMI", IMPERIAL_ARAMAIC);
4.4184 + aliases.put("ARMN", ARMENIAN);
4.4185 + aliases.put("AVST", AVESTAN);
4.4186 + aliases.put("BALI", BALINESE);
4.4187 + aliases.put("BAMU", BAMUM);
4.4188 + aliases.put("BATK", BATAK);
4.4189 + aliases.put("BENG", BENGALI);
4.4190 + aliases.put("BOPO", BOPOMOFO);
4.4191 + aliases.put("BRAI", BRAILLE);
4.4192 + aliases.put("BRAH", BRAHMI);
4.4193 + aliases.put("BUGI", BUGINESE);
4.4194 + aliases.put("BUHD", BUHID);
4.4195 + aliases.put("CANS", CANADIAN_ABORIGINAL);
4.4196 + aliases.put("CARI", CARIAN);
4.4197 + aliases.put("CHAM", CHAM);
4.4198 + aliases.put("CHER", CHEROKEE);
4.4199 + aliases.put("COPT", COPTIC);
4.4200 + aliases.put("CPRT", CYPRIOT);
4.4201 + aliases.put("CYRL", CYRILLIC);
4.4202 + aliases.put("DEVA", DEVANAGARI);
4.4203 + aliases.put("DSRT", DESERET);
4.4204 + aliases.put("EGYP", EGYPTIAN_HIEROGLYPHS);
4.4205 + aliases.put("ETHI", ETHIOPIC);
4.4206 + aliases.put("GEOR", GEORGIAN);
4.4207 + aliases.put("GLAG", GLAGOLITIC);
4.4208 + aliases.put("GOTH", GOTHIC);
4.4209 + aliases.put("GREK", GREEK);
4.4210 + aliases.put("GUJR", GUJARATI);
4.4211 + aliases.put("GURU", GURMUKHI);
4.4212 + aliases.put("HANG", HANGUL);
4.4213 + aliases.put("HANI", HAN);
4.4214 + aliases.put("HANO", HANUNOO);
4.4215 + aliases.put("HEBR", HEBREW);
4.4216 + aliases.put("HIRA", HIRAGANA);
4.4217 + // it appears we don't have the KATAKANA_OR_HIRAGANA
4.4218 + //aliases.put("HRKT", KATAKANA_OR_HIRAGANA);
4.4219 + aliases.put("ITAL", OLD_ITALIC);
4.4220 + aliases.put("JAVA", JAVANESE);
4.4221 + aliases.put("KALI", KAYAH_LI);
4.4222 + aliases.put("KANA", KATAKANA);
4.4223 + aliases.put("KHAR", KHAROSHTHI);
4.4224 + aliases.put("KHMR", KHMER);
4.4225 + aliases.put("KNDA", KANNADA);
4.4226 + aliases.put("KTHI", KAITHI);
4.4227 + aliases.put("LANA", TAI_THAM);
4.4228 + aliases.put("LAOO", LAO);
4.4229 + aliases.put("LATN", LATIN);
4.4230 + aliases.put("LEPC", LEPCHA);
4.4231 + aliases.put("LIMB", LIMBU);
4.4232 + aliases.put("LINB", LINEAR_B);
4.4233 + aliases.put("LISU", LISU);
4.4234 + aliases.put("LYCI", LYCIAN);
4.4235 + aliases.put("LYDI", LYDIAN);
4.4236 + aliases.put("MAND", MANDAIC);
4.4237 + aliases.put("MLYM", MALAYALAM);
4.4238 + aliases.put("MONG", MONGOLIAN);
4.4239 + aliases.put("MTEI", MEETEI_MAYEK);
4.4240 + aliases.put("MYMR", MYANMAR);
4.4241 + aliases.put("NKOO", NKO);
4.4242 + aliases.put("OGAM", OGHAM);
4.4243 + aliases.put("OLCK", OL_CHIKI);
4.4244 + aliases.put("ORKH", OLD_TURKIC);
4.4245 + aliases.put("ORYA", ORIYA);
4.4246 + aliases.put("OSMA", OSMANYA);
4.4247 + aliases.put("PHAG", PHAGS_PA);
4.4248 + aliases.put("PHLI", INSCRIPTIONAL_PAHLAVI);
4.4249 + aliases.put("PHNX", PHOENICIAN);
4.4250 + aliases.put("PRTI", INSCRIPTIONAL_PARTHIAN);
4.4251 + aliases.put("RJNG", REJANG);
4.4252 + aliases.put("RUNR", RUNIC);
4.4253 + aliases.put("SAMR", SAMARITAN);
4.4254 + aliases.put("SARB", OLD_SOUTH_ARABIAN);
4.4255 + aliases.put("SAUR", SAURASHTRA);
4.4256 + aliases.put("SHAW", SHAVIAN);
4.4257 + aliases.put("SINH", SINHALA);
4.4258 + aliases.put("SUND", SUNDANESE);
4.4259 + aliases.put("SYLO", SYLOTI_NAGRI);
4.4260 + aliases.put("SYRC", SYRIAC);
4.4261 + aliases.put("TAGB", TAGBANWA);
4.4262 + aliases.put("TALE", TAI_LE);
4.4263 + aliases.put("TALU", NEW_TAI_LUE);
4.4264 + aliases.put("TAML", TAMIL);
4.4265 + aliases.put("TAVT", TAI_VIET);
4.4266 + aliases.put("TELU", TELUGU);
4.4267 + aliases.put("TFNG", TIFINAGH);
4.4268 + aliases.put("TGLG", TAGALOG);
4.4269 + aliases.put("THAA", THAANA);
4.4270 + aliases.put("THAI", THAI);
4.4271 + aliases.put("TIBT", TIBETAN);
4.4272 + aliases.put("UGAR", UGARITIC);
4.4273 + aliases.put("VAII", VAI);
4.4274 + aliases.put("XPEO", OLD_PERSIAN);
4.4275 + aliases.put("XSUX", CUNEIFORM);
4.4276 + aliases.put("YIII", YI);
4.4277 + aliases.put("ZINH", INHERITED);
4.4278 + aliases.put("ZYYY", COMMON);
4.4279 + aliases.put("ZZZZ", UNKNOWN);
4.4280 + }
4.4281 +
4.4282 + /**
4.4283 + * Returns the enum constant representing the Unicode script of which
4.4284 + * the given character (Unicode code point) is assigned to.
4.4285 + *
4.4286 + * @param codePoint the character (Unicode code point) in question.
4.4287 + * @return The {@code UnicodeScript} constant representing the
4.4288 + * Unicode script of which this character is assigned to.
4.4289 + *
4.4290 + * @exception IllegalArgumentException if the specified
4.4291 + * {@code codePoint} is an invalid Unicode code point.
4.4292 + * @see Character#isValidCodePoint(int)
4.4293 + *
4.4294 + */
4.4295 + public static UnicodeScript of(int codePoint) {
4.4296 + if (!isValidCodePoint(codePoint))
4.4297 + throw new IllegalArgumentException();
4.4298 + int type = getType(codePoint);
4.4299 + // leave SURROGATE and PRIVATE_USE for table lookup
4.4300 + if (type == UNASSIGNED)
4.4301 + return UNKNOWN;
4.4302 + int index = Arrays.binarySearch(scriptStarts, codePoint);
4.4303 + if (index < 0)
4.4304 + index = -index - 2;
4.4305 + return scripts[index];
4.4306 + }
4.4307 +
4.4308 + /**
4.4309 + * Returns the UnicodeScript constant with the given Unicode script
4.4310 + * name or the script name alias. Script names and their aliases are
4.4311 + * determined by The Unicode Standard. The files Scripts<version>.txt
4.4312 + * and PropertyValueAliases<version>.txt define script names
4.4313 + * and the script name aliases for a particular version of the
4.4314 + * standard. The {@link Character} class specifies the version of
4.4315 + * the standard that it supports.
4.4316 + * <p>
4.4317 + * Character case is ignored for all of the valid script names.
4.4318 + * The en_US locale's case mapping rules are used to provide
4.4319 + * case-insensitive string comparisons for script name validation.
4.4320 + * <p>
4.4321 + *
4.4322 + * @param scriptName A {@code UnicodeScript} name.
4.4323 + * @return The {@code UnicodeScript} constant identified
4.4324 + * by {@code scriptName}
4.4325 + * @throws IllegalArgumentException if {@code scriptName} is an
4.4326 + * invalid name
4.4327 + * @throws NullPointerException if {@code scriptName} is null
4.4328 + */
4.4329 + public static final UnicodeScript forName(String scriptName) {
4.4330 + scriptName = scriptName.toUpperCase(Locale.ENGLISH);
4.4331 + //.replace(' ', '_'));
4.4332 + UnicodeScript sc = aliases.get(scriptName);
4.4333 + if (sc != null)
4.4334 + return sc;
4.4335 + return valueOf(scriptName);
4.4336 + }
4.4337 + }
4.4338 +
4.4339 + /**
4.4340 + * The value of the {@code Character}.
4.4341 + *
4.4342 + * @serial
4.4343 + */
4.4344 + private final char value;
4.4345 +
4.4346 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
4.4347 + private static final long serialVersionUID = 3786198910865385080L;
4.4348 +
4.4349 + /**
4.4350 + * Constructs a newly allocated {@code Character} object that
4.4351 + * represents the specified {@code char} value.
4.4352 + *
4.4353 + * @param value the value to be represented by the
4.4354 + * {@code Character} object.
4.4355 + */
4.4356 + public Character(char value) {
4.4357 + this.value = value;
4.4358 + }
4.4359 +
4.4360 + private static class CharacterCache {
4.4361 + private CharacterCache(){}
4.4362 +
4.4363 + static final Character cache[] = new Character[127 + 1];
4.4364 +
4.4365 + static {
4.4366 + for (int i = 0; i < cache.length; i++)
4.4367 + cache[i] = new Character((char)i);
4.4368 + }
4.4369 + }
4.4370 +
4.4371 + /**
4.4372 + * Returns a <tt>Character</tt> instance representing the specified
4.4373 + * <tt>char</tt> value.
4.4374 + * If a new <tt>Character</tt> instance is not required, this method
4.4375 + * should generally be used in preference to the constructor
4.4376 + * {@link #Character(char)}, as this method is likely to yield
4.4377 + * significantly better space and time performance by caching
4.4378 + * frequently requested values.
4.4379 + *
4.4380 + * This method will always cache values in the range {@code
4.4381 + * '\u005Cu0000'} to {@code '\u005Cu007F'}, inclusive, and may
4.4382 + * cache other values outside of this range.
4.4383 + *
4.4384 + * @param c a char value.
4.4385 + * @return a <tt>Character</tt> instance representing <tt>c</tt>.
4.4386 + * @since 1.5
4.4387 + */
4.4388 + public static Character valueOf(char c) {
4.4389 + if (c <= 127) { // must cache
4.4390 + return CharacterCache.cache[(int)c];
4.4391 + }
4.4392 + return new Character(c);
4.4393 + }
4.4394 +
4.4395 + /**
4.4396 + * Returns the value of this {@code Character} object.
4.4397 + * @return the primitive {@code char} value represented by
4.4398 + * this object.
4.4399 + */
4.4400 + public char charValue() {
4.4401 + return value;
4.4402 + }
4.4403 +
4.4404 + /**
4.4405 + * Returns a hash code for this {@code Character}; equal to the result
4.4406 + * of invoking {@code charValue()}.
4.4407 + *
4.4408 + * @return a hash code value for this {@code Character}
4.4409 + */
4.4410 + public int hashCode() {
4.4411 + return (int)value;
4.4412 + }
4.4413 +
4.4414 + /**
4.4415 + * Compares this object against the specified object.
4.4416 + * The result is {@code true} if and only if the argument is not
4.4417 + * {@code null} and is a {@code Character} object that
4.4418 + * represents the same {@code char} value as this object.
4.4419 + *
4.4420 + * @param obj the object to compare with.
4.4421 + * @return {@code true} if the objects are the same;
4.4422 + * {@code false} otherwise.
4.4423 + */
4.4424 + public boolean equals(Object obj) {
4.4425 + if (obj instanceof Character) {
4.4426 + return value == ((Character)obj).charValue();
4.4427 + }
4.4428 + return false;
4.4429 + }
4.4430 +
4.4431 + /**
4.4432 + * Returns a {@code String} object representing this
4.4433 + * {@code Character}'s value. The result is a string of
4.4434 + * length 1 whose sole component is the primitive
4.4435 + * {@code char} value represented by this
4.4436 + * {@code Character} object.
4.4437 + *
4.4438 + * @return a string representation of this object.
4.4439 + */
4.4440 + public String toString() {
4.4441 + char buf[] = {value};
4.4442 + return String.valueOf(buf);
4.4443 + }
4.4444 +
4.4445 + /**
4.4446 + * Returns a {@code String} object representing the
4.4447 + * specified {@code char}. The result is a string of length
4.4448 + * 1 consisting solely of the specified {@code char}.
4.4449 + *
4.4450 + * @param c the {@code char} to be converted
4.4451 + * @return the string representation of the specified {@code char}
4.4452 + * @since 1.4
4.4453 + */
4.4454 + public static String toString(char c) {
4.4455 + return String.valueOf(c);
4.4456 + }
4.4457 +
4.4458 + /**
4.4459 + * Determines whether the specified code point is a valid
4.4460 + * <a href="http://www.unicode.org/glossary/#code_point">
4.4461 + * Unicode code point value</a>.
4.4462 + *
4.4463 + * @param codePoint the Unicode code point to be tested
4.4464 + * @return {@code true} if the specified code point value is between
4.4465 + * {@link #MIN_CODE_POINT} and
4.4466 + * {@link #MAX_CODE_POINT} inclusive;
4.4467 + * {@code false} otherwise.
4.4468 + * @since 1.5
4.4469 + */
4.4470 + public static boolean isValidCodePoint(int codePoint) {
4.4471 + // Optimized form of:
4.4472 + // codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT
4.4473 + int plane = codePoint >>> 16;
4.4474 + return plane < ((MAX_CODE_POINT + 1) >>> 16);
4.4475 + }
4.4476 +
4.4477 + /**
4.4478 + * Determines whether the specified character (Unicode code point)
4.4479 + * is in the <a href="#BMP">Basic Multilingual Plane (BMP)</a>.
4.4480 + * Such code points can be represented using a single {@code char}.
4.4481 + *
4.4482 + * @param codePoint the character (Unicode code point) to be tested
4.4483 + * @return {@code true} if the specified code point is between
4.4484 + * {@link #MIN_VALUE} and {@link #MAX_VALUE} inclusive;
4.4485 + * {@code false} otherwise.
4.4486 + * @since 1.7
4.4487 + */
4.4488 + public static boolean isBmpCodePoint(int codePoint) {
4.4489 + return codePoint >>> 16 == 0;
4.4490 + // Optimized form of:
4.4491 + // codePoint >= MIN_VALUE && codePoint <= MAX_VALUE
4.4492 + // We consistently use logical shift (>>>) to facilitate
4.4493 + // additional runtime optimizations.
4.4494 + }
4.4495 +
4.4496 + /**
4.4497 + * Determines whether the specified character (Unicode code point)
4.4498 + * is in the <a href="#supplementary">supplementary character</a> range.
4.4499 + *
4.4500 + * @param codePoint the character (Unicode code point) to be tested
4.4501 + * @return {@code true} if the specified code point is between
4.4502 + * {@link #MIN_SUPPLEMENTARY_CODE_POINT} and
4.4503 + * {@link #MAX_CODE_POINT} inclusive;
4.4504 + * {@code false} otherwise.
4.4505 + * @since 1.5
4.4506 + */
4.4507 + public static boolean isSupplementaryCodePoint(int codePoint) {
4.4508 + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
4.4509 + && codePoint < MAX_CODE_POINT + 1;
4.4510 + }
4.4511 +
4.4512 + /**
4.4513 + * Determines if the given {@code char} value is a
4.4514 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
4.4515 + * Unicode high-surrogate code unit</a>
4.4516 + * (also known as <i>leading-surrogate code unit</i>).
4.4517 + *
4.4518 + * <p>Such values do not represent characters by themselves,
4.4519 + * but are used in the representation of
4.4520 + * <a href="#supplementary">supplementary characters</a>
4.4521 + * in the UTF-16 encoding.
4.4522 + *
4.4523 + * @param ch the {@code char} value to be tested.
4.4524 + * @return {@code true} if the {@code char} value is between
4.4525 + * {@link #MIN_HIGH_SURROGATE} and
4.4526 + * {@link #MAX_HIGH_SURROGATE} inclusive;
4.4527 + * {@code false} otherwise.
4.4528 + * @see Character#isLowSurrogate(char)
4.4529 + * @see Character.UnicodeBlock#of(int)
4.4530 + * @since 1.5
4.4531 + */
4.4532 + public static boolean isHighSurrogate(char ch) {
4.4533 + // Help VM constant-fold; MAX_HIGH_SURROGATE + 1 == MIN_LOW_SURROGATE
4.4534 + return ch >= MIN_HIGH_SURROGATE && ch < (MAX_HIGH_SURROGATE + 1);
4.4535 + }
4.4536 +
4.4537 + /**
4.4538 + * Determines if the given {@code char} value is a
4.4539 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
4.4540 + * Unicode low-surrogate code unit</a>
4.4541 + * (also known as <i>trailing-surrogate code unit</i>).
4.4542 + *
4.4543 + * <p>Such values do not represent characters by themselves,
4.4544 + * but are used in the representation of
4.4545 + * <a href="#supplementary">supplementary characters</a>
4.4546 + * in the UTF-16 encoding.
4.4547 + *
4.4548 + * @param ch the {@code char} value to be tested.
4.4549 + * @return {@code true} if the {@code char} value is between
4.4550 + * {@link #MIN_LOW_SURROGATE} and
4.4551 + * {@link #MAX_LOW_SURROGATE} inclusive;
4.4552 + * {@code false} otherwise.
4.4553 + * @see Character#isHighSurrogate(char)
4.4554 + * @since 1.5
4.4555 + */
4.4556 + public static boolean isLowSurrogate(char ch) {
4.4557 + return ch >= MIN_LOW_SURROGATE && ch < (MAX_LOW_SURROGATE + 1);
4.4558 + }
4.4559 +
4.4560 + /**
4.4561 + * Determines if the given {@code char} value is a Unicode
4.4562 + * <i>surrogate code unit</i>.
4.4563 + *
4.4564 + * <p>Such values do not represent characters by themselves,
4.4565 + * but are used in the representation of
4.4566 + * <a href="#supplementary">supplementary characters</a>
4.4567 + * in the UTF-16 encoding.
4.4568 + *
4.4569 + * <p>A char value is a surrogate code unit if and only if it is either
4.4570 + * a {@linkplain #isLowSurrogate(char) low-surrogate code unit} or
4.4571 + * a {@linkplain #isHighSurrogate(char) high-surrogate code unit}.
4.4572 + *
4.4573 + * @param ch the {@code char} value to be tested.
4.4574 + * @return {@code true} if the {@code char} value is between
4.4575 + * {@link #MIN_SURROGATE} and
4.4576 + * {@link #MAX_SURROGATE} inclusive;
4.4577 + * {@code false} otherwise.
4.4578 + * @since 1.7
4.4579 + */
4.4580 + public static boolean isSurrogate(char ch) {
4.4581 + return ch >= MIN_SURROGATE && ch < (MAX_SURROGATE + 1);
4.4582 + }
4.4583 +
4.4584 + /**
4.4585 + * Determines whether the specified pair of {@code char}
4.4586 + * values is a valid
4.4587 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
4.4588 + * Unicode surrogate pair</a>.
4.4589 +
4.4590 + * <p>This method is equivalent to the expression:
4.4591 + * <blockquote><pre>
4.4592 + * isHighSurrogate(high) && isLowSurrogate(low)
4.4593 + * </pre></blockquote>
4.4594 + *
4.4595 + * @param high the high-surrogate code value to be tested
4.4596 + * @param low the low-surrogate code value to be tested
4.4597 + * @return {@code true} if the specified high and
4.4598 + * low-surrogate code values represent a valid surrogate pair;
4.4599 + * {@code false} otherwise.
4.4600 + * @since 1.5
4.4601 + */
4.4602 + public static boolean isSurrogatePair(char high, char low) {
4.4603 + return isHighSurrogate(high) && isLowSurrogate(low);
4.4604 + }
4.4605 +
4.4606 + /**
4.4607 + * Determines the number of {@code char} values needed to
4.4608 + * represent the specified character (Unicode code point). If the
4.4609 + * specified character is equal to or greater than 0x10000, then
4.4610 + * the method returns 2. Otherwise, the method returns 1.
4.4611 + *
4.4612 + * <p>This method doesn't validate the specified character to be a
4.4613 + * valid Unicode code point. The caller must validate the
4.4614 + * character value using {@link #isValidCodePoint(int) isValidCodePoint}
4.4615 + * if necessary.
4.4616 + *
4.4617 + * @param codePoint the character (Unicode code point) to be tested.
4.4618 + * @return 2 if the character is a valid supplementary character; 1 otherwise.
4.4619 + * @see Character#isSupplementaryCodePoint(int)
4.4620 + * @since 1.5
4.4621 + */
4.4622 + public static int charCount(int codePoint) {
4.4623 + return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT ? 2 : 1;
4.4624 + }
4.4625 +
4.4626 + /**
4.4627 + * Converts the specified surrogate pair to its supplementary code
4.4628 + * point value. This method does not validate the specified
4.4629 + * surrogate pair. The caller must validate it using {@link
4.4630 + * #isSurrogatePair(char, char) isSurrogatePair} if necessary.
4.4631 + *
4.4632 + * @param high the high-surrogate code unit
4.4633 + * @param low the low-surrogate code unit
4.4634 + * @return the supplementary code point composed from the
4.4635 + * specified surrogate pair.
4.4636 + * @since 1.5
4.4637 + */
4.4638 + public static int toCodePoint(char high, char low) {
4.4639 + // Optimized form of:
4.4640 + // return ((high - MIN_HIGH_SURROGATE) << 10)
4.4641 + // + (low - MIN_LOW_SURROGATE)
4.4642 + // + MIN_SUPPLEMENTARY_CODE_POINT;
4.4643 + return ((high << 10) + low) + (MIN_SUPPLEMENTARY_CODE_POINT
4.4644 + - (MIN_HIGH_SURROGATE << 10)
4.4645 + - MIN_LOW_SURROGATE);
4.4646 + }
4.4647 +
4.4648 + /**
4.4649 + * Returns the code point at the given index of the
4.4650 + * {@code CharSequence}. If the {@code char} value at
4.4651 + * the given index in the {@code CharSequence} is in the
4.4652 + * high-surrogate range, the following index is less than the
4.4653 + * length of the {@code CharSequence}, and the
4.4654 + * {@code char} value at the following index is in the
4.4655 + * low-surrogate range, then the supplementary code point
4.4656 + * corresponding to this surrogate pair is returned. Otherwise,
4.4657 + * the {@code char} value at the given index is returned.
4.4658 + *
4.4659 + * @param seq a sequence of {@code char} values (Unicode code
4.4660 + * units)
4.4661 + * @param index the index to the {@code char} values (Unicode
4.4662 + * code units) in {@code seq} to be converted
4.4663 + * @return the Unicode code point at the given index
4.4664 + * @exception NullPointerException if {@code seq} is null.
4.4665 + * @exception IndexOutOfBoundsException if the value
4.4666 + * {@code index} is negative or not less than
4.4667 + * {@link CharSequence#length() seq.length()}.
4.4668 + * @since 1.5
4.4669 + */
4.4670 + public static int codePointAt(CharSequence seq, int index) {
4.4671 + char c1 = seq.charAt(index++);
4.4672 + if (isHighSurrogate(c1)) {
4.4673 + if (index < seq.length()) {
4.4674 + char c2 = seq.charAt(index);
4.4675 + if (isLowSurrogate(c2)) {
4.4676 + return toCodePoint(c1, c2);
4.4677 + }
4.4678 + }
4.4679 + }
4.4680 + return c1;
4.4681 + }
4.4682 +
4.4683 + /**
4.4684 + * Returns the code point at the given index of the
4.4685 + * {@code char} array. If the {@code char} value at
4.4686 + * the given index in the {@code char} array is in the
4.4687 + * high-surrogate range, the following index is less than the
4.4688 + * length of the {@code char} array, and the
4.4689 + * {@code char} value at the following index is in the
4.4690 + * low-surrogate range, then the supplementary code point
4.4691 + * corresponding to this surrogate pair is returned. Otherwise,
4.4692 + * the {@code char} value at the given index is returned.
4.4693 + *
4.4694 + * @param a the {@code char} array
4.4695 + * @param index the index to the {@code char} values (Unicode
4.4696 + * code units) in the {@code char} array to be converted
4.4697 + * @return the Unicode code point at the given index
4.4698 + * @exception NullPointerException if {@code a} is null.
4.4699 + * @exception IndexOutOfBoundsException if the value
4.4700 + * {@code index} is negative or not less than
4.4701 + * the length of the {@code char} array.
4.4702 + * @since 1.5
4.4703 + */
4.4704 + public static int codePointAt(char[] a, int index) {
4.4705 + return codePointAtImpl(a, index, a.length);
4.4706 + }
4.4707 +
4.4708 + /**
4.4709 + * Returns the code point at the given index of the
4.4710 + * {@code char} array, where only array elements with
4.4711 + * {@code index} less than {@code limit} can be used. If
4.4712 + * the {@code char} value at the given index in the
4.4713 + * {@code char} array is in the high-surrogate range, the
4.4714 + * following index is less than the {@code limit}, and the
4.4715 + * {@code char} value at the following index is in the
4.4716 + * low-surrogate range, then the supplementary code point
4.4717 + * corresponding to this surrogate pair is returned. Otherwise,
4.4718 + * the {@code char} value at the given index is returned.
4.4719 + *
4.4720 + * @param a the {@code char} array
4.4721 + * @param index the index to the {@code char} values (Unicode
4.4722 + * code units) in the {@code char} array to be converted
4.4723 + * @param limit the index after the last array element that
4.4724 + * can be used in the {@code char} array
4.4725 + * @return the Unicode code point at the given index
4.4726 + * @exception NullPointerException if {@code a} is null.
4.4727 + * @exception IndexOutOfBoundsException if the {@code index}
4.4728 + * argument is negative or not less than the {@code limit}
4.4729 + * argument, or if the {@code limit} argument is negative or
4.4730 + * greater than the length of the {@code char} array.
4.4731 + * @since 1.5
4.4732 + */
4.4733 + public static int codePointAt(char[] a, int index, int limit) {
4.4734 + if (index >= limit || limit < 0 || limit > a.length) {
4.4735 + throw new IndexOutOfBoundsException();
4.4736 + }
4.4737 + return codePointAtImpl(a, index, limit);
4.4738 + }
4.4739 +
4.4740 + // throws ArrayIndexOutofBoundsException if index out of bounds
4.4741 + static int codePointAtImpl(char[] a, int index, int limit) {
4.4742 + char c1 = a[index++];
4.4743 + if (isHighSurrogate(c1)) {
4.4744 + if (index < limit) {
4.4745 + char c2 = a[index];
4.4746 + if (isLowSurrogate(c2)) {
4.4747 + return toCodePoint(c1, c2);
4.4748 + }
4.4749 + }
4.4750 + }
4.4751 + return c1;
4.4752 + }
4.4753 +
4.4754 + /**
4.4755 + * Returns the code point preceding the given index of the
4.4756 + * {@code CharSequence}. If the {@code char} value at
4.4757 + * {@code (index - 1)} in the {@code CharSequence} is in
4.4758 + * the low-surrogate range, {@code (index - 2)} is not
4.4759 + * negative, and the {@code char} value at {@code (index - 2)}
4.4760 + * in the {@code CharSequence} is in the
4.4761 + * high-surrogate range, then the supplementary code point
4.4762 + * corresponding to this surrogate pair is returned. Otherwise,
4.4763 + * the {@code char} value at {@code (index - 1)} is
4.4764 + * returned.
4.4765 + *
4.4766 + * @param seq the {@code CharSequence} instance
4.4767 + * @param index the index following the code point that should be returned
4.4768 + * @return the Unicode code point value before the given index.
4.4769 + * @exception NullPointerException if {@code seq} is null.
4.4770 + * @exception IndexOutOfBoundsException if the {@code index}
4.4771 + * argument is less than 1 or greater than {@link
4.4772 + * CharSequence#length() seq.length()}.
4.4773 + * @since 1.5
4.4774 + */
4.4775 + public static int codePointBefore(CharSequence seq, int index) {
4.4776 + char c2 = seq.charAt(--index);
4.4777 + if (isLowSurrogate(c2)) {
4.4778 + if (index > 0) {
4.4779 + char c1 = seq.charAt(--index);
4.4780 + if (isHighSurrogate(c1)) {
4.4781 + return toCodePoint(c1, c2);
4.4782 + }
4.4783 + }
4.4784 + }
4.4785 + return c2;
4.4786 + }
4.4787 +
4.4788 + /**
4.4789 + * Returns the code point preceding the given index of the
4.4790 + * {@code char} array. If the {@code char} value at
4.4791 + * {@code (index - 1)} in the {@code char} array is in
4.4792 + * the low-surrogate range, {@code (index - 2)} is not
4.4793 + * negative, and the {@code char} value at {@code (index - 2)}
4.4794 + * in the {@code char} array is in the
4.4795 + * high-surrogate range, then the supplementary code point
4.4796 + * corresponding to this surrogate pair is returned. Otherwise,
4.4797 + * the {@code char} value at {@code (index - 1)} is
4.4798 + * returned.
4.4799 + *
4.4800 + * @param a the {@code char} array
4.4801 + * @param index the index following the code point that should be returned
4.4802 + * @return the Unicode code point value before the given index.
4.4803 + * @exception NullPointerException if {@code a} is null.
4.4804 + * @exception IndexOutOfBoundsException if the {@code index}
4.4805 + * argument is less than 1 or greater than the length of the
4.4806 + * {@code char} array
4.4807 + * @since 1.5
4.4808 + */
4.4809 + public static int codePointBefore(char[] a, int index) {
4.4810 + return codePointBeforeImpl(a, index, 0);
4.4811 + }
4.4812 +
4.4813 + /**
4.4814 + * Returns the code point preceding the given index of the
4.4815 + * {@code char} array, where only array elements with
4.4816 + * {@code index} greater than or equal to {@code start}
4.4817 + * can be used. If the {@code char} value at {@code (index - 1)}
4.4818 + * in the {@code char} array is in the
4.4819 + * low-surrogate range, {@code (index - 2)} is not less than
4.4820 + * {@code start}, and the {@code char} value at
4.4821 + * {@code (index - 2)} in the {@code char} array is in
4.4822 + * the high-surrogate range, then the supplementary code point
4.4823 + * corresponding to this surrogate pair is returned. Otherwise,
4.4824 + * the {@code char} value at {@code (index - 1)} is
4.4825 + * returned.
4.4826 + *
4.4827 + * @param a the {@code char} array
4.4828 + * @param index the index following the code point that should be returned
4.4829 + * @param start the index of the first array element in the
4.4830 + * {@code char} array
4.4831 + * @return the Unicode code point value before the given index.
4.4832 + * @exception NullPointerException if {@code a} is null.
4.4833 + * @exception IndexOutOfBoundsException if the {@code index}
4.4834 + * argument is not greater than the {@code start} argument or
4.4835 + * is greater than the length of the {@code char} array, or
4.4836 + * if the {@code start} argument is negative or not less than
4.4837 + * the length of the {@code char} array.
4.4838 + * @since 1.5
4.4839 + */
4.4840 + public static int codePointBefore(char[] a, int index, int start) {
4.4841 + if (index <= start || start < 0 || start >= a.length) {
4.4842 + throw new IndexOutOfBoundsException();
4.4843 + }
4.4844 + return codePointBeforeImpl(a, index, start);
4.4845 + }
4.4846 +
4.4847 + // throws ArrayIndexOutofBoundsException if index-1 out of bounds
4.4848 + static int codePointBeforeImpl(char[] a, int index, int start) {
4.4849 + char c2 = a[--index];
4.4850 + if (isLowSurrogate(c2)) {
4.4851 + if (index > start) {
4.4852 + char c1 = a[--index];
4.4853 + if (isHighSurrogate(c1)) {
4.4854 + return toCodePoint(c1, c2);
4.4855 + }
4.4856 + }
4.4857 + }
4.4858 + return c2;
4.4859 + }
4.4860 +
4.4861 + /**
4.4862 + * Returns the leading surrogate (a
4.4863 + * <a href="http://www.unicode.org/glossary/#high_surrogate_code_unit">
4.4864 + * high surrogate code unit</a>) of the
4.4865 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
4.4866 + * surrogate pair</a>
4.4867 + * representing the specified supplementary character (Unicode
4.4868 + * code point) in the UTF-16 encoding. If the specified character
4.4869 + * is not a
4.4870 + * <a href="Character.html#supplementary">supplementary character</a>,
4.4871 + * an unspecified {@code char} is returned.
4.4872 + *
4.4873 + * <p>If
4.4874 + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)}
4.4875 + * is {@code true}, then
4.4876 + * {@link #isHighSurrogate isHighSurrogate}{@code (highSurrogate(x))} and
4.4877 + * {@link #toCodePoint toCodePoint}{@code (highSurrogate(x), }{@link #lowSurrogate lowSurrogate}{@code (x)) == x}
4.4878 + * are also always {@code true}.
4.4879 + *
4.4880 + * @param codePoint a supplementary character (Unicode code point)
4.4881 + * @return the leading surrogate code unit used to represent the
4.4882 + * character in the UTF-16 encoding
4.4883 + * @since 1.7
4.4884 + */
4.4885 + public static char highSurrogate(int codePoint) {
4.4886 + return (char) ((codePoint >>> 10)
4.4887 + + (MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10)));
4.4888 + }
4.4889 +
4.4890 + /**
4.4891 + * Returns the trailing surrogate (a
4.4892 + * <a href="http://www.unicode.org/glossary/#low_surrogate_code_unit">
4.4893 + * low surrogate code unit</a>) of the
4.4894 + * <a href="http://www.unicode.org/glossary/#surrogate_pair">
4.4895 + * surrogate pair</a>
4.4896 + * representing the specified supplementary character (Unicode
4.4897 + * code point) in the UTF-16 encoding. If the specified character
4.4898 + * is not a
4.4899 + * <a href="Character.html#supplementary">supplementary character</a>,
4.4900 + * an unspecified {@code char} is returned.
4.4901 + *
4.4902 + * <p>If
4.4903 + * {@link #isSupplementaryCodePoint isSupplementaryCodePoint(x)}
4.4904 + * is {@code true}, then
4.4905 + * {@link #isLowSurrogate isLowSurrogate}{@code (lowSurrogate(x))} and
4.4906 + * {@link #toCodePoint toCodePoint}{@code (}{@link #highSurrogate highSurrogate}{@code (x), lowSurrogate(x)) == x}
4.4907 + * are also always {@code true}.
4.4908 + *
4.4909 + * @param codePoint a supplementary character (Unicode code point)
4.4910 + * @return the trailing surrogate code unit used to represent the
4.4911 + * character in the UTF-16 encoding
4.4912 + * @since 1.7
4.4913 + */
4.4914 + public static char lowSurrogate(int codePoint) {
4.4915 + return (char) ((codePoint & 0x3ff) + MIN_LOW_SURROGATE);
4.4916 + }
4.4917 +
4.4918 + /**
4.4919 + * Converts the specified character (Unicode code point) to its
4.4920 + * UTF-16 representation. If the specified code point is a BMP
4.4921 + * (Basic Multilingual Plane or Plane 0) value, the same value is
4.4922 + * stored in {@code dst[dstIndex]}, and 1 is returned. If the
4.4923 + * specified code point is a supplementary character, its
4.4924 + * surrogate values are stored in {@code dst[dstIndex]}
4.4925 + * (high-surrogate) and {@code dst[dstIndex+1]}
4.4926 + * (low-surrogate), and 2 is returned.
4.4927 + *
4.4928 + * @param codePoint the character (Unicode code point) to be converted.
4.4929 + * @param dst an array of {@code char} in which the
4.4930 + * {@code codePoint}'s UTF-16 value is stored.
4.4931 + * @param dstIndex the start index into the {@code dst}
4.4932 + * array where the converted value is stored.
4.4933 + * @return 1 if the code point is a BMP code point, 2 if the
4.4934 + * code point is a supplementary code point.
4.4935 + * @exception IllegalArgumentException if the specified
4.4936 + * {@code codePoint} is not a valid Unicode code point.
4.4937 + * @exception NullPointerException if the specified {@code dst} is null.
4.4938 + * @exception IndexOutOfBoundsException if {@code dstIndex}
4.4939 + * is negative or not less than {@code dst.length}, or if
4.4940 + * {@code dst} at {@code dstIndex} doesn't have enough
4.4941 + * array element(s) to store the resulting {@code char}
4.4942 + * value(s). (If {@code dstIndex} is equal to
4.4943 + * {@code dst.length-1} and the specified
4.4944 + * {@code codePoint} is a supplementary character, the
4.4945 + * high-surrogate value is not stored in
4.4946 + * {@code dst[dstIndex]}.)
4.4947 + * @since 1.5
4.4948 + */
4.4949 + public static int toChars(int codePoint, char[] dst, int dstIndex) {
4.4950 + if (isBmpCodePoint(codePoint)) {
4.4951 + dst[dstIndex] = (char) codePoint;
4.4952 + return 1;
4.4953 + } else if (isValidCodePoint(codePoint)) {
4.4954 + toSurrogates(codePoint, dst, dstIndex);
4.4955 + return 2;
4.4956 + } else {
4.4957 + throw new IllegalArgumentException();
4.4958 + }
4.4959 + }
4.4960 +
4.4961 + /**
4.4962 + * Converts the specified character (Unicode code point) to its
4.4963 + * UTF-16 representation stored in a {@code char} array. If
4.4964 + * the specified code point is a BMP (Basic Multilingual Plane or
4.4965 + * Plane 0) value, the resulting {@code char} array has
4.4966 + * the same value as {@code codePoint}. If the specified code
4.4967 + * point is a supplementary code point, the resulting
4.4968 + * {@code char} array has the corresponding surrogate pair.
4.4969 + *
4.4970 + * @param codePoint a Unicode code point
4.4971 + * @return a {@code char} array having
4.4972 + * {@code codePoint}'s UTF-16 representation.
4.4973 + * @exception IllegalArgumentException if the specified
4.4974 + * {@code codePoint} is not a valid Unicode code point.
4.4975 + * @since 1.5
4.4976 + */
4.4977 + public static char[] toChars(int codePoint) {
4.4978 + if (isBmpCodePoint(codePoint)) {
4.4979 + return new char[] { (char) codePoint };
4.4980 + } else if (isValidCodePoint(codePoint)) {
4.4981 + char[] result = new char[2];
4.4982 + toSurrogates(codePoint, result, 0);
4.4983 + return result;
4.4984 + } else {
4.4985 + throw new IllegalArgumentException();
4.4986 + }
4.4987 + }
4.4988 +
4.4989 + static void toSurrogates(int codePoint, char[] dst, int index) {
4.4990 + // We write elements "backwards" to guarantee all-or-nothing
4.4991 + dst[index+1] = lowSurrogate(codePoint);
4.4992 + dst[index] = highSurrogate(codePoint);
4.4993 + }
4.4994 +
4.4995 + /**
4.4996 + * Returns the number of Unicode code points in the text range of
4.4997 + * the specified char sequence. The text range begins at the
4.4998 + * specified {@code beginIndex} and extends to the
4.4999 + * {@code char} at index {@code endIndex - 1}. Thus the
4.5000 + * length (in {@code char}s) of the text range is
4.5001 + * {@code endIndex-beginIndex}. Unpaired surrogates within
4.5002 + * the text range count as one code point each.
4.5003 + *
4.5004 + * @param seq the char sequence
4.5005 + * @param beginIndex the index to the first {@code char} of
4.5006 + * the text range.
4.5007 + * @param endIndex the index after the last {@code char} of
4.5008 + * the text range.
4.5009 + * @return the number of Unicode code points in the specified text
4.5010 + * range
4.5011 + * @exception NullPointerException if {@code seq} is null.
4.5012 + * @exception IndexOutOfBoundsException if the
4.5013 + * {@code beginIndex} is negative, or {@code endIndex}
4.5014 + * is larger than the length of the given sequence, or
4.5015 + * {@code beginIndex} is larger than {@code endIndex}.
4.5016 + * @since 1.5
4.5017 + */
4.5018 + public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) {
4.5019 + int length = seq.length();
4.5020 + if (beginIndex < 0 || endIndex > length || beginIndex > endIndex) {
4.5021 + throw new IndexOutOfBoundsException();
4.5022 + }
4.5023 + int n = endIndex - beginIndex;
4.5024 + for (int i = beginIndex; i < endIndex; ) {
4.5025 + if (isHighSurrogate(seq.charAt(i++)) && i < endIndex &&
4.5026 + isLowSurrogate(seq.charAt(i))) {
4.5027 + n--;
4.5028 + i++;
4.5029 + }
4.5030 + }
4.5031 + return n;
4.5032 + }
4.5033 +
4.5034 + /**
4.5035 + * Returns the number of Unicode code points in a subarray of the
4.5036 + * {@code char} array argument. The {@code offset}
4.5037 + * argument is the index of the first {@code char} of the
4.5038 + * subarray and the {@code count} argument specifies the
4.5039 + * length of the subarray in {@code char}s. Unpaired
4.5040 + * surrogates within the subarray count as one code point each.
4.5041 + *
4.5042 + * @param a the {@code char} array
4.5043 + * @param offset the index of the first {@code char} in the
4.5044 + * given {@code char} array
4.5045 + * @param count the length of the subarray in {@code char}s
4.5046 + * @return the number of Unicode code points in the specified subarray
4.5047 + * @exception NullPointerException if {@code a} is null.
4.5048 + * @exception IndexOutOfBoundsException if {@code offset} or
4.5049 + * {@code count} is negative, or if {@code offset +
4.5050 + * count} is larger than the length of the given array.
4.5051 + * @since 1.5
4.5052 + */
4.5053 + public static int codePointCount(char[] a, int offset, int count) {
4.5054 + if (count > a.length - offset || offset < 0 || count < 0) {
4.5055 + throw new IndexOutOfBoundsException();
4.5056 + }
4.5057 + return codePointCountImpl(a, offset, count);
4.5058 + }
4.5059 +
4.5060 + static int codePointCountImpl(char[] a, int offset, int count) {
4.5061 + int endIndex = offset + count;
4.5062 + int n = count;
4.5063 + for (int i = offset; i < endIndex; ) {
4.5064 + if (isHighSurrogate(a[i++]) && i < endIndex &&
4.5065 + isLowSurrogate(a[i])) {
4.5066 + n--;
4.5067 + i++;
4.5068 + }
4.5069 + }
4.5070 + return n;
4.5071 + }
4.5072 +
4.5073 + /**
4.5074 + * Returns the index within the given char sequence that is offset
4.5075 + * from the given {@code index} by {@code codePointOffset}
4.5076 + * code points. Unpaired surrogates within the text range given by
4.5077 + * {@code index} and {@code codePointOffset} count as
4.5078 + * one code point each.
4.5079 + *
4.5080 + * @param seq the char sequence
4.5081 + * @param index the index to be offset
4.5082 + * @param codePointOffset the offset in code points
4.5083 + * @return the index within the char sequence
4.5084 + * @exception NullPointerException if {@code seq} is null.
4.5085 + * @exception IndexOutOfBoundsException if {@code index}
4.5086 + * is negative or larger then the length of the char sequence,
4.5087 + * or if {@code codePointOffset} is positive and the
4.5088 + * subsequence starting with {@code index} has fewer than
4.5089 + * {@code codePointOffset} code points, or if
4.5090 + * {@code codePointOffset} is negative and the subsequence
4.5091 + * before {@code index} has fewer than the absolute value
4.5092 + * of {@code codePointOffset} code points.
4.5093 + * @since 1.5
4.5094 + */
4.5095 + public static int offsetByCodePoints(CharSequence seq, int index,
4.5096 + int codePointOffset) {
4.5097 + int length = seq.length();
4.5098 + if (index < 0 || index > length) {
4.5099 + throw new IndexOutOfBoundsException();
4.5100 + }
4.5101 +
4.5102 + int x = index;
4.5103 + if (codePointOffset >= 0) {
4.5104 + int i;
4.5105 + for (i = 0; x < length && i < codePointOffset; i++) {
4.5106 + if (isHighSurrogate(seq.charAt(x++)) && x < length &&
4.5107 + isLowSurrogate(seq.charAt(x))) {
4.5108 + x++;
4.5109 + }
4.5110 + }
4.5111 + if (i < codePointOffset) {
4.5112 + throw new IndexOutOfBoundsException();
4.5113 + }
4.5114 + } else {
4.5115 + int i;
4.5116 + for (i = codePointOffset; x > 0 && i < 0; i++) {
4.5117 + if (isLowSurrogate(seq.charAt(--x)) && x > 0 &&
4.5118 + isHighSurrogate(seq.charAt(x-1))) {
4.5119 + x--;
4.5120 + }
4.5121 + }
4.5122 + if (i < 0) {
4.5123 + throw new IndexOutOfBoundsException();
4.5124 + }
4.5125 + }
4.5126 + return x;
4.5127 + }
4.5128 +
4.5129 + /**
4.5130 + * Returns the index within the given {@code char} subarray
4.5131 + * that is offset from the given {@code index} by
4.5132 + * {@code codePointOffset} code points. The
4.5133 + * {@code start} and {@code count} arguments specify a
4.5134 + * subarray of the {@code char} array. Unpaired surrogates
4.5135 + * within the text range given by {@code index} and
4.5136 + * {@code codePointOffset} count as one code point each.
4.5137 + *
4.5138 + * @param a the {@code char} array
4.5139 + * @param start the index of the first {@code char} of the
4.5140 + * subarray
4.5141 + * @param count the length of the subarray in {@code char}s
4.5142 + * @param index the index to be offset
4.5143 + * @param codePointOffset the offset in code points
4.5144 + * @return the index within the subarray
4.5145 + * @exception NullPointerException if {@code a} is null.
4.5146 + * @exception IndexOutOfBoundsException
4.5147 + * if {@code start} or {@code count} is negative,
4.5148 + * or if {@code start + count} is larger than the length of
4.5149 + * the given array,
4.5150 + * or if {@code index} is less than {@code start} or
4.5151 + * larger then {@code start + count},
4.5152 + * or if {@code codePointOffset} is positive and the text range
4.5153 + * starting with {@code index} and ending with {@code start + count - 1}
4.5154 + * has fewer than {@code codePointOffset} code
4.5155 + * points,
4.5156 + * or if {@code codePointOffset} is negative and the text range
4.5157 + * starting with {@code start} and ending with {@code index - 1}
4.5158 + * has fewer than the absolute value of
4.5159 + * {@code codePointOffset} code points.
4.5160 + * @since 1.5
4.5161 + */
4.5162 + public static int offsetByCodePoints(char[] a, int start, int count,
4.5163 + int index, int codePointOffset) {
4.5164 + if (count > a.length-start || start < 0 || count < 0
4.5165 + || index < start || index > start+count) {
4.5166 + throw new IndexOutOfBoundsException();
4.5167 + }
4.5168 + return offsetByCodePointsImpl(a, start, count, index, codePointOffset);
4.5169 + }
4.5170 +
4.5171 + static int offsetByCodePointsImpl(char[]a, int start, int count,
4.5172 + int index, int codePointOffset) {
4.5173 + int x = index;
4.5174 + if (codePointOffset >= 0) {
4.5175 + int limit = start + count;
4.5176 + int i;
4.5177 + for (i = 0; x < limit && i < codePointOffset; i++) {
4.5178 + if (isHighSurrogate(a[x++]) && x < limit &&
4.5179 + isLowSurrogate(a[x])) {
4.5180 + x++;
4.5181 + }
4.5182 + }
4.5183 + if (i < codePointOffset) {
4.5184 + throw new IndexOutOfBoundsException();
4.5185 + }
4.5186 + } else {
4.5187 + int i;
4.5188 + for (i = codePointOffset; x > start && i < 0; i++) {
4.5189 + if (isLowSurrogate(a[--x]) && x > start &&
4.5190 + isHighSurrogate(a[x-1])) {
4.5191 + x--;
4.5192 + }
4.5193 + }
4.5194 + if (i < 0) {
4.5195 + throw new IndexOutOfBoundsException();
4.5196 + }
4.5197 + }
4.5198 + return x;
4.5199 + }
4.5200 +
4.5201 + /**
4.5202 + * Determines if the specified character is a lowercase character.
4.5203 + * <p>
4.5204 + * A character is lowercase if its general category type, provided
4.5205 + * by {@code Character.getType(ch)}, is
4.5206 + * {@code LOWERCASE_LETTER}, or it has contributory property
4.5207 + * Other_Lowercase as defined by the Unicode Standard.
4.5208 + * <p>
4.5209 + * The following are examples of lowercase characters:
4.5210 + * <p><blockquote><pre>
4.5211 + * a b c d e f g h i j k l m n o p q r s t u v w x y z
4.5212 + * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
4.5213 + * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
4.5214 + * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
4.5215 + * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
4.5216 + * </pre></blockquote>
4.5217 + * <p> Many other Unicode characters are lowercase too.
4.5218 + *
4.5219 + * <p><b>Note:</b> This method cannot handle <a
4.5220 + * href="#supplementary"> supplementary characters</a>. To support
4.5221 + * all Unicode characters, including supplementary characters, use
4.5222 + * the {@link #isLowerCase(int)} method.
4.5223 + *
4.5224 + * @param ch the character to be tested.
4.5225 + * @return {@code true} if the character is lowercase;
4.5226 + * {@code false} otherwise.
4.5227 + * @see Character#isLowerCase(char)
4.5228 + * @see Character#isTitleCase(char)
4.5229 + * @see Character#toLowerCase(char)
4.5230 + * @see Character#getType(char)
4.5231 + */
4.5232 + public static boolean isLowerCase(char ch) {
4.5233 + return isLowerCase((int)ch);
4.5234 + }
4.5235 +
4.5236 + /**
4.5237 + * Determines if the specified character (Unicode code point) is a
4.5238 + * lowercase character.
4.5239 + * <p>
4.5240 + * A character is lowercase if its general category type, provided
4.5241 + * by {@link Character#getType getType(codePoint)}, is
4.5242 + * {@code LOWERCASE_LETTER}, or it has contributory property
4.5243 + * Other_Lowercase as defined by the Unicode Standard.
4.5244 + * <p>
4.5245 + * The following are examples of lowercase characters:
4.5246 + * <p><blockquote><pre>
4.5247 + * a b c d e f g h i j k l m n o p q r s t u v w x y z
4.5248 + * '\u00DF' '\u00E0' '\u00E1' '\u00E2' '\u00E3' '\u00E4' '\u00E5' '\u00E6'
4.5249 + * '\u00E7' '\u00E8' '\u00E9' '\u00EA' '\u00EB' '\u00EC' '\u00ED' '\u00EE'
4.5250 + * '\u00EF' '\u00F0' '\u00F1' '\u00F2' '\u00F3' '\u00F4' '\u00F5' '\u00F6'
4.5251 + * '\u00F8' '\u00F9' '\u00FA' '\u00FB' '\u00FC' '\u00FD' '\u00FE' '\u00FF'
4.5252 + * </pre></blockquote>
4.5253 + * <p> Many other Unicode characters are lowercase too.
4.5254 + *
4.5255 + * @param codePoint the character (Unicode code point) to be tested.
4.5256 + * @return {@code true} if the character is lowercase;
4.5257 + * {@code false} otherwise.
4.5258 + * @see Character#isLowerCase(int)
4.5259 + * @see Character#isTitleCase(int)
4.5260 + * @see Character#toLowerCase(int)
4.5261 + * @see Character#getType(int)
4.5262 + * @since 1.5
4.5263 + */
4.5264 + public static boolean isLowerCase(int codePoint) {
4.5265 + return getType(codePoint) == Character.LOWERCASE_LETTER ||
4.5266 + CharacterData.of(codePoint).isOtherLowercase(codePoint);
4.5267 + }
4.5268 +
4.5269 + /**
4.5270 + * Determines if the specified character is an uppercase character.
4.5271 + * <p>
4.5272 + * A character is uppercase if its general category type, provided by
4.5273 + * {@code Character.getType(ch)}, is {@code UPPERCASE_LETTER}.
4.5274 + * or it has contributory property Other_Uppercase as defined by the Unicode Standard.
4.5275 + * <p>
4.5276 + * The following are examples of uppercase characters:
4.5277 + * <p><blockquote><pre>
4.5278 + * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
4.5279 + * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
4.5280 + * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
4.5281 + * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
4.5282 + * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
4.5283 + * </pre></blockquote>
4.5284 + * <p> Many other Unicode characters are uppercase too.<p>
4.5285 + *
4.5286 + * <p><b>Note:</b> This method cannot handle <a
4.5287 + * href="#supplementary"> supplementary characters</a>. To support
4.5288 + * all Unicode characters, including supplementary characters, use
4.5289 + * the {@link #isUpperCase(int)} method.
4.5290 + *
4.5291 + * @param ch the character to be tested.
4.5292 + * @return {@code true} if the character is uppercase;
4.5293 + * {@code false} otherwise.
4.5294 + * @see Character#isLowerCase(char)
4.5295 + * @see Character#isTitleCase(char)
4.5296 + * @see Character#toUpperCase(char)
4.5297 + * @see Character#getType(char)
4.5298 + * @since 1.0
4.5299 + */
4.5300 + public static boolean isUpperCase(char ch) {
4.5301 + return isUpperCase((int)ch);
4.5302 + }
4.5303 +
4.5304 + /**
4.5305 + * Determines if the specified character (Unicode code point) is an uppercase character.
4.5306 + * <p>
4.5307 + * A character is uppercase if its general category type, provided by
4.5308 + * {@link Character#getType(int) getType(codePoint)}, is {@code UPPERCASE_LETTER},
4.5309 + * or it has contributory property Other_Uppercase as defined by the Unicode Standard.
4.5310 + * <p>
4.5311 + * The following are examples of uppercase characters:
4.5312 + * <p><blockquote><pre>
4.5313 + * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
4.5314 + * '\u00C0' '\u00C1' '\u00C2' '\u00C3' '\u00C4' '\u00C5' '\u00C6' '\u00C7'
4.5315 + * '\u00C8' '\u00C9' '\u00CA' '\u00CB' '\u00CC' '\u00CD' '\u00CE' '\u00CF'
4.5316 + * '\u00D0' '\u00D1' '\u00D2' '\u00D3' '\u00D4' '\u00D5' '\u00D6' '\u00D8'
4.5317 + * '\u00D9' '\u00DA' '\u00DB' '\u00DC' '\u00DD' '\u00DE'
4.5318 + * </pre></blockquote>
4.5319 + * <p> Many other Unicode characters are uppercase too.<p>
4.5320 + *
4.5321 + * @param codePoint the character (Unicode code point) to be tested.
4.5322 + * @return {@code true} if the character is uppercase;
4.5323 + * {@code false} otherwise.
4.5324 + * @see Character#isLowerCase(int)
4.5325 + * @see Character#isTitleCase(int)
4.5326 + * @see Character#toUpperCase(int)
4.5327 + * @see Character#getType(int)
4.5328 + * @since 1.5
4.5329 + */
4.5330 + public static boolean isUpperCase(int codePoint) {
4.5331 + return getType(codePoint) == Character.UPPERCASE_LETTER ||
4.5332 + CharacterData.of(codePoint).isOtherUppercase(codePoint);
4.5333 + }
4.5334 +
4.5335 + /**
4.5336 + * Determines if the specified character is a titlecase character.
4.5337 + * <p>
4.5338 + * A character is a titlecase character if its general
4.5339 + * category type, provided by {@code Character.getType(ch)},
4.5340 + * is {@code TITLECASE_LETTER}.
4.5341 + * <p>
4.5342 + * Some characters look like pairs of Latin letters. For example, there
4.5343 + * is an uppercase letter that looks like "LJ" and has a corresponding
4.5344 + * lowercase letter that looks like "lj". A third form, which looks like "Lj",
4.5345 + * is the appropriate form to use when rendering a word in lowercase
4.5346 + * with initial capitals, as for a book title.
4.5347 + * <p>
4.5348 + * These are some of the Unicode characters for which this method returns
4.5349 + * {@code true}:
4.5350 + * <ul>
4.5351 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}
4.5352 + * <li>{@code LATIN CAPITAL LETTER L WITH SMALL LETTER J}
4.5353 + * <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
4.5354 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
4.5355 + * </ul>
4.5356 + * <p> Many other Unicode characters are titlecase too.<p>
4.5357 + *
4.5358 + * <p><b>Note:</b> This method cannot handle <a
4.5359 + * href="#supplementary"> supplementary characters</a>. To support
4.5360 + * all Unicode characters, including supplementary characters, use
4.5361 + * the {@link #isTitleCase(int)} method.
4.5362 + *
4.5363 + * @param ch the character to be tested.
4.5364 + * @return {@code true} if the character is titlecase;
4.5365 + * {@code false} otherwise.
4.5366 + * @see Character#isLowerCase(char)
4.5367 + * @see Character#isUpperCase(char)
4.5368 + * @see Character#toTitleCase(char)
4.5369 + * @see Character#getType(char)
4.5370 + * @since 1.0.2
4.5371 + */
4.5372 + public static boolean isTitleCase(char ch) {
4.5373 + return isTitleCase((int)ch);
4.5374 + }
4.5375 +
4.5376 + /**
4.5377 + * Determines if the specified character (Unicode code point) is a titlecase character.
4.5378 + * <p>
4.5379 + * A character is a titlecase character if its general
4.5380 + * category type, provided by {@link Character#getType(int) getType(codePoint)},
4.5381 + * is {@code TITLECASE_LETTER}.
4.5382 + * <p>
4.5383 + * Some characters look like pairs of Latin letters. For example, there
4.5384 + * is an uppercase letter that looks like "LJ" and has a corresponding
4.5385 + * lowercase letter that looks like "lj". A third form, which looks like "Lj",
4.5386 + * is the appropriate form to use when rendering a word in lowercase
4.5387 + * with initial capitals, as for a book title.
4.5388 + * <p>
4.5389 + * These are some of the Unicode characters for which this method returns
4.5390 + * {@code true}:
4.5391 + * <ul>
4.5392 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON}
4.5393 + * <li>{@code LATIN CAPITAL LETTER L WITH SMALL LETTER J}
4.5394 + * <li>{@code LATIN CAPITAL LETTER N WITH SMALL LETTER J}
4.5395 + * <li>{@code LATIN CAPITAL LETTER D WITH SMALL LETTER Z}
4.5396 + * </ul>
4.5397 + * <p> Many other Unicode characters are titlecase too.<p>
4.5398 + *
4.5399 + * @param codePoint the character (Unicode code point) to be tested.
4.5400 + * @return {@code true} if the character is titlecase;
4.5401 + * {@code false} otherwise.
4.5402 + * @see Character#isLowerCase(int)
4.5403 + * @see Character#isUpperCase(int)
4.5404 + * @see Character#toTitleCase(int)
4.5405 + * @see Character#getType(int)
4.5406 + * @since 1.5
4.5407 + */
4.5408 + public static boolean isTitleCase(int codePoint) {
4.5409 + return getType(codePoint) == Character.TITLECASE_LETTER;
4.5410 + }
4.5411 +
4.5412 + /**
4.5413 + * Determines if the specified character is a digit.
4.5414 + * <p>
4.5415 + * A character is a digit if its general category type, provided
4.5416 + * by {@code Character.getType(ch)}, is
4.5417 + * {@code DECIMAL_DIGIT_NUMBER}.
4.5418 + * <p>
4.5419 + * Some Unicode character ranges that contain digits:
4.5420 + * <ul>
4.5421 + * <li>{@code '\u005Cu0030'} through {@code '\u005Cu0039'},
4.5422 + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'})
4.5423 + * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
4.5424 + * Arabic-Indic digits
4.5425 + * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
4.5426 + * Extended Arabic-Indic digits
4.5427 + * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
4.5428 + * Devanagari digits
4.5429 + * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
4.5430 + * Fullwidth digits
4.5431 + * </ul>
4.5432 + *
4.5433 + * Many other character ranges contain digits as well.
4.5434 + *
4.5435 + * <p><b>Note:</b> This method cannot handle <a
4.5436 + * href="#supplementary"> supplementary characters</a>. To support
4.5437 + * all Unicode characters, including supplementary characters, use
4.5438 + * the {@link #isDigit(int)} method.
4.5439 + *
4.5440 + * @param ch the character to be tested.
4.5441 + * @return {@code true} if the character is a digit;
4.5442 + * {@code false} otherwise.
4.5443 + * @see Character#digit(char, int)
4.5444 + * @see Character#forDigit(int, int)
4.5445 + * @see Character#getType(char)
4.5446 + */
4.5447 + public static boolean isDigit(char ch) {
4.5448 + return isDigit((int)ch);
4.5449 + }
4.5450 +
4.5451 + /**
4.5452 + * Determines if the specified character (Unicode code point) is a digit.
4.5453 + * <p>
4.5454 + * A character is a digit if its general category type, provided
4.5455 + * by {@link Character#getType(int) getType(codePoint)}, is
4.5456 + * {@code DECIMAL_DIGIT_NUMBER}.
4.5457 + * <p>
4.5458 + * Some Unicode character ranges that contain digits:
4.5459 + * <ul>
4.5460 + * <li>{@code '\u005Cu0030'} through {@code '\u005Cu0039'},
4.5461 + * ISO-LATIN-1 digits ({@code '0'} through {@code '9'})
4.5462 + * <li>{@code '\u005Cu0660'} through {@code '\u005Cu0669'},
4.5463 + * Arabic-Indic digits
4.5464 + * <li>{@code '\u005Cu06F0'} through {@code '\u005Cu06F9'},
4.5465 + * Extended Arabic-Indic digits
4.5466 + * <li>{@code '\u005Cu0966'} through {@code '\u005Cu096F'},
4.5467 + * Devanagari digits
4.5468 + * <li>{@code '\u005CuFF10'} through {@code '\u005CuFF19'},
4.5469 + * Fullwidth digits
4.5470 + * </ul>
4.5471 + *
4.5472 + * Many other character ranges contain digits as well.
4.5473 + *
4.5474 + * @param codePoint the character (Unicode code point) to be tested.
4.5475 + * @return {@code true} if the character is a digit;
4.5476 + * {@code false} otherwise.
4.5477 + * @see Character#forDigit(int, int)
4.5478 + * @see Character#getType(int)
4.5479 + * @since 1.5
4.5480 + */
4.5481 + public static boolean isDigit(int codePoint) {
4.5482 + return getType(codePoint) == Character.DECIMAL_DIGIT_NUMBER;
4.5483 + }
4.5484 +
4.5485 + /**
4.5486 + * Determines if a character is defined in Unicode.
4.5487 + * <p>
4.5488 + * A character is defined if at least one of the following is true:
4.5489 + * <ul>
4.5490 + * <li>It has an entry in the UnicodeData file.
4.5491 + * <li>It has a value in a range defined by the UnicodeData file.
4.5492 + * </ul>
4.5493 + *
4.5494 + * <p><b>Note:</b> This method cannot handle <a
4.5495 + * href="#supplementary"> supplementary characters</a>. To support
4.5496 + * all Unicode characters, including supplementary characters, use
4.5497 + * the {@link #isDefined(int)} method.
4.5498 + *
4.5499 + * @param ch the character to be tested
4.5500 + * @return {@code true} if the character has a defined meaning
4.5501 + * in Unicode; {@code false} otherwise.
4.5502 + * @see Character#isDigit(char)
4.5503 + * @see Character#isLetter(char)
4.5504 + * @see Character#isLetterOrDigit(char)
4.5505 + * @see Character#isLowerCase(char)
4.5506 + * @see Character#isTitleCase(char)
4.5507 + * @see Character#isUpperCase(char)
4.5508 + * @since 1.0.2
4.5509 + */
4.5510 + public static boolean isDefined(char ch) {
4.5511 + return isDefined((int)ch);
4.5512 + }
4.5513 +
4.5514 + /**
4.5515 + * Determines if a character (Unicode code point) is defined in Unicode.
4.5516 + * <p>
4.5517 + * A character is defined if at least one of the following is true:
4.5518 + * <ul>
4.5519 + * <li>It has an entry in the UnicodeData file.
4.5520 + * <li>It has a value in a range defined by the UnicodeData file.
4.5521 + * </ul>
4.5522 + *
4.5523 + * @param codePoint the character (Unicode code point) to be tested.
4.5524 + * @return {@code true} if the character has a defined meaning
4.5525 + * in Unicode; {@code false} otherwise.
4.5526 + * @see Character#isDigit(int)
4.5527 + * @see Character#isLetter(int)
4.5528 + * @see Character#isLetterOrDigit(int)
4.5529 + * @see Character#isLowerCase(int)
4.5530 + * @see Character#isTitleCase(int)
4.5531 + * @see Character#isUpperCase(int)
4.5532 + * @since 1.5
4.5533 + */
4.5534 + public static boolean isDefined(int codePoint) {
4.5535 + return getType(codePoint) != Character.UNASSIGNED;
4.5536 + }
4.5537 +
4.5538 + /**
4.5539 + * Determines if the specified character is a letter.
4.5540 + * <p>
4.5541 + * A character is considered to be a letter if its general
4.5542 + * category type, provided by {@code Character.getType(ch)},
4.5543 + * is any of the following:
4.5544 + * <ul>
4.5545 + * <li> {@code UPPERCASE_LETTER}
4.5546 + * <li> {@code LOWERCASE_LETTER}
4.5547 + * <li> {@code TITLECASE_LETTER}
4.5548 + * <li> {@code MODIFIER_LETTER}
4.5549 + * <li> {@code OTHER_LETTER}
4.5550 + * </ul>
4.5551 + *
4.5552 + * Not all letters have case. Many characters are
4.5553 + * letters but are neither uppercase nor lowercase nor titlecase.
4.5554 + *
4.5555 + * <p><b>Note:</b> This method cannot handle <a
4.5556 + * href="#supplementary"> supplementary characters</a>. To support
4.5557 + * all Unicode characters, including supplementary characters, use
4.5558 + * the {@link #isLetter(int)} method.
4.5559 + *
4.5560 + * @param ch the character to be tested.
4.5561 + * @return {@code true} if the character is a letter;
4.5562 + * {@code false} otherwise.
4.5563 + * @see Character#isDigit(char)
4.5564 + * @see Character#isJavaIdentifierStart(char)
4.5565 + * @see Character#isJavaLetter(char)
4.5566 + * @see Character#isJavaLetterOrDigit(char)
4.5567 + * @see Character#isLetterOrDigit(char)
4.5568 + * @see Character#isLowerCase(char)
4.5569 + * @see Character#isTitleCase(char)
4.5570 + * @see Character#isUnicodeIdentifierStart(char)
4.5571 + * @see Character#isUpperCase(char)
4.5572 + */
4.5573 + public static boolean isLetter(char ch) {
4.5574 + return isLetter((int)ch);
4.5575 + }
4.5576 +
4.5577 + /**
4.5578 + * Determines if the specified character (Unicode code point) is a letter.
4.5579 + * <p>
4.5580 + * A character is considered to be a letter if its general
4.5581 + * category type, provided by {@link Character#getType(int) getType(codePoint)},
4.5582 + * is any of the following:
4.5583 + * <ul>
4.5584 + * <li> {@code UPPERCASE_LETTER}
4.5585 + * <li> {@code LOWERCASE_LETTER}
4.5586 + * <li> {@code TITLECASE_LETTER}
4.5587 + * <li> {@code MODIFIER_LETTER}
4.5588 + * <li> {@code OTHER_LETTER}
4.5589 + * </ul>
4.5590 + *
4.5591 + * Not all letters have case. Many characters are
4.5592 + * letters but are neither uppercase nor lowercase nor titlecase.
4.5593 + *
4.5594 + * @param codePoint the character (Unicode code point) to be tested.
4.5595 + * @return {@code true} if the character is a letter;
4.5596 + * {@code false} otherwise.
4.5597 + * @see Character#isDigit(int)
4.5598 + * @see Character#isJavaIdentifierStart(int)
4.5599 + * @see Character#isLetterOrDigit(int)
4.5600 + * @see Character#isLowerCase(int)
4.5601 + * @see Character#isTitleCase(int)
4.5602 + * @see Character#isUnicodeIdentifierStart(int)
4.5603 + * @see Character#isUpperCase(int)
4.5604 + * @since 1.5
4.5605 + */
4.5606 + public static boolean isLetter(int codePoint) {
4.5607 + return ((((1 << Character.UPPERCASE_LETTER) |
4.5608 + (1 << Character.LOWERCASE_LETTER) |
4.5609 + (1 << Character.TITLECASE_LETTER) |
4.5610 + (1 << Character.MODIFIER_LETTER) |
4.5611 + (1 << Character.OTHER_LETTER)) >> getType(codePoint)) & 1)
4.5612 + != 0;
4.5613 + }
4.5614 +
4.5615 + /**
4.5616 + * Determines if the specified character is a letter or digit.
4.5617 + * <p>
4.5618 + * A character is considered to be a letter or digit if either
4.5619 + * {@code Character.isLetter(char ch)} or
4.5620 + * {@code Character.isDigit(char ch)} returns
4.5621 + * {@code true} for the character.
4.5622 + *
4.5623 + * <p><b>Note:</b> This method cannot handle <a
4.5624 + * href="#supplementary"> supplementary characters</a>. To support
4.5625 + * all Unicode characters, including supplementary characters, use
4.5626 + * the {@link #isLetterOrDigit(int)} method.
4.5627 + *
4.5628 + * @param ch the character to be tested.
4.5629 + * @return {@code true} if the character is a letter or digit;
4.5630 + * {@code false} otherwise.
4.5631 + * @see Character#isDigit(char)
4.5632 + * @see Character#isJavaIdentifierPart(char)
4.5633 + * @see Character#isJavaLetter(char)
4.5634 + * @see Character#isJavaLetterOrDigit(char)
4.5635 + * @see Character#isLetter(char)
4.5636 + * @see Character#isUnicodeIdentifierPart(char)
4.5637 + * @since 1.0.2
4.5638 + */
4.5639 + public static boolean isLetterOrDigit(char ch) {
4.5640 + return isLetterOrDigit((int)ch);
4.5641 + }
4.5642 +
4.5643 + /**
4.5644 + * Determines if the specified character (Unicode code point) is a letter or digit.
4.5645 + * <p>
4.5646 + * A character is considered to be a letter or digit if either
4.5647 + * {@link #isLetter(int) isLetter(codePoint)} or
4.5648 + * {@link #isDigit(int) isDigit(codePoint)} returns
4.5649 + * {@code true} for the character.
4.5650 + *
4.5651 + * @param codePoint the character (Unicode code point) to be tested.
4.5652 + * @return {@code true} if the character is a letter or digit;
4.5653 + * {@code false} otherwise.
4.5654 + * @see Character#isDigit(int)
4.5655 + * @see Character#isJavaIdentifierPart(int)
4.5656 + * @see Character#isLetter(int)
4.5657 + * @see Character#isUnicodeIdentifierPart(int)
4.5658 + * @since 1.5
4.5659 + */
4.5660 + public static boolean isLetterOrDigit(int codePoint) {
4.5661 + return ((((1 << Character.UPPERCASE_LETTER) |
4.5662 + (1 << Character.LOWERCASE_LETTER) |
4.5663 + (1 << Character.TITLECASE_LETTER) |
4.5664 + (1 << Character.MODIFIER_LETTER) |
4.5665 + (1 << Character.OTHER_LETTER) |
4.5666 + (1 << Character.DECIMAL_DIGIT_NUMBER)) >> getType(codePoint)) & 1)
4.5667 + != 0;
4.5668 + }
4.5669 +
4.5670 + /**
4.5671 + * Determines if the specified character is permissible as the first
4.5672 + * character in a Java identifier.
4.5673 + * <p>
4.5674 + * A character may start a Java identifier if and only if
4.5675 + * one of the following is true:
4.5676 + * <ul>
4.5677 + * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
4.5678 + * <li> {@link #getType(char) getType(ch)} returns {@code LETTER_NUMBER}
4.5679 + * <li> {@code ch} is a currency symbol (such as {@code '$'})
4.5680 + * <li> {@code ch} is a connecting punctuation character (such as {@code '_'}).
4.5681 + * </ul>
4.5682 + *
4.5683 + * @param ch the character to be tested.
4.5684 + * @return {@code true} if the character may start a Java
4.5685 + * identifier; {@code false} otherwise.
4.5686 + * @see Character#isJavaLetterOrDigit(char)
4.5687 + * @see Character#isJavaIdentifierStart(char)
4.5688 + * @see Character#isJavaIdentifierPart(char)
4.5689 + * @see Character#isLetter(char)
4.5690 + * @see Character#isLetterOrDigit(char)
4.5691 + * @see Character#isUnicodeIdentifierStart(char)
4.5692 + * @since 1.02
4.5693 + * @deprecated Replaced by isJavaIdentifierStart(char).
4.5694 + */
4.5695 + @Deprecated
4.5696 + public static boolean isJavaLetter(char ch) {
4.5697 + return isJavaIdentifierStart(ch);
4.5698 + }
4.5699 +
4.5700 + /**
4.5701 + * Determines if the specified character may be part of a Java
4.5702 + * identifier as other than the first character.
4.5703 + * <p>
4.5704 + * A character may be part of a Java identifier if and only if any
4.5705 + * of the following are true:
4.5706 + * <ul>
4.5707 + * <li> it is a letter
4.5708 + * <li> it is a currency symbol (such as {@code '$'})
4.5709 + * <li> it is a connecting punctuation character (such as {@code '_'})
4.5710 + * <li> it is a digit
4.5711 + * <li> it is a numeric letter (such as a Roman numeral character)
4.5712 + * <li> it is a combining mark
4.5713 + * <li> it is a non-spacing mark
4.5714 + * <li> {@code isIdentifierIgnorable} returns
4.5715 + * {@code true} for the character.
4.5716 + * </ul>
4.5717 + *
4.5718 + * @param ch the character to be tested.
4.5719 + * @return {@code true} if the character may be part of a
4.5720 + * Java identifier; {@code false} otherwise.
4.5721 + * @see Character#isJavaLetter(char)
4.5722 + * @see Character#isJavaIdentifierStart(char)
4.5723 + * @see Character#isJavaIdentifierPart(char)
4.5724 + * @see Character#isLetter(char)
4.5725 + * @see Character#isLetterOrDigit(char)
4.5726 + * @see Character#isUnicodeIdentifierPart(char)
4.5727 + * @see Character#isIdentifierIgnorable(char)
4.5728 + * @since 1.02
4.5729 + * @deprecated Replaced by isJavaIdentifierPart(char).
4.5730 + */
4.5731 + @Deprecated
4.5732 + public static boolean isJavaLetterOrDigit(char ch) {
4.5733 + return isJavaIdentifierPart(ch);
4.5734 + }
4.5735 +
4.5736 + /**
4.5737 + * Determines if the specified character (Unicode code point) is an alphabet.
4.5738 + * <p>
4.5739 + * A character is considered to be alphabetic if its general category type,
4.5740 + * provided by {@link Character#getType(int) getType(codePoint)}, is any of
4.5741 + * the following:
4.5742 + * <ul>
4.5743 + * <li> <code>UPPERCASE_LETTER</code>
4.5744 + * <li> <code>LOWERCASE_LETTER</code>
4.5745 + * <li> <code>TITLECASE_LETTER</code>
4.5746 + * <li> <code>MODIFIER_LETTER</code>
4.5747 + * <li> <code>OTHER_LETTER</code>
4.5748 + * <li> <code>LETTER_NUMBER</code>
4.5749 + * </ul>
4.5750 + * or it has contributory property Other_Alphabetic as defined by the
4.5751 + * Unicode Standard.
4.5752 + *
4.5753 + * @param codePoint the character (Unicode code point) to be tested.
4.5754 + * @return <code>true</code> if the character is a Unicode alphabet
4.5755 + * character, <code>false</code> otherwise.
4.5756 + * @since 1.7
4.5757 + */
4.5758 + public static boolean isAlphabetic(int codePoint) {
4.5759 + return (((((1 << Character.UPPERCASE_LETTER) |
4.5760 + (1 << Character.LOWERCASE_LETTER) |
4.5761 + (1 << Character.TITLECASE_LETTER) |
4.5762 + (1 << Character.MODIFIER_LETTER) |
4.5763 + (1 << Character.OTHER_LETTER) |
4.5764 + (1 << Character.LETTER_NUMBER)) >> getType(codePoint)) & 1) != 0) ||
4.5765 + CharacterData.of(codePoint).isOtherAlphabetic(codePoint);
4.5766 + }
4.5767 +
4.5768 + /**
4.5769 + * Determines if the specified character (Unicode code point) is a CJKV
4.5770 + * (Chinese, Japanese, Korean and Vietnamese) ideograph, as defined by
4.5771 + * the Unicode Standard.
4.5772 + *
4.5773 + * @param codePoint the character (Unicode code point) to be tested.
4.5774 + * @return <code>true</code> if the character is a Unicode ideograph
4.5775 + * character, <code>false</code> otherwise.
4.5776 + * @since 1.7
4.5777 + */
4.5778 + public static boolean isIdeographic(int codePoint) {
4.5779 + return CharacterData.of(codePoint).isIdeographic(codePoint);
4.5780 + }
4.5781 +
4.5782 + /**
4.5783 + * Determines if the specified character is
4.5784 + * permissible as the first character in a Java identifier.
4.5785 + * <p>
4.5786 + * A character may start a Java identifier if and only if
4.5787 + * one of the following conditions is true:
4.5788 + * <ul>
4.5789 + * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
4.5790 + * <li> {@link #getType(char) getType(ch)} returns {@code LETTER_NUMBER}
4.5791 + * <li> {@code ch} is a currency symbol (such as {@code '$'})
4.5792 + * <li> {@code ch} is a connecting punctuation character (such as {@code '_'}).
4.5793 + * </ul>
4.5794 + *
4.5795 + * <p><b>Note:</b> This method cannot handle <a
4.5796 + * href="#supplementary"> supplementary characters</a>. To support
4.5797 + * all Unicode characters, including supplementary characters, use
4.5798 + * the {@link #isJavaIdentifierStart(int)} method.
4.5799 + *
4.5800 + * @param ch the character to be tested.
4.5801 + * @return {@code true} if the character may start a Java identifier;
4.5802 + * {@code false} otherwise.
4.5803 + * @see Character#isJavaIdentifierPart(char)
4.5804 + * @see Character#isLetter(char)
4.5805 + * @see Character#isUnicodeIdentifierStart(char)
4.5806 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
4.5807 + * @since 1.1
4.5808 + */
4.5809 + public static boolean isJavaIdentifierStart(char ch) {
4.5810 + return isJavaIdentifierStart((int)ch);
4.5811 + }
4.5812 +
4.5813 + /**
4.5814 + * Determines if the character (Unicode code point) is
4.5815 + * permissible as the first character in a Java identifier.
4.5816 + * <p>
4.5817 + * A character may start a Java identifier if and only if
4.5818 + * one of the following conditions is true:
4.5819 + * <ul>
4.5820 + * <li> {@link #isLetter(int) isLetter(codePoint)}
4.5821 + * returns {@code true}
4.5822 + * <li> {@link #getType(int) getType(codePoint)}
4.5823 + * returns {@code LETTER_NUMBER}
4.5824 + * <li> the referenced character is a currency symbol (such as {@code '$'})
4.5825 + * <li> the referenced character is a connecting punctuation character
4.5826 + * (such as {@code '_'}).
4.5827 + * </ul>
4.5828 + *
4.5829 + * @param codePoint the character (Unicode code point) to be tested.
4.5830 + * @return {@code true} if the character may start a Java identifier;
4.5831 + * {@code false} otherwise.
4.5832 + * @see Character#isJavaIdentifierPart(int)
4.5833 + * @see Character#isLetter(int)
4.5834 + * @see Character#isUnicodeIdentifierStart(int)
4.5835 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
4.5836 + * @since 1.5
4.5837 + */
4.5838 + public static boolean isJavaIdentifierStart(int codePoint) {
4.5839 + return CharacterData.of(codePoint).isJavaIdentifierStart(codePoint);
4.5840 + }
4.5841 +
4.5842 + /**
4.5843 + * Determines if the specified character may be part of a Java
4.5844 + * identifier as other than the first character.
4.5845 + * <p>
4.5846 + * A character may be part of a Java identifier if any of the following
4.5847 + * are true:
4.5848 + * <ul>
4.5849 + * <li> it is a letter
4.5850 + * <li> it is a currency symbol (such as {@code '$'})
4.5851 + * <li> it is a connecting punctuation character (such as {@code '_'})
4.5852 + * <li> it is a digit
4.5853 + * <li> it is a numeric letter (such as a Roman numeral character)
4.5854 + * <li> it is a combining mark
4.5855 + * <li> it is a non-spacing mark
4.5856 + * <li> {@code isIdentifierIgnorable} returns
4.5857 + * {@code true} for the character
4.5858 + * </ul>
4.5859 + *
4.5860 + * <p><b>Note:</b> This method cannot handle <a
4.5861 + * href="#supplementary"> supplementary characters</a>. To support
4.5862 + * all Unicode characters, including supplementary characters, use
4.5863 + * the {@link #isJavaIdentifierPart(int)} method.
4.5864 + *
4.5865 + * @param ch the character to be tested.
4.5866 + * @return {@code true} if the character may be part of a
4.5867 + * Java identifier; {@code false} otherwise.
4.5868 + * @see Character#isIdentifierIgnorable(char)
4.5869 + * @see Character#isJavaIdentifierStart(char)
4.5870 + * @see Character#isLetterOrDigit(char)
4.5871 + * @see Character#isUnicodeIdentifierPart(char)
4.5872 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
4.5873 + * @since 1.1
4.5874 + */
4.5875 + public static boolean isJavaIdentifierPart(char ch) {
4.5876 + return isJavaIdentifierPart((int)ch);
4.5877 + }
4.5878 +
4.5879 + /**
4.5880 + * Determines if the character (Unicode code point) may be part of a Java
4.5881 + * identifier as other than the first character.
4.5882 + * <p>
4.5883 + * A character may be part of a Java identifier if any of the following
4.5884 + * are true:
4.5885 + * <ul>
4.5886 + * <li> it is a letter
4.5887 + * <li> it is a currency symbol (such as {@code '$'})
4.5888 + * <li> it is a connecting punctuation character (such as {@code '_'})
4.5889 + * <li> it is a digit
4.5890 + * <li> it is a numeric letter (such as a Roman numeral character)
4.5891 + * <li> it is a combining mark
4.5892 + * <li> it is a non-spacing mark
4.5893 + * <li> {@link #isIdentifierIgnorable(int)
4.5894 + * isIdentifierIgnorable(codePoint)} returns {@code true} for
4.5895 + * the character
4.5896 + * </ul>
4.5897 + *
4.5898 + * @param codePoint the character (Unicode code point) to be tested.
4.5899 + * @return {@code true} if the character may be part of a
4.5900 + * Java identifier; {@code false} otherwise.
4.5901 + * @see Character#isIdentifierIgnorable(int)
4.5902 + * @see Character#isJavaIdentifierStart(int)
4.5903 + * @see Character#isLetterOrDigit(int)
4.5904 + * @see Character#isUnicodeIdentifierPart(int)
4.5905 + * @see javax.lang.model.SourceVersion#isIdentifier(CharSequence)
4.5906 + * @since 1.5
4.5907 + */
4.5908 + public static boolean isJavaIdentifierPart(int codePoint) {
4.5909 + return CharacterData.of(codePoint).isJavaIdentifierPart(codePoint);
4.5910 + }
4.5911 +
4.5912 + /**
4.5913 + * Determines if the specified character is permissible as the
4.5914 + * first character in a Unicode identifier.
4.5915 + * <p>
4.5916 + * A character may start a Unicode identifier if and only if
4.5917 + * one of the following conditions is true:
4.5918 + * <ul>
4.5919 + * <li> {@link #isLetter(char) isLetter(ch)} returns {@code true}
4.5920 + * <li> {@link #getType(char) getType(ch)} returns
4.5921 + * {@code LETTER_NUMBER}.
4.5922 + * </ul>
4.5923 + *
4.5924 + * <p><b>Note:</b> This method cannot handle <a
4.5925 + * href="#supplementary"> supplementary characters</a>. To support
4.5926 + * all Unicode characters, including supplementary characters, use
4.5927 + * the {@link #isUnicodeIdentifierStart(int)} method.
4.5928 + *
4.5929 + * @param ch the character to be tested.
4.5930 + * @return {@code true} if the character may start a Unicode
4.5931 + * identifier; {@code false} otherwise.
4.5932 + * @see Character#isJavaIdentifierStart(char)
4.5933 + * @see Character#isLetter(char)
4.5934 + * @see Character#isUnicodeIdentifierPart(char)
4.5935 + * @since 1.1
4.5936 + */
4.5937 + public static boolean isUnicodeIdentifierStart(char ch) {
4.5938 + return isUnicodeIdentifierStart((int)ch);
4.5939 + }
4.5940 +
4.5941 + /**
4.5942 + * Determines if the specified character (Unicode code point) is permissible as the
4.5943 + * first character in a Unicode identifier.
4.5944 + * <p>
4.5945 + * A character may start a Unicode identifier if and only if
4.5946 + * one of the following conditions is true:
4.5947 + * <ul>
4.5948 + * <li> {@link #isLetter(int) isLetter(codePoint)}
4.5949 + * returns {@code true}
4.5950 + * <li> {@link #getType(int) getType(codePoint)}
4.5951 + * returns {@code LETTER_NUMBER}.
4.5952 + * </ul>
4.5953 + * @param codePoint the character (Unicode code point) to be tested.
4.5954 + * @return {@code true} if the character may start a Unicode
4.5955 + * identifier; {@code false} otherwise.
4.5956 + * @see Character#isJavaIdentifierStart(int)
4.5957 + * @see Character#isLetter(int)
4.5958 + * @see Character#isUnicodeIdentifierPart(int)
4.5959 + * @since 1.5
4.5960 + */
4.5961 + public static boolean isUnicodeIdentifierStart(int codePoint) {
4.5962 + return CharacterData.of(codePoint).isUnicodeIdentifierStart(codePoint);
4.5963 + }
4.5964 +
4.5965 + /**
4.5966 + * Determines if the specified character may be part of a Unicode
4.5967 + * identifier as other than the first character.
4.5968 + * <p>
4.5969 + * A character may be part of a Unicode identifier if and only if
4.5970 + * one of the following statements is true:
4.5971 + * <ul>
4.5972 + * <li> it is a letter
4.5973 + * <li> it is a connecting punctuation character (such as {@code '_'})
4.5974 + * <li> it is a digit
4.5975 + * <li> it is a numeric letter (such as a Roman numeral character)
4.5976 + * <li> it is a combining mark
4.5977 + * <li> it is a non-spacing mark
4.5978 + * <li> {@code isIdentifierIgnorable} returns
4.5979 + * {@code true} for this character.
4.5980 + * </ul>
4.5981 + *
4.5982 + * <p><b>Note:</b> This method cannot handle <a
4.5983 + * href="#supplementary"> supplementary characters</a>. To support
4.5984 + * all Unicode characters, including supplementary characters, use
4.5985 + * the {@link #isUnicodeIdentifierPart(int)} method.
4.5986 + *
4.5987 + * @param ch the character to be tested.
4.5988 + * @return {@code true} if the character may be part of a
4.5989 + * Unicode identifier; {@code false} otherwise.
4.5990 + * @see Character#isIdentifierIgnorable(char)
4.5991 + * @see Character#isJavaIdentifierPart(char)
4.5992 + * @see Character#isLetterOrDigit(char)
4.5993 + * @see Character#isUnicodeIdentifierStart(char)
4.5994 + * @since 1.1
4.5995 + */
4.5996 + public static boolean isUnicodeIdentifierPart(char ch) {
4.5997 + return isUnicodeIdentifierPart((int)ch);
4.5998 + }
4.5999 +
4.6000 + /**
4.6001 + * Determines if the specified character (Unicode code point) may be part of a Unicode
4.6002 + * identifier as other than the first character.
4.6003 + * <p>
4.6004 + * A character may be part of a Unicode identifier if and only if
4.6005 + * one of the following statements is true:
4.6006 + * <ul>
4.6007 + * <li> it is a letter
4.6008 + * <li> it is a connecting punctuation character (such as {@code '_'})
4.6009 + * <li> it is a digit
4.6010 + * <li> it is a numeric letter (such as a Roman numeral character)
4.6011 + * <li> it is a combining mark
4.6012 + * <li> it is a non-spacing mark
4.6013 + * <li> {@code isIdentifierIgnorable} returns
4.6014 + * {@code true} for this character.
4.6015 + * </ul>
4.6016 + * @param codePoint the character (Unicode code point) to be tested.
4.6017 + * @return {@code true} if the character may be part of a
4.6018 + * Unicode identifier; {@code false} otherwise.
4.6019 + * @see Character#isIdentifierIgnorable(int)
4.6020 + * @see Character#isJavaIdentifierPart(int)
4.6021 + * @see Character#isLetterOrDigit(int)
4.6022 + * @see Character#isUnicodeIdentifierStart(int)
4.6023 + * @since 1.5
4.6024 + */
4.6025 + public static boolean isUnicodeIdentifierPart(int codePoint) {
4.6026 + return CharacterData.of(codePoint).isUnicodeIdentifierPart(codePoint);
4.6027 + }
4.6028 +
4.6029 + /**
4.6030 + * Determines if the specified character should be regarded as
4.6031 + * an ignorable character in a Java identifier or a Unicode identifier.
4.6032 + * <p>
4.6033 + * The following Unicode characters are ignorable in a Java identifier
4.6034 + * or a Unicode identifier:
4.6035 + * <ul>
4.6036 + * <li>ISO control characters that are not whitespace
4.6037 + * <ul>
4.6038 + * <li>{@code '\u005Cu0000'} through {@code '\u005Cu0008'}
4.6039 + * <li>{@code '\u005Cu000E'} through {@code '\u005Cu001B'}
4.6040 + * <li>{@code '\u005Cu007F'} through {@code '\u005Cu009F'}
4.6041 + * </ul>
4.6042 + *
4.6043 + * <li>all characters that have the {@code FORMAT} general
4.6044 + * category value
4.6045 + * </ul>
4.6046 + *
4.6047 + * <p><b>Note:</b> This method cannot handle <a
4.6048 + * href="#supplementary"> supplementary characters</a>. To support
4.6049 + * all Unicode characters, including supplementary characters, use
4.6050 + * the {@link #isIdentifierIgnorable(int)} method.
4.6051 + *
4.6052 + * @param ch the character to be tested.
4.6053 + * @return {@code true} if the character is an ignorable control
4.6054 + * character that may be part of a Java or Unicode identifier;
4.6055 + * {@code false} otherwise.
4.6056 + * @see Character#isJavaIdentifierPart(char)
4.6057 + * @see Character#isUnicodeIdentifierPart(char)
4.6058 + * @since 1.1
4.6059 + */
4.6060 + public static boolean isIdentifierIgnorable(char ch) {
4.6061 + return isIdentifierIgnorable((int)ch);
4.6062 + }
4.6063 +
4.6064 + /**
4.6065 + * Determines if the specified character (Unicode code point) should be regarded as
4.6066 + * an ignorable character in a Java identifier or a Unicode identifier.
4.6067 + * <p>
4.6068 + * The following Unicode characters are ignorable in a Java identifier
4.6069 + * or a Unicode identifier:
4.6070 + * <ul>
4.6071 + * <li>ISO control characters that are not whitespace
4.6072 + * <ul>
4.6073 + * <li>{@code '\u005Cu0000'} through {@code '\u005Cu0008'}
4.6074 + * <li>{@code '\u005Cu000E'} through {@code '\u005Cu001B'}
4.6075 + * <li>{@code '\u005Cu007F'} through {@code '\u005Cu009F'}
4.6076 + * </ul>
4.6077 + *
4.6078 + * <li>all characters that have the {@code FORMAT} general
4.6079 + * category value
4.6080 + * </ul>
4.6081 + *
4.6082 + * @param codePoint the character (Unicode code point) to be tested.
4.6083 + * @return {@code true} if the character is an ignorable control
4.6084 + * character that may be part of a Java or Unicode identifier;
4.6085 + * {@code false} otherwise.
4.6086 + * @see Character#isJavaIdentifierPart(int)
4.6087 + * @see Character#isUnicodeIdentifierPart(int)
4.6088 + * @since 1.5
4.6089 + */
4.6090 + public static boolean isIdentifierIgnorable(int codePoint) {
4.6091 + return CharacterData.of(codePoint).isIdentifierIgnorable(codePoint);
4.6092 + }
4.6093 +
4.6094 + /**
4.6095 + * Converts the character argument to lowercase using case
4.6096 + * mapping information from the UnicodeData file.
4.6097 + * <p>
4.6098 + * Note that
4.6099 + * {@code Character.isLowerCase(Character.toLowerCase(ch))}
4.6100 + * does not always return {@code true} for some ranges of
4.6101 + * characters, particularly those that are symbols or ideographs.
4.6102 + *
4.6103 + * <p>In general, {@link String#toLowerCase()} should be used to map
4.6104 + * characters to lowercase. {@code String} case mapping methods
4.6105 + * have several benefits over {@code Character} case mapping methods.
4.6106 + * {@code String} case mapping methods can perform locale-sensitive
4.6107 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
4.6108 + * the {@code Character} case mapping methods cannot.
4.6109 + *
4.6110 + * <p><b>Note:</b> This method cannot handle <a
4.6111 + * href="#supplementary"> supplementary characters</a>. To support
4.6112 + * all Unicode characters, including supplementary characters, use
4.6113 + * the {@link #toLowerCase(int)} method.
4.6114 + *
4.6115 + * @param ch the character to be converted.
4.6116 + * @return the lowercase equivalent of the character, if any;
4.6117 + * otherwise, the character itself.
4.6118 + * @see Character#isLowerCase(char)
4.6119 + * @see String#toLowerCase()
4.6120 + */
4.6121 + public static char toLowerCase(char ch) {
4.6122 + return (char)toLowerCase((int)ch);
4.6123 + }
4.6124 +
4.6125 + /**
4.6126 + * Converts the character (Unicode code point) argument to
4.6127 + * lowercase using case mapping information from the UnicodeData
4.6128 + * file.
4.6129 + *
4.6130 + * <p> Note that
4.6131 + * {@code Character.isLowerCase(Character.toLowerCase(codePoint))}
4.6132 + * does not always return {@code true} for some ranges of
4.6133 + * characters, particularly those that are symbols or ideographs.
4.6134 + *
4.6135 + * <p>In general, {@link String#toLowerCase()} should be used to map
4.6136 + * characters to lowercase. {@code String} case mapping methods
4.6137 + * have several benefits over {@code Character} case mapping methods.
4.6138 + * {@code String} case mapping methods can perform locale-sensitive
4.6139 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
4.6140 + * the {@code Character} case mapping methods cannot.
4.6141 + *
4.6142 + * @param codePoint the character (Unicode code point) to be converted.
4.6143 + * @return the lowercase equivalent of the character (Unicode code
4.6144 + * point), if any; otherwise, the character itself.
4.6145 + * @see Character#isLowerCase(int)
4.6146 + * @see String#toLowerCase()
4.6147 + *
4.6148 + * @since 1.5
4.6149 + */
4.6150 + public static int toLowerCase(int codePoint) {
4.6151 + return CharacterData.of(codePoint).toLowerCase(codePoint);
4.6152 + }
4.6153 +
4.6154 + /**
4.6155 + * Converts the character argument to uppercase using case mapping
4.6156 + * information from the UnicodeData file.
4.6157 + * <p>
4.6158 + * Note that
4.6159 + * {@code Character.isUpperCase(Character.toUpperCase(ch))}
4.6160 + * does not always return {@code true} for some ranges of
4.6161 + * characters, particularly those that are symbols or ideographs.
4.6162 + *
4.6163 + * <p>In general, {@link String#toUpperCase()} should be used to map
4.6164 + * characters to uppercase. {@code String} case mapping methods
4.6165 + * have several benefits over {@code Character} case mapping methods.
4.6166 + * {@code String} case mapping methods can perform locale-sensitive
4.6167 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
4.6168 + * the {@code Character} case mapping methods cannot.
4.6169 + *
4.6170 + * <p><b>Note:</b> This method cannot handle <a
4.6171 + * href="#supplementary"> supplementary characters</a>. To support
4.6172 + * all Unicode characters, including supplementary characters, use
4.6173 + * the {@link #toUpperCase(int)} method.
4.6174 + *
4.6175 + * @param ch the character to be converted.
4.6176 + * @return the uppercase equivalent of the character, if any;
4.6177 + * otherwise, the character itself.
4.6178 + * @see Character#isUpperCase(char)
4.6179 + * @see String#toUpperCase()
4.6180 + */
4.6181 + public static char toUpperCase(char ch) {
4.6182 + return (char)toUpperCase((int)ch);
4.6183 + }
4.6184 +
4.6185 + /**
4.6186 + * Converts the character (Unicode code point) argument to
4.6187 + * uppercase using case mapping information from the UnicodeData
4.6188 + * file.
4.6189 + *
4.6190 + * <p>Note that
4.6191 + * {@code Character.isUpperCase(Character.toUpperCase(codePoint))}
4.6192 + * does not always return {@code true} for some ranges of
4.6193 + * characters, particularly those that are symbols or ideographs.
4.6194 + *
4.6195 + * <p>In general, {@link String#toUpperCase()} should be used to map
4.6196 + * characters to uppercase. {@code String} case mapping methods
4.6197 + * have several benefits over {@code Character} case mapping methods.
4.6198 + * {@code String} case mapping methods can perform locale-sensitive
4.6199 + * mappings, context-sensitive mappings, and 1:M character mappings, whereas
4.6200 + * the {@code Character} case mapping methods cannot.
4.6201 + *
4.6202 + * @param codePoint the character (Unicode code point) to be converted.
4.6203 + * @return the uppercase equivalent of the character, if any;
4.6204 + * otherwise, the character itself.
4.6205 + * @see Character#isUpperCase(int)
4.6206 + * @see String#toUpperCase()
4.6207 + *
4.6208 + * @since 1.5
4.6209 + */
4.6210 + public static int toUpperCase(int codePoint) {
4.6211 + return CharacterData.of(codePoint).toUpperCase(codePoint);
4.6212 + }
4.6213 +
4.6214 + /**
4.6215 + * Converts the character argument to titlecase using case mapping
4.6216 + * information from the UnicodeData file. If a character has no
4.6217 + * explicit titlecase mapping and is not itself a titlecase char
4.6218 + * according to UnicodeData, then the uppercase mapping is
4.6219 + * returned as an equivalent titlecase mapping. If the
4.6220 + * {@code char} argument is already a titlecase
4.6221 + * {@code char}, the same {@code char} value will be
4.6222 + * returned.
4.6223 + * <p>
4.6224 + * Note that
4.6225 + * {@code Character.isTitleCase(Character.toTitleCase(ch))}
4.6226 + * does not always return {@code true} for some ranges of
4.6227 + * characters.
4.6228 + *
4.6229 + * <p><b>Note:</b> This method cannot handle <a
4.6230 + * href="#supplementary"> supplementary characters</a>. To support
4.6231 + * all Unicode characters, including supplementary characters, use
4.6232 + * the {@link #toTitleCase(int)} method.
4.6233 + *
4.6234 + * @param ch the character to be converted.
4.6235 + * @return the titlecase equivalent of the character, if any;
4.6236 + * otherwise, the character itself.
4.6237 + * @see Character#isTitleCase(char)
4.6238 + * @see Character#toLowerCase(char)
4.6239 + * @see Character#toUpperCase(char)
4.6240 + * @since 1.0.2
4.6241 + */
4.6242 + public static char toTitleCase(char ch) {
4.6243 + return (char)toTitleCase((int)ch);
4.6244 + }
4.6245 +
4.6246 + /**
4.6247 + * Converts the character (Unicode code point) argument to titlecase using case mapping
4.6248 + * information from the UnicodeData file. If a character has no
4.6249 + * explicit titlecase mapping and is not itself a titlecase char
4.6250 + * according to UnicodeData, then the uppercase mapping is
4.6251 + * returned as an equivalent titlecase mapping. If the
4.6252 + * character argument is already a titlecase
4.6253 + * character, the same character value will be
4.6254 + * returned.
4.6255 + *
4.6256 + * <p>Note that
4.6257 + * {@code Character.isTitleCase(Character.toTitleCase(codePoint))}
4.6258 + * does not always return {@code true} for some ranges of
4.6259 + * characters.
4.6260 + *
4.6261 + * @param codePoint the character (Unicode code point) to be converted.
4.6262 + * @return the titlecase equivalent of the character, if any;
4.6263 + * otherwise, the character itself.
4.6264 + * @see Character#isTitleCase(int)
4.6265 + * @see Character#toLowerCase(int)
4.6266 + * @see Character#toUpperCase(int)
4.6267 + * @since 1.5
4.6268 + */
4.6269 + public static int toTitleCase(int codePoint) {
4.6270 + return CharacterData.of(codePoint).toTitleCase(codePoint);
4.6271 + }
4.6272 +
4.6273 + /**
4.6274 + * Returns the numeric value of the character {@code ch} in the
4.6275 + * specified radix.
4.6276 + * <p>
4.6277 + * If the radix is not in the range {@code MIN_RADIX} ≤
4.6278 + * {@code radix} ≤ {@code MAX_RADIX} or if the
4.6279 + * value of {@code ch} is not a valid digit in the specified
4.6280 + * radix, {@code -1} is returned. A character is a valid digit
4.6281 + * if at least one of the following is true:
4.6282 + * <ul>
4.6283 + * <li>The method {@code isDigit} is {@code true} of the character
4.6284 + * and the Unicode decimal digit value of the character (or its
4.6285 + * single-character decomposition) is less than the specified radix.
4.6286 + * In this case the decimal digit value is returned.
4.6287 + * <li>The character is one of the uppercase Latin letters
4.6288 + * {@code 'A'} through {@code 'Z'} and its code is less than
4.6289 + * {@code radix + 'A' - 10}.
4.6290 + * In this case, {@code ch - 'A' + 10}
4.6291 + * is returned.
4.6292 + * <li>The character is one of the lowercase Latin letters
4.6293 + * {@code 'a'} through {@code 'z'} and its code is less than
4.6294 + * {@code radix + 'a' - 10}.
4.6295 + * In this case, {@code ch - 'a' + 10}
4.6296 + * is returned.
4.6297 + * <li>The character is one of the fullwidth uppercase Latin letters A
4.6298 + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'})
4.6299 + * and its code is less than
4.6300 + * {@code radix + '\u005CuFF21' - 10}.
4.6301 + * In this case, {@code ch - '\u005CuFF21' + 10}
4.6302 + * is returned.
4.6303 + * <li>The character is one of the fullwidth lowercase Latin letters a
4.6304 + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'})
4.6305 + * and its code is less than
4.6306 + * {@code radix + '\u005CuFF41' - 10}.
4.6307 + * In this case, {@code ch - '\u005CuFF41' + 10}
4.6308 + * is returned.
4.6309 + * </ul>
4.6310 + *
4.6311 + * <p><b>Note:</b> This method cannot handle <a
4.6312 + * href="#supplementary"> supplementary characters</a>. To support
4.6313 + * all Unicode characters, including supplementary characters, use
4.6314 + * the {@link #digit(int, int)} method.
4.6315 + *
4.6316 + * @param ch the character to be converted.
4.6317 + * @param radix the radix.
4.6318 + * @return the numeric value represented by the character in the
4.6319 + * specified radix.
4.6320 + * @see Character#forDigit(int, int)
4.6321 + * @see Character#isDigit(char)
4.6322 + */
4.6323 + public static int digit(char ch, int radix) {
4.6324 + return digit((int)ch, radix);
4.6325 + }
4.6326 +
4.6327 + /**
4.6328 + * Returns the numeric value of the specified character (Unicode
4.6329 + * code point) in the specified radix.
4.6330 + *
4.6331 + * <p>If the radix is not in the range {@code MIN_RADIX} ≤
4.6332 + * {@code radix} ≤ {@code MAX_RADIX} or if the
4.6333 + * character is not a valid digit in the specified
4.6334 + * radix, {@code -1} is returned. A character is a valid digit
4.6335 + * if at least one of the following is true:
4.6336 + * <ul>
4.6337 + * <li>The method {@link #isDigit(int) isDigit(codePoint)} is {@code true} of the character
4.6338 + * and the Unicode decimal digit value of the character (or its
4.6339 + * single-character decomposition) is less than the specified radix.
4.6340 + * In this case the decimal digit value is returned.
4.6341 + * <li>The character is one of the uppercase Latin letters
4.6342 + * {@code 'A'} through {@code 'Z'} and its code is less than
4.6343 + * {@code radix + 'A' - 10}.
4.6344 + * In this case, {@code codePoint - 'A' + 10}
4.6345 + * is returned.
4.6346 + * <li>The character is one of the lowercase Latin letters
4.6347 + * {@code 'a'} through {@code 'z'} and its code is less than
4.6348 + * {@code radix + 'a' - 10}.
4.6349 + * In this case, {@code codePoint - 'a' + 10}
4.6350 + * is returned.
4.6351 + * <li>The character is one of the fullwidth uppercase Latin letters A
4.6352 + * ({@code '\u005CuFF21'}) through Z ({@code '\u005CuFF3A'})
4.6353 + * and its code is less than
4.6354 + * {@code radix + '\u005CuFF21' - 10}.
4.6355 + * In this case,
4.6356 + * {@code codePoint - '\u005CuFF21' + 10}
4.6357 + * is returned.
4.6358 + * <li>The character is one of the fullwidth lowercase Latin letters a
4.6359 + * ({@code '\u005CuFF41'}) through z ({@code '\u005CuFF5A'})
4.6360 + * and its code is less than
4.6361 + * {@code radix + '\u005CuFF41'- 10}.
4.6362 + * In this case,
4.6363 + * {@code codePoint - '\u005CuFF41' + 10}
4.6364 + * is returned.
4.6365 + * </ul>
4.6366 + *
4.6367 + * @param codePoint the character (Unicode code point) to be converted.
4.6368 + * @param radix the radix.
4.6369 + * @return the numeric value represented by the character in the
4.6370 + * specified radix.
4.6371 + * @see Character#forDigit(int, int)
4.6372 + * @see Character#isDigit(int)
4.6373 + * @since 1.5
4.6374 + */
4.6375 + public static int digit(int codePoint, int radix) {
4.6376 + return CharacterData.of(codePoint).digit(codePoint, radix);
4.6377 + }
4.6378 +
4.6379 + /**
4.6380 + * Returns the {@code int} value that the specified Unicode
4.6381 + * character represents. For example, the character
4.6382 + * {@code '\u005Cu216C'} (the roman numeral fifty) will return
4.6383 + * an int with a value of 50.
4.6384 + * <p>
4.6385 + * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through
4.6386 + * {@code '\u005Cu005A'}), lowercase
4.6387 + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and
4.6388 + * full width variant ({@code '\u005CuFF21'} through
4.6389 + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through
4.6390 + * {@code '\u005CuFF5A'}) forms have numeric values from 10
4.6391 + * through 35. This is independent of the Unicode specification,
4.6392 + * which does not assign numeric values to these {@code char}
4.6393 + * values.
4.6394 + * <p>
4.6395 + * If the character does not have a numeric value, then -1 is returned.
4.6396 + * If the character has a numeric value that cannot be represented as a
4.6397 + * nonnegative integer (for example, a fractional value), then -2
4.6398 + * is returned.
4.6399 + *
4.6400 + * <p><b>Note:</b> This method cannot handle <a
4.6401 + * href="#supplementary"> supplementary characters</a>. To support
4.6402 + * all Unicode characters, including supplementary characters, use
4.6403 + * the {@link #getNumericValue(int)} method.
4.6404 + *
4.6405 + * @param ch the character to be converted.
4.6406 + * @return the numeric value of the character, as a nonnegative {@code int}
4.6407 + * value; -2 if the character has a numeric value that is not a
4.6408 + * nonnegative integer; -1 if the character has no numeric value.
4.6409 + * @see Character#forDigit(int, int)
4.6410 + * @see Character#isDigit(char)
4.6411 + * @since 1.1
4.6412 + */
4.6413 + public static int getNumericValue(char ch) {
4.6414 + return getNumericValue((int)ch);
4.6415 + }
4.6416 +
4.6417 + /**
4.6418 + * Returns the {@code int} value that the specified
4.6419 + * character (Unicode code point) represents. For example, the character
4.6420 + * {@code '\u005Cu216C'} (the Roman numeral fifty) will return
4.6421 + * an {@code int} with a value of 50.
4.6422 + * <p>
4.6423 + * The letters A-Z in their uppercase ({@code '\u005Cu0041'} through
4.6424 + * {@code '\u005Cu005A'}), lowercase
4.6425 + * ({@code '\u005Cu0061'} through {@code '\u005Cu007A'}), and
4.6426 + * full width variant ({@code '\u005CuFF21'} through
4.6427 + * {@code '\u005CuFF3A'} and {@code '\u005CuFF41'} through
4.6428 + * {@code '\u005CuFF5A'}) forms have numeric values from 10
4.6429 + * through 35. This is independent of the Unicode specification,
4.6430 + * which does not assign numeric values to these {@code char}
4.6431 + * values.
4.6432 + * <p>
4.6433 + * If the character does not have a numeric value, then -1 is returned.
4.6434 + * If the character has a numeric value that cannot be represented as a
4.6435 + * nonnegative integer (for example, a fractional value), then -2
4.6436 + * is returned.
4.6437 + *
4.6438 + * @param codePoint the character (Unicode code point) to be converted.
4.6439 + * @return the numeric value of the character, as a nonnegative {@code int}
4.6440 + * value; -2 if the character has a numeric value that is not a
4.6441 + * nonnegative integer; -1 if the character has no numeric value.
4.6442 + * @see Character#forDigit(int, int)
4.6443 + * @see Character#isDigit(int)
4.6444 + * @since 1.5
4.6445 + */
4.6446 + public static int getNumericValue(int codePoint) {
4.6447 + return CharacterData.of(codePoint).getNumericValue(codePoint);
4.6448 + }
4.6449 +
4.6450 + /**
4.6451 + * Determines if the specified character is ISO-LATIN-1 white space.
4.6452 + * This method returns {@code true} for the following five
4.6453 + * characters only:
4.6454 + * <table>
4.6455 + * <tr><td>{@code '\t'}</td> <td>{@code U+0009}</td>
4.6456 + * <td>{@code HORIZONTAL TABULATION}</td></tr>
4.6457 + * <tr><td>{@code '\n'}</td> <td>{@code U+000A}</td>
4.6458 + * <td>{@code NEW LINE}</td></tr>
4.6459 + * <tr><td>{@code '\f'}</td> <td>{@code U+000C}</td>
4.6460 + * <td>{@code FORM FEED}</td></tr>
4.6461 + * <tr><td>{@code '\r'}</td> <td>{@code U+000D}</td>
4.6462 + * <td>{@code CARRIAGE RETURN}</td></tr>
4.6463 + * <tr><td>{@code ' '}</td> <td>{@code U+0020}</td>
4.6464 + * <td>{@code SPACE}</td></tr>
4.6465 + * </table>
4.6466 + *
4.6467 + * @param ch the character to be tested.
4.6468 + * @return {@code true} if the character is ISO-LATIN-1 white
4.6469 + * space; {@code false} otherwise.
4.6470 + * @see Character#isSpaceChar(char)
4.6471 + * @see Character#isWhitespace(char)
4.6472 + * @deprecated Replaced by isWhitespace(char).
4.6473 + */
4.6474 + @Deprecated
4.6475 + public static boolean isSpace(char ch) {
4.6476 + return (ch <= 0x0020) &&
4.6477 + (((((1L << 0x0009) |
4.6478 + (1L << 0x000A) |
4.6479 + (1L << 0x000C) |
4.6480 + (1L << 0x000D) |
4.6481 + (1L << 0x0020)) >> ch) & 1L) != 0);
4.6482 + }
4.6483 +
4.6484 +
4.6485 + /**
4.6486 + * Determines if the specified character is a Unicode space character.
4.6487 + * A character is considered to be a space character if and only if
4.6488 + * it is specified to be a space character by the Unicode Standard. This
4.6489 + * method returns true if the character's general category type is any of
4.6490 + * the following:
4.6491 + * <ul>
4.6492 + * <li> {@code SPACE_SEPARATOR}
4.6493 + * <li> {@code LINE_SEPARATOR}
4.6494 + * <li> {@code PARAGRAPH_SEPARATOR}
4.6495 + * </ul>
4.6496 + *
4.6497 + * <p><b>Note:</b> This method cannot handle <a
4.6498 + * href="#supplementary"> supplementary characters</a>. To support
4.6499 + * all Unicode characters, including supplementary characters, use
4.6500 + * the {@link #isSpaceChar(int)} method.
4.6501 + *
4.6502 + * @param ch the character to be tested.
4.6503 + * @return {@code true} if the character is a space character;
4.6504 + * {@code false} otherwise.
4.6505 + * @see Character#isWhitespace(char)
4.6506 + * @since 1.1
4.6507 + */
4.6508 + public static boolean isSpaceChar(char ch) {
4.6509 + return isSpaceChar((int)ch);
4.6510 + }
4.6511 +
4.6512 + /**
4.6513 + * Determines if the specified character (Unicode code point) is a
4.6514 + * Unicode space character. A character is considered to be a
4.6515 + * space character if and only if it is specified to be a space
4.6516 + * character by the Unicode Standard. This method returns true if
4.6517 + * the character's general category type is any of the following:
4.6518 + *
4.6519 + * <ul>
4.6520 + * <li> {@link #SPACE_SEPARATOR}
4.6521 + * <li> {@link #LINE_SEPARATOR}
4.6522 + * <li> {@link #PARAGRAPH_SEPARATOR}
4.6523 + * </ul>
4.6524 + *
4.6525 + * @param codePoint the character (Unicode code point) to be tested.
4.6526 + * @return {@code true} if the character is a space character;
4.6527 + * {@code false} otherwise.
4.6528 + * @see Character#isWhitespace(int)
4.6529 + * @since 1.5
4.6530 + */
4.6531 + public static boolean isSpaceChar(int codePoint) {
4.6532 + return ((((1 << Character.SPACE_SEPARATOR) |
4.6533 + (1 << Character.LINE_SEPARATOR) |
4.6534 + (1 << Character.PARAGRAPH_SEPARATOR)) >> getType(codePoint)) & 1)
4.6535 + != 0;
4.6536 + }
4.6537 +
4.6538 + /**
4.6539 + * Determines if the specified character is white space according to Java.
4.6540 + * A character is a Java whitespace character if and only if it satisfies
4.6541 + * one of the following criteria:
4.6542 + * <ul>
4.6543 + * <li> It is a Unicode space character ({@code SPACE_SEPARATOR},
4.6544 + * {@code LINE_SEPARATOR}, or {@code PARAGRAPH_SEPARATOR})
4.6545 + * but is not also a non-breaking space ({@code '\u005Cu00A0'},
4.6546 + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}).
4.6547 + * <li> It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION.
4.6548 + * <li> It is {@code '\u005Cn'}, U+000A LINE FEED.
4.6549 + * <li> It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION.
4.6550 + * <li> It is {@code '\u005Cf'}, U+000C FORM FEED.
4.6551 + * <li> It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN.
4.6552 + * <li> It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR.
4.6553 + * <li> It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR.
4.6554 + * <li> It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
4.6555 + * <li> It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
4.6556 + * </ul>
4.6557 + *
4.6558 + * <p><b>Note:</b> This method cannot handle <a
4.6559 + * href="#supplementary"> supplementary characters</a>. To support
4.6560 + * all Unicode characters, including supplementary characters, use
4.6561 + * the {@link #isWhitespace(int)} method.
4.6562 + *
4.6563 + * @param ch the character to be tested.
4.6564 + * @return {@code true} if the character is a Java whitespace
4.6565 + * character; {@code false} otherwise.
4.6566 + * @see Character#isSpaceChar(char)
4.6567 + * @since 1.1
4.6568 + */
4.6569 + public static boolean isWhitespace(char ch) {
4.6570 + return isWhitespace((int)ch);
4.6571 + }
4.6572 +
4.6573 + /**
4.6574 + * Determines if the specified character (Unicode code point) is
4.6575 + * white space according to Java. A character is a Java
4.6576 + * whitespace character if and only if it satisfies one of the
4.6577 + * following criteria:
4.6578 + * <ul>
4.6579 + * <li> It is a Unicode space character ({@link #SPACE_SEPARATOR},
4.6580 + * {@link #LINE_SEPARATOR}, or {@link #PARAGRAPH_SEPARATOR})
4.6581 + * but is not also a non-breaking space ({@code '\u005Cu00A0'},
4.6582 + * {@code '\u005Cu2007'}, {@code '\u005Cu202F'}).
4.6583 + * <li> It is {@code '\u005Ct'}, U+0009 HORIZONTAL TABULATION.
4.6584 + * <li> It is {@code '\u005Cn'}, U+000A LINE FEED.
4.6585 + * <li> It is {@code '\u005Cu000B'}, U+000B VERTICAL TABULATION.
4.6586 + * <li> It is {@code '\u005Cf'}, U+000C FORM FEED.
4.6587 + * <li> It is {@code '\u005Cr'}, U+000D CARRIAGE RETURN.
4.6588 + * <li> It is {@code '\u005Cu001C'}, U+001C FILE SEPARATOR.
4.6589 + * <li> It is {@code '\u005Cu001D'}, U+001D GROUP SEPARATOR.
4.6590 + * <li> It is {@code '\u005Cu001E'}, U+001E RECORD SEPARATOR.
4.6591 + * <li> It is {@code '\u005Cu001F'}, U+001F UNIT SEPARATOR.
4.6592 + * </ul>
4.6593 + * <p>
4.6594 + *
4.6595 + * @param codePoint the character (Unicode code point) to be tested.
4.6596 + * @return {@code true} if the character is a Java whitespace
4.6597 + * character; {@code false} otherwise.
4.6598 + * @see Character#isSpaceChar(int)
4.6599 + * @since 1.5
4.6600 + */
4.6601 + public static boolean isWhitespace(int codePoint) {
4.6602 + return CharacterData.of(codePoint).isWhitespace(codePoint);
4.6603 + }
4.6604 +
4.6605 + /**
4.6606 + * Determines if the specified character is an ISO control
4.6607 + * character. A character is considered to be an ISO control
4.6608 + * character if its code is in the range {@code '\u005Cu0000'}
4.6609 + * through {@code '\u005Cu001F'} or in the range
4.6610 + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}.
4.6611 + *
4.6612 + * <p><b>Note:</b> This method cannot handle <a
4.6613 + * href="#supplementary"> supplementary characters</a>. To support
4.6614 + * all Unicode characters, including supplementary characters, use
4.6615 + * the {@link #isISOControl(int)} method.
4.6616 + *
4.6617 + * @param ch the character to be tested.
4.6618 + * @return {@code true} if the character is an ISO control character;
4.6619 + * {@code false} otherwise.
4.6620 + *
4.6621 + * @see Character#isSpaceChar(char)
4.6622 + * @see Character#isWhitespace(char)
4.6623 + * @since 1.1
4.6624 + */
4.6625 + public static boolean isISOControl(char ch) {
4.6626 + return isISOControl((int)ch);
4.6627 + }
4.6628 +
4.6629 + /**
4.6630 + * Determines if the referenced character (Unicode code point) is an ISO control
4.6631 + * character. A character is considered to be an ISO control
4.6632 + * character if its code is in the range {@code '\u005Cu0000'}
4.6633 + * through {@code '\u005Cu001F'} or in the range
4.6634 + * {@code '\u005Cu007F'} through {@code '\u005Cu009F'}.
4.6635 + *
4.6636 + * @param codePoint the character (Unicode code point) to be tested.
4.6637 + * @return {@code true} if the character is an ISO control character;
4.6638 + * {@code false} otherwise.
4.6639 + * @see Character#isSpaceChar(int)
4.6640 + * @see Character#isWhitespace(int)
4.6641 + * @since 1.5
4.6642 + */
4.6643 + public static boolean isISOControl(int codePoint) {
4.6644 + // Optimized form of:
4.6645 + // (codePoint >= 0x00 && codePoint <= 0x1F) ||
4.6646 + // (codePoint >= 0x7F && codePoint <= 0x9F);
4.6647 + return codePoint <= 0x9F &&
4.6648 + (codePoint >= 0x7F || (codePoint >>> 5 == 0));
4.6649 + }
4.6650 +
4.6651 + /**
4.6652 + * Returns a value indicating a character's general category.
4.6653 + *
4.6654 + * <p><b>Note:</b> This method cannot handle <a
4.6655 + * href="#supplementary"> supplementary characters</a>. To support
4.6656 + * all Unicode characters, including supplementary characters, use
4.6657 + * the {@link #getType(int)} method.
4.6658 + *
4.6659 + * @param ch the character to be tested.
4.6660 + * @return a value of type {@code int} representing the
4.6661 + * character's general category.
4.6662 + * @see Character#COMBINING_SPACING_MARK
4.6663 + * @see Character#CONNECTOR_PUNCTUATION
4.6664 + * @see Character#CONTROL
4.6665 + * @see Character#CURRENCY_SYMBOL
4.6666 + * @see Character#DASH_PUNCTUATION
4.6667 + * @see Character#DECIMAL_DIGIT_NUMBER
4.6668 + * @see Character#ENCLOSING_MARK
4.6669 + * @see Character#END_PUNCTUATION
4.6670 + * @see Character#FINAL_QUOTE_PUNCTUATION
4.6671 + * @see Character#FORMAT
4.6672 + * @see Character#INITIAL_QUOTE_PUNCTUATION
4.6673 + * @see Character#LETTER_NUMBER
4.6674 + * @see Character#LINE_SEPARATOR
4.6675 + * @see Character#LOWERCASE_LETTER
4.6676 + * @see Character#MATH_SYMBOL
4.6677 + * @see Character#MODIFIER_LETTER
4.6678 + * @see Character#MODIFIER_SYMBOL
4.6679 + * @see Character#NON_SPACING_MARK
4.6680 + * @see Character#OTHER_LETTER
4.6681 + * @see Character#OTHER_NUMBER
4.6682 + * @see Character#OTHER_PUNCTUATION
4.6683 + * @see Character#OTHER_SYMBOL
4.6684 + * @see Character#PARAGRAPH_SEPARATOR
4.6685 + * @see Character#PRIVATE_USE
4.6686 + * @see Character#SPACE_SEPARATOR
4.6687 + * @see Character#START_PUNCTUATION
4.6688 + * @see Character#SURROGATE
4.6689 + * @see Character#TITLECASE_LETTER
4.6690 + * @see Character#UNASSIGNED
4.6691 + * @see Character#UPPERCASE_LETTER
4.6692 + * @since 1.1
4.6693 + */
4.6694 + public static int getType(char ch) {
4.6695 + return getType((int)ch);
4.6696 + }
4.6697 +
4.6698 + /**
4.6699 + * Returns a value indicating a character's general category.
4.6700 + *
4.6701 + * @param codePoint the character (Unicode code point) to be tested.
4.6702 + * @return a value of type {@code int} representing the
4.6703 + * character's general category.
4.6704 + * @see Character#COMBINING_SPACING_MARK COMBINING_SPACING_MARK
4.6705 + * @see Character#CONNECTOR_PUNCTUATION CONNECTOR_PUNCTUATION
4.6706 + * @see Character#CONTROL CONTROL
4.6707 + * @see Character#CURRENCY_SYMBOL CURRENCY_SYMBOL
4.6708 + * @see Character#DASH_PUNCTUATION DASH_PUNCTUATION
4.6709 + * @see Character#DECIMAL_DIGIT_NUMBER DECIMAL_DIGIT_NUMBER
4.6710 + * @see Character#ENCLOSING_MARK ENCLOSING_MARK
4.6711 + * @see Character#END_PUNCTUATION END_PUNCTUATION
4.6712 + * @see Character#FINAL_QUOTE_PUNCTUATION FINAL_QUOTE_PUNCTUATION
4.6713 + * @see Character#FORMAT FORMAT
4.6714 + * @see Character#INITIAL_QUOTE_PUNCTUATION INITIAL_QUOTE_PUNCTUATION
4.6715 + * @see Character#LETTER_NUMBER LETTER_NUMBER
4.6716 + * @see Character#LINE_SEPARATOR LINE_SEPARATOR
4.6717 + * @see Character#LOWERCASE_LETTER LOWERCASE_LETTER
4.6718 + * @see Character#MATH_SYMBOL MATH_SYMBOL
4.6719 + * @see Character#MODIFIER_LETTER MODIFIER_LETTER
4.6720 + * @see Character#MODIFIER_SYMBOL MODIFIER_SYMBOL
4.6721 + * @see Character#NON_SPACING_MARK NON_SPACING_MARK
4.6722 + * @see Character#OTHER_LETTER OTHER_LETTER
4.6723 + * @see Character#OTHER_NUMBER OTHER_NUMBER
4.6724 + * @see Character#OTHER_PUNCTUATION OTHER_PUNCTUATION
4.6725 + * @see Character#OTHER_SYMBOL OTHER_SYMBOL
4.6726 + * @see Character#PARAGRAPH_SEPARATOR PARAGRAPH_SEPARATOR
4.6727 + * @see Character#PRIVATE_USE PRIVATE_USE
4.6728 + * @see Character#SPACE_SEPARATOR SPACE_SEPARATOR
4.6729 + * @see Character#START_PUNCTUATION START_PUNCTUATION
4.6730 + * @see Character#SURROGATE SURROGATE
4.6731 + * @see Character#TITLECASE_LETTER TITLECASE_LETTER
4.6732 + * @see Character#UNASSIGNED UNASSIGNED
4.6733 + * @see Character#UPPERCASE_LETTER UPPERCASE_LETTER
4.6734 + * @since 1.5
4.6735 + */
4.6736 + public static int getType(int codePoint) {
4.6737 + return CharacterData.of(codePoint).getType(codePoint);
4.6738 + }
4.6739 +
4.6740 + /**
4.6741 + * Determines the character representation for a specific digit in
4.6742 + * the specified radix. If the value of {@code radix} is not a
4.6743 + * valid radix, or the value of {@code digit} is not a valid
4.6744 + * digit in the specified radix, the null character
4.6745 + * ({@code '\u005Cu0000'}) is returned.
4.6746 + * <p>
4.6747 + * The {@code radix} argument is valid if it is greater than or
4.6748 + * equal to {@code MIN_RADIX} and less than or equal to
4.6749 + * {@code MAX_RADIX}. The {@code digit} argument is valid if
4.6750 + * {@code 0 <= digit < radix}.
4.6751 + * <p>
4.6752 + * If the digit is less than 10, then
4.6753 + * {@code '0' + digit} is returned. Otherwise, the value
4.6754 + * {@code 'a' + digit - 10} is returned.
4.6755 + *
4.6756 + * @param digit the number to convert to a character.
4.6757 + * @param radix the radix.
4.6758 + * @return the {@code char} representation of the specified digit
4.6759 + * in the specified radix.
4.6760 + * @see Character#MIN_RADIX
4.6761 + * @see Character#MAX_RADIX
4.6762 + * @see Character#digit(char, int)
4.6763 + */
4.6764 + public static char forDigit(int digit, int radix) {
4.6765 + if ((digit >= radix) || (digit < 0)) {
4.6766 + return '\0';
4.6767 + }
4.6768 + if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) {
4.6769 + return '\0';
4.6770 + }
4.6771 + if (digit < 10) {
4.6772 + return (char)('0' + digit);
4.6773 + }
4.6774 + return (char)('a' - 10 + digit);
4.6775 + }
4.6776 +
4.6777 + /**
4.6778 + * Returns the Unicode directionality property for the given
4.6779 + * character. Character directionality is used to calculate the
4.6780 + * visual ordering of text. The directionality value of undefined
4.6781 + * {@code char} values is {@code DIRECTIONALITY_UNDEFINED}.
4.6782 + *
4.6783 + * <p><b>Note:</b> This method cannot handle <a
4.6784 + * href="#supplementary"> supplementary characters</a>. To support
4.6785 + * all Unicode characters, including supplementary characters, use
4.6786 + * the {@link #getDirectionality(int)} method.
4.6787 + *
4.6788 + * @param ch {@code char} for which the directionality property
4.6789 + * is requested.
4.6790 + * @return the directionality property of the {@code char} value.
4.6791 + *
4.6792 + * @see Character#DIRECTIONALITY_UNDEFINED
4.6793 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT
4.6794 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT
4.6795 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
4.6796 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER
4.6797 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
4.6798 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
4.6799 + * @see Character#DIRECTIONALITY_ARABIC_NUMBER
4.6800 + * @see Character#DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
4.6801 + * @see Character#DIRECTIONALITY_NONSPACING_MARK
4.6802 + * @see Character#DIRECTIONALITY_BOUNDARY_NEUTRAL
4.6803 + * @see Character#DIRECTIONALITY_PARAGRAPH_SEPARATOR
4.6804 + * @see Character#DIRECTIONALITY_SEGMENT_SEPARATOR
4.6805 + * @see Character#DIRECTIONALITY_WHITESPACE
4.6806 + * @see Character#DIRECTIONALITY_OTHER_NEUTRALS
4.6807 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
4.6808 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
4.6809 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
4.6810 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
4.6811 + * @see Character#DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
4.6812 + * @since 1.4
4.6813 + */
4.6814 + public static byte getDirectionality(char ch) {
4.6815 + return getDirectionality((int)ch);
4.6816 + }
4.6817 +
4.6818 + /**
4.6819 + * Returns the Unicode directionality property for the given
4.6820 + * character (Unicode code point). Character directionality is
4.6821 + * used to calculate the visual ordering of text. The
4.6822 + * directionality value of undefined character is {@link
4.6823 + * #DIRECTIONALITY_UNDEFINED}.
4.6824 + *
4.6825 + * @param codePoint the character (Unicode code point) for which
4.6826 + * the directionality property is requested.
4.6827 + * @return the directionality property of the character.
4.6828 + *
4.6829 + * @see Character#DIRECTIONALITY_UNDEFINED DIRECTIONALITY_UNDEFINED
4.6830 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT DIRECTIONALITY_LEFT_TO_RIGHT
4.6831 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT DIRECTIONALITY_RIGHT_TO_LEFT
4.6832 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
4.6833 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER DIRECTIONALITY_EUROPEAN_NUMBER
4.6834 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
4.6835 + * @see Character#DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR
4.6836 + * @see Character#DIRECTIONALITY_ARABIC_NUMBER DIRECTIONALITY_ARABIC_NUMBER
4.6837 + * @see Character#DIRECTIONALITY_COMMON_NUMBER_SEPARATOR DIRECTIONALITY_COMMON_NUMBER_SEPARATOR
4.6838 + * @see Character#DIRECTIONALITY_NONSPACING_MARK DIRECTIONALITY_NONSPACING_MARK
4.6839 + * @see Character#DIRECTIONALITY_BOUNDARY_NEUTRAL DIRECTIONALITY_BOUNDARY_NEUTRAL
4.6840 + * @see Character#DIRECTIONALITY_PARAGRAPH_SEPARATOR DIRECTIONALITY_PARAGRAPH_SEPARATOR
4.6841 + * @see Character#DIRECTIONALITY_SEGMENT_SEPARATOR DIRECTIONALITY_SEGMENT_SEPARATOR
4.6842 + * @see Character#DIRECTIONALITY_WHITESPACE DIRECTIONALITY_WHITESPACE
4.6843 + * @see Character#DIRECTIONALITY_OTHER_NEUTRALS DIRECTIONALITY_OTHER_NEUTRALS
4.6844 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING
4.6845 + * @see Character#DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE
4.6846 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING
4.6847 + * @see Character#DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE
4.6848 + * @see Character#DIRECTIONALITY_POP_DIRECTIONAL_FORMAT DIRECTIONALITY_POP_DIRECTIONAL_FORMAT
4.6849 + * @since 1.5
4.6850 + */
4.6851 + public static byte getDirectionality(int codePoint) {
4.6852 + return CharacterData.of(codePoint).getDirectionality(codePoint);
4.6853 + }
4.6854 +
4.6855 + /**
4.6856 + * Determines whether the character is mirrored according to the
4.6857 + * Unicode specification. Mirrored characters should have their
4.6858 + * glyphs horizontally mirrored when displayed in text that is
4.6859 + * right-to-left. For example, {@code '\u005Cu0028'} LEFT
4.6860 + * PARENTHESIS is semantically defined to be an <i>opening
4.6861 + * parenthesis</i>. This will appear as a "(" in text that is
4.6862 + * left-to-right but as a ")" in text that is right-to-left.
4.6863 + *
4.6864 + * <p><b>Note:</b> This method cannot handle <a
4.6865 + * href="#supplementary"> supplementary characters</a>. To support
4.6866 + * all Unicode characters, including supplementary characters, use
4.6867 + * the {@link #isMirrored(int)} method.
4.6868 + *
4.6869 + * @param ch {@code char} for which the mirrored property is requested
4.6870 + * @return {@code true} if the char is mirrored, {@code false}
4.6871 + * if the {@code char} is not mirrored or is not defined.
4.6872 + * @since 1.4
4.6873 + */
4.6874 + public static boolean isMirrored(char ch) {
4.6875 + return isMirrored((int)ch);
4.6876 + }
4.6877 +
4.6878 + /**
4.6879 + * Determines whether the specified character (Unicode code point)
4.6880 + * is mirrored according to the Unicode specification. Mirrored
4.6881 + * characters should have their glyphs horizontally mirrored when
4.6882 + * displayed in text that is right-to-left. For example,
4.6883 + * {@code '\u005Cu0028'} LEFT PARENTHESIS is semantically
4.6884 + * defined to be an <i>opening parenthesis</i>. This will appear
4.6885 + * as a "(" in text that is left-to-right but as a ")" in text
4.6886 + * that is right-to-left.
4.6887 + *
4.6888 + * @param codePoint the character (Unicode code point) to be tested.
4.6889 + * @return {@code true} if the character is mirrored, {@code false}
4.6890 + * if the character is not mirrored or is not defined.
4.6891 + * @since 1.5
4.6892 + */
4.6893 + public static boolean isMirrored(int codePoint) {
4.6894 + return CharacterData.of(codePoint).isMirrored(codePoint);
4.6895 + }
4.6896 +
4.6897 + /**
4.6898 + * Compares two {@code Character} objects numerically.
4.6899 + *
4.6900 + * @param anotherCharacter the {@code Character} to be compared.
4.6901 +
4.6902 + * @return the value {@code 0} if the argument {@code Character}
4.6903 + * is equal to this {@code Character}; a value less than
4.6904 + * {@code 0} if this {@code Character} is numerically less
4.6905 + * than the {@code Character} argument; and a value greater than
4.6906 + * {@code 0} if this {@code Character} is numerically greater
4.6907 + * than the {@code Character} argument (unsigned comparison).
4.6908 + * Note that this is strictly a numerical comparison; it is not
4.6909 + * locale-dependent.
4.6910 + * @since 1.2
4.6911 + */
4.6912 + public int compareTo(Character anotherCharacter) {
4.6913 + return compare(this.value, anotherCharacter.value);
4.6914 + }
4.6915 +
4.6916 + /**
4.6917 + * Compares two {@code char} values numerically.
4.6918 + * The value returned is identical to what would be returned by:
4.6919 + * <pre>
4.6920 + * Character.valueOf(x).compareTo(Character.valueOf(y))
4.6921 + * </pre>
4.6922 + *
4.6923 + * @param x the first {@code char} to compare
4.6924 + * @param y the second {@code char} to compare
4.6925 + * @return the value {@code 0} if {@code x == y};
4.6926 + * a value less than {@code 0} if {@code x < y}; and
4.6927 + * a value greater than {@code 0} if {@code x > y}
4.6928 + * @since 1.7
4.6929 + */
4.6930 + public static int compare(char x, char y) {
4.6931 + return x - y;
4.6932 + }
4.6933 +
4.6934 + /**
4.6935 + * Converts the character (Unicode code point) argument to uppercase using
4.6936 + * information from the UnicodeData file.
4.6937 + * <p>
4.6938 + *
4.6939 + * @param codePoint the character (Unicode code point) to be converted.
4.6940 + * @return either the uppercase equivalent of the character, if
4.6941 + * any, or an error flag ({@code Character.ERROR})
4.6942 + * that indicates that a 1:M {@code char} mapping exists.
4.6943 + * @see Character#isLowerCase(char)
4.6944 + * @see Character#isUpperCase(char)
4.6945 + * @see Character#toLowerCase(char)
4.6946 + * @see Character#toTitleCase(char)
4.6947 + * @since 1.4
4.6948 + */
4.6949 + static int toUpperCaseEx(int codePoint) {
4.6950 + assert isValidCodePoint(codePoint);
4.6951 + return CharacterData.of(codePoint).toUpperCaseEx(codePoint);
4.6952 + }
4.6953 +
4.6954 + /**
4.6955 + * Converts the character (Unicode code point) argument to uppercase using case
4.6956 + * mapping information from the SpecialCasing file in the Unicode
4.6957 + * specification. If a character has no explicit uppercase
4.6958 + * mapping, then the {@code char} itself is returned in the
4.6959 + * {@code char[]}.
4.6960 + *
4.6961 + * @param codePoint the character (Unicode code point) to be converted.
4.6962 + * @return a {@code char[]} with the uppercased character.
4.6963 + * @since 1.4
4.6964 + */
4.6965 + static char[] toUpperCaseCharArray(int codePoint) {
4.6966 + // As of Unicode 6.0, 1:M uppercasings only happen in the BMP.
4.6967 + assert isBmpCodePoint(codePoint);
4.6968 + return CharacterData.of(codePoint).toUpperCaseCharArray(codePoint);
4.6969 + }
4.6970 +
4.6971 + /**
4.6972 + * The number of bits used to represent a <tt>char</tt> value in unsigned
4.6973 + * binary form, constant {@code 16}.
4.6974 + *
4.6975 + * @since 1.5
4.6976 + */
4.6977 + public static final int SIZE = 16;
4.6978 +
4.6979 + /**
4.6980 + * Returns the value obtained by reversing the order of the bytes in the
4.6981 + * specified <tt>char</tt> value.
4.6982 + *
4.6983 + * @return the value obtained by reversing (or, equivalently, swapping)
4.6984 + * the bytes in the specified <tt>char</tt> value.
4.6985 + * @since 1.5
4.6986 + */
4.6987 + public static char reverseBytes(char ch) {
4.6988 + return (char) (((ch & 0xFF00) >> 8) | (ch << 8));
4.6989 + }
4.6990 +
4.6991 + /**
4.6992 + * Returns the Unicode name of the specified character
4.6993 + * {@code codePoint}, or null if the code point is
4.6994 + * {@link #UNASSIGNED unassigned}.
4.6995 + * <p>
4.6996 + * Note: if the specified character is not assigned a name by
4.6997 + * the <i>UnicodeData</i> file (part of the Unicode Character
4.6998 + * Database maintained by the Unicode Consortium), the returned
4.6999 + * name is the same as the result of expression.
4.7000 + *
4.7001 + * <blockquote>{@code
4.7002 + * Character.UnicodeBlock.of(codePoint).toString().replace('_', ' ')
4.7003 + * + " "
4.7004 + * + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
4.7005 + *
4.7006 + * }</blockquote>
4.7007 + *
4.7008 + * @param codePoint the character (Unicode code point)
4.7009 + *
4.7010 + * @return the Unicode name of the specified character, or null if
4.7011 + * the code point is unassigned.
4.7012 + *
4.7013 + * @exception IllegalArgumentException if the specified
4.7014 + * {@code codePoint} is not a valid Unicode
4.7015 + * code point.
4.7016 + *
4.7017 + * @since 1.7
4.7018 + */
4.7019 + public static String getName(int codePoint) {
4.7020 + if (!isValidCodePoint(codePoint)) {
4.7021 + throw new IllegalArgumentException();
4.7022 + }
4.7023 + String name = CharacterName.get(codePoint);
4.7024 + if (name != null)
4.7025 + return name;
4.7026 + if (getType(codePoint) == UNASSIGNED)
4.7027 + return null;
4.7028 + UnicodeBlock block = UnicodeBlock.of(codePoint);
4.7029 + if (block != null)
4.7030 + return block.toString().replace('_', ' ') + " "
4.7031 + + Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
4.7032 + // should never come here
4.7033 + return Integer.toHexString(codePoint).toUpperCase(Locale.ENGLISH);
4.7034 + }
4.7035 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/emul/src/main/java/java/lang/ClassCastException.java Sun Sep 30 14:37:39 2012 -0700
5.3 @@ -0,0 +1,60 @@
5.4 +/*
5.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5.7 + *
5.8 + * This code is free software; you can redistribute it and/or modify it
5.9 + * under the terms of the GNU General Public License version 2 only, as
5.10 + * published by the Free Software Foundation. Oracle designates this
5.11 + * particular file as subject to the "Classpath" exception as provided
5.12 + * by Oracle in the LICENSE file that accompanied this code.
5.13 + *
5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5.17 + * version 2 for more details (a copy is included in the LICENSE file that
5.18 + * accompanied this code).
5.19 + *
5.20 + * You should have received a copy of the GNU General Public License version
5.21 + * 2 along with this work; if not, write to the Free Software Foundation,
5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5.23 + *
5.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5.25 + * or visit www.oracle.com if you need additional information or have any
5.26 + * questions.
5.27 + */
5.28 +
5.29 +package java.lang;
5.30 +
5.31 +/**
5.32 + * Thrown to indicate that the code has attempted to cast an object
5.33 + * to a subclass of which it is not an instance. For example, the
5.34 + * following code generates a <code>ClassCastException</code>:
5.35 + * <p><blockquote><pre>
5.36 + * Object x = new Integer(0);
5.37 + * System.out.println((String)x);
5.38 + * </pre></blockquote>
5.39 + *
5.40 + * @author unascribed
5.41 + * @since JDK1.0
5.42 + */
5.43 +public
5.44 +class ClassCastException extends RuntimeException {
5.45 + private static final long serialVersionUID = -9223365651070458532L;
5.46 +
5.47 + /**
5.48 + * Constructs a <code>ClassCastException</code> with no detail message.
5.49 + */
5.50 + public ClassCastException() {
5.51 + super();
5.52 + }
5.53 +
5.54 + /**
5.55 + * Constructs a <code>ClassCastException</code> with the specified
5.56 + * detail message.
5.57 + *
5.58 + * @param s the detail message.
5.59 + */
5.60 + public ClassCastException(String s) {
5.61 + super(s);
5.62 + }
5.63 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/emul/src/main/java/java/lang/ClassNotFoundException.java Sun Sep 30 14:37:39 2012 -0700
6.3 @@ -0,0 +1,125 @@
6.4 +/*
6.5 + * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6.7 + *
6.8 + * This code is free software; you can redistribute it and/or modify it
6.9 + * under the terms of the GNU General Public License version 2 only, as
6.10 + * published by the Free Software Foundation. Oracle designates this
6.11 + * particular file as subject to the "Classpath" exception as provided
6.12 + * by Oracle in the LICENSE file that accompanied this code.
6.13 + *
6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6.17 + * version 2 for more details (a copy is included in the LICENSE file that
6.18 + * accompanied this code).
6.19 + *
6.20 + * You should have received a copy of the GNU General Public License version
6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6.23 + *
6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6.25 + * or visit www.oracle.com if you need additional information or have any
6.26 + * questions.
6.27 + */
6.28 +
6.29 +package java.lang;
6.30 +
6.31 +/**
6.32 + * Thrown when an application tries to load in a class through its
6.33 + * string name using:
6.34 + * <ul>
6.35 + * <li>The <code>forName</code> method in class <code>Class</code>.
6.36 + * <li>The <code>findSystemClass</code> method in class
6.37 + * <code>ClassLoader</code> .
6.38 + * <li>The <code>loadClass</code> method in class <code>ClassLoader</code>.
6.39 + * </ul>
6.40 + * <p>
6.41 + * but no definition for the class with the specified name could be found.
6.42 + *
6.43 + * <p>As of release 1.4, this exception has been retrofitted to conform to
6.44 + * the general purpose exception-chaining mechanism. The "optional exception
6.45 + * that was raised while loading the class" that may be provided at
6.46 + * construction time and accessed via the {@link #getException()} method is
6.47 + * now known as the <i>cause</i>, and may be accessed via the {@link
6.48 + * Throwable#getCause()} method, as well as the aforementioned "legacy method."
6.49 + *
6.50 + * @author unascribed
6.51 + * @see java.lang.Class#forName(java.lang.String)
6.52 + * @see java.lang.ClassLoader#findSystemClass(java.lang.String)
6.53 + * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
6.54 + * @since JDK1.0
6.55 + */
6.56 +public class ClassNotFoundException extends ReflectiveOperationException {
6.57 + /**
6.58 + * use serialVersionUID from JDK 1.1.X for interoperability
6.59 + */
6.60 + private static final long serialVersionUID = 9176873029745254542L;
6.61 +
6.62 + /**
6.63 + * This field holds the exception ex if the
6.64 + * ClassNotFoundException(String s, Throwable ex) constructor was
6.65 + * used to instantiate the object
6.66 + * @serial
6.67 + * @since 1.2
6.68 + */
6.69 + private Throwable ex;
6.70 +
6.71 + /**
6.72 + * Constructs a <code>ClassNotFoundException</code> with no detail message.
6.73 + */
6.74 + public ClassNotFoundException() {
6.75 + super((Throwable)null); // Disallow initCause
6.76 + }
6.77 +
6.78 + /**
6.79 + * Constructs a <code>ClassNotFoundException</code> with the
6.80 + * specified detail message.
6.81 + *
6.82 + * @param s the detail message.
6.83 + */
6.84 + public ClassNotFoundException(String s) {
6.85 + super(s, null); // Disallow initCause
6.86 + }
6.87 +
6.88 + /**
6.89 + * Constructs a <code>ClassNotFoundException</code> with the
6.90 + * specified detail message and optional exception that was
6.91 + * raised while loading the class.
6.92 + *
6.93 + * @param s the detail message
6.94 + * @param ex the exception that was raised while loading the class
6.95 + * @since 1.2
6.96 + */
6.97 + public ClassNotFoundException(String s, Throwable ex) {
6.98 + super(s, null); // Disallow initCause
6.99 + this.ex = ex;
6.100 + }
6.101 +
6.102 + /**
6.103 + * Returns the exception that was raised if an error occurred while
6.104 + * attempting to load the class. Otherwise, returns <tt>null</tt>.
6.105 + *
6.106 + * <p>This method predates the general-purpose exception chaining facility.
6.107 + * The {@link Throwable#getCause()} method is now the preferred means of
6.108 + * obtaining this information.
6.109 + *
6.110 + * @return the <code>Exception</code> that was raised while loading a class
6.111 + * @since 1.2
6.112 + */
6.113 + public Throwable getException() {
6.114 + return ex;
6.115 + }
6.116 +
6.117 + /**
6.118 + * Returns the cause of this exception (the exception that was raised
6.119 + * if an error occurred while attempting to load the class; otherwise
6.120 + * <tt>null</tt>).
6.121 + *
6.122 + * @return the cause of this exception.
6.123 + * @since 1.4
6.124 + */
6.125 + public Throwable getCause() {
6.126 + return ex;
6.127 + }
6.128 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/emul/src/main/java/java/lang/Double.java Sun Sep 30 14:37:39 2012 -0700
7.3 @@ -0,0 +1,988 @@
7.4 +/*
7.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7.7 + *
7.8 + * This code is free software; you can redistribute it and/or modify it
7.9 + * under the terms of the GNU General Public License version 2 only, as
7.10 + * published by the Free Software Foundation. Oracle designates this
7.11 + * particular file as subject to the "Classpath" exception as provided
7.12 + * by Oracle in the LICENSE file that accompanied this code.
7.13 + *
7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7.17 + * version 2 for more details (a copy is included in the LICENSE file that
7.18 + * accompanied this code).
7.19 + *
7.20 + * You should have received a copy of the GNU General Public License version
7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7.23 + *
7.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7.25 + * or visit www.oracle.com if you need additional information or have any
7.26 + * questions.
7.27 + */
7.28 +
7.29 +package java.lang;
7.30 +
7.31 +import sun.misc.FloatingDecimal;
7.32 +import sun.misc.FpUtils;
7.33 +import sun.misc.DoubleConsts;
7.34 +
7.35 +/**
7.36 + * The {@code Double} class wraps a value of the primitive type
7.37 + * {@code double} in an object. An object of type
7.38 + * {@code Double} contains a single field whose type is
7.39 + * {@code double}.
7.40 + *
7.41 + * <p>In addition, this class provides several methods for converting a
7.42 + * {@code double} to a {@code String} and a
7.43 + * {@code String} to a {@code double}, as well as other
7.44 + * constants and methods useful when dealing with a
7.45 + * {@code double}.
7.46 + *
7.47 + * @author Lee Boynton
7.48 + * @author Arthur van Hoff
7.49 + * @author Joseph D. Darcy
7.50 + * @since JDK1.0
7.51 + */
7.52 +public final class Double extends Number implements Comparable<Double> {
7.53 + /**
7.54 + * A constant holding the positive infinity of type
7.55 + * {@code double}. It is equal to the value returned by
7.56 + * {@code Double.longBitsToDouble(0x7ff0000000000000L)}.
7.57 + */
7.58 + public static final double POSITIVE_INFINITY = 1.0 / 0.0;
7.59 +
7.60 + /**
7.61 + * A constant holding the negative infinity of type
7.62 + * {@code double}. It is equal to the value returned by
7.63 + * {@code Double.longBitsToDouble(0xfff0000000000000L)}.
7.64 + */
7.65 + public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
7.66 +
7.67 + /**
7.68 + * A constant holding a Not-a-Number (NaN) value of type
7.69 + * {@code double}. It is equivalent to the value returned by
7.70 + * {@code Double.longBitsToDouble(0x7ff8000000000000L)}.
7.71 + */
7.72 + public static final double NaN = 0.0d / 0.0;
7.73 +
7.74 + /**
7.75 + * A constant holding the largest positive finite value of type
7.76 + * {@code double},
7.77 + * (2-2<sup>-52</sup>)·2<sup>1023</sup>. It is equal to
7.78 + * the hexadecimal floating-point literal
7.79 + * {@code 0x1.fffffffffffffP+1023} and also equal to
7.80 + * {@code Double.longBitsToDouble(0x7fefffffffffffffL)}.
7.81 + */
7.82 + public static final double MAX_VALUE = 0x1.fffffffffffffP+1023; // 1.7976931348623157e+308
7.83 +
7.84 + /**
7.85 + * A constant holding the smallest positive normal value of type
7.86 + * {@code double}, 2<sup>-1022</sup>. It is equal to the
7.87 + * hexadecimal floating-point literal {@code 0x1.0p-1022} and also
7.88 + * equal to {@code Double.longBitsToDouble(0x0010000000000000L)}.
7.89 + *
7.90 + * @since 1.6
7.91 + */
7.92 + public static final double MIN_NORMAL = 0x1.0p-1022; // 2.2250738585072014E-308
7.93 +
7.94 + /**
7.95 + * A constant holding the smallest positive nonzero value of type
7.96 + * {@code double}, 2<sup>-1074</sup>. It is equal to the
7.97 + * hexadecimal floating-point literal
7.98 + * {@code 0x0.0000000000001P-1022} and also equal to
7.99 + * {@code Double.longBitsToDouble(0x1L)}.
7.100 + */
7.101 + public static final double MIN_VALUE = 0x0.0000000000001P-1022; // 4.9e-324
7.102 +
7.103 + /**
7.104 + * Maximum exponent a finite {@code double} variable may have.
7.105 + * It is equal to the value returned by
7.106 + * {@code Math.getExponent(Double.MAX_VALUE)}.
7.107 + *
7.108 + * @since 1.6
7.109 + */
7.110 + public static final int MAX_EXPONENT = 1023;
7.111 +
7.112 + /**
7.113 + * Minimum exponent a normalized {@code double} variable may
7.114 + * have. It is equal to the value returned by
7.115 + * {@code Math.getExponent(Double.MIN_NORMAL)}.
7.116 + *
7.117 + * @since 1.6
7.118 + */
7.119 + public static final int MIN_EXPONENT = -1022;
7.120 +
7.121 + /**
7.122 + * The number of bits used to represent a {@code double} value.
7.123 + *
7.124 + * @since 1.5
7.125 + */
7.126 + public static final int SIZE = 64;
7.127 +
7.128 + /**
7.129 + * The {@code Class} instance representing the primitive type
7.130 + * {@code double}.
7.131 + *
7.132 + * @since JDK1.1
7.133 + */
7.134 + public static final Class<Double> TYPE = (Class<Double>) Class.getPrimitiveClass("double");
7.135 +
7.136 + /**
7.137 + * Returns a string representation of the {@code double}
7.138 + * argument. All characters mentioned below are ASCII characters.
7.139 + * <ul>
7.140 + * <li>If the argument is NaN, the result is the string
7.141 + * "{@code NaN}".
7.142 + * <li>Otherwise, the result is a string that represents the sign and
7.143 + * magnitude (absolute value) of the argument. If the sign is negative,
7.144 + * the first character of the result is '{@code -}'
7.145 + * (<code>'\u002D'</code>); if the sign is positive, no sign character
7.146 + * appears in the result. As for the magnitude <i>m</i>:
7.147 + * <ul>
7.148 + * <li>If <i>m</i> is infinity, it is represented by the characters
7.149 + * {@code "Infinity"}; thus, positive infinity produces the result
7.150 + * {@code "Infinity"} and negative infinity produces the result
7.151 + * {@code "-Infinity"}.
7.152 + *
7.153 + * <li>If <i>m</i> is zero, it is represented by the characters
7.154 + * {@code "0.0"}; thus, negative zero produces the result
7.155 + * {@code "-0.0"} and positive zero produces the result
7.156 + * {@code "0.0"}.
7.157 + *
7.158 + * <li>If <i>m</i> is greater than or equal to 10<sup>-3</sup> but less
7.159 + * than 10<sup>7</sup>, then it is represented as the integer part of
7.160 + * <i>m</i>, in decimal form with no leading zeroes, followed by
7.161 + * '{@code .}' (<code>'\u002E'</code>), followed by one or
7.162 + * more decimal digits representing the fractional part of <i>m</i>.
7.163 + *
7.164 + * <li>If <i>m</i> is less than 10<sup>-3</sup> or greater than or
7.165 + * equal to 10<sup>7</sup>, then it is represented in so-called
7.166 + * "computerized scientific notation." Let <i>n</i> be the unique
7.167 + * integer such that 10<sup><i>n</i></sup> ≤ <i>m</i> {@literal <}
7.168 + * 10<sup><i>n</i>+1</sup>; then let <i>a</i> be the
7.169 + * mathematically exact quotient of <i>m</i> and
7.170 + * 10<sup><i>n</i></sup> so that 1 ≤ <i>a</i> {@literal <} 10. The
7.171 + * magnitude is then represented as the integer part of <i>a</i>,
7.172 + * as a single decimal digit, followed by '{@code .}'
7.173 + * (<code>'\u002E'</code>), followed by decimal digits
7.174 + * representing the fractional part of <i>a</i>, followed by the
7.175 + * letter '{@code E}' (<code>'\u0045'</code>), followed
7.176 + * by a representation of <i>n</i> as a decimal integer, as
7.177 + * produced by the method {@link Integer#toString(int)}.
7.178 + * </ul>
7.179 + * </ul>
7.180 + * How many digits must be printed for the fractional part of
7.181 + * <i>m</i> or <i>a</i>? There must be at least one digit to represent
7.182 + * the fractional part, and beyond that as many, but only as many, more
7.183 + * digits as are needed to uniquely distinguish the argument value from
7.184 + * adjacent values of type {@code double}. That is, suppose that
7.185 + * <i>x</i> is the exact mathematical value represented by the decimal
7.186 + * representation produced by this method for a finite nonzero argument
7.187 + * <i>d</i>. Then <i>d</i> must be the {@code double} value nearest
7.188 + * to <i>x</i>; or if two {@code double} values are equally close
7.189 + * to <i>x</i>, then <i>d</i> must be one of them and the least
7.190 + * significant bit of the significand of <i>d</i> must be {@code 0}.
7.191 + *
7.192 + * <p>To create localized string representations of a floating-point
7.193 + * value, use subclasses of {@link java.text.NumberFormat}.
7.194 + *
7.195 + * @param d the {@code double} to be converted.
7.196 + * @return a string representation of the argument.
7.197 + */
7.198 + public static String toString(double d) {
7.199 + return new FloatingDecimal(d).toJavaFormatString();
7.200 + }
7.201 +
7.202 + /**
7.203 + * Returns a hexadecimal string representation of the
7.204 + * {@code double} argument. All characters mentioned below
7.205 + * are ASCII characters.
7.206 + *
7.207 + * <ul>
7.208 + * <li>If the argument is NaN, the result is the string
7.209 + * "{@code NaN}".
7.210 + * <li>Otherwise, the result is a string that represents the sign
7.211 + * and magnitude of the argument. If the sign is negative, the
7.212 + * first character of the result is '{@code -}'
7.213 + * (<code>'\u002D'</code>); if the sign is positive, no sign
7.214 + * character appears in the result. As for the magnitude <i>m</i>:
7.215 + *
7.216 + * <ul>
7.217 + * <li>If <i>m</i> is infinity, it is represented by the string
7.218 + * {@code "Infinity"}; thus, positive infinity produces the
7.219 + * result {@code "Infinity"} and negative infinity produces
7.220 + * the result {@code "-Infinity"}.
7.221 + *
7.222 + * <li>If <i>m</i> is zero, it is represented by the string
7.223 + * {@code "0x0.0p0"}; thus, negative zero produces the result
7.224 + * {@code "-0x0.0p0"} and positive zero produces the result
7.225 + * {@code "0x0.0p0"}.
7.226 + *
7.227 + * <li>If <i>m</i> is a {@code double} value with a
7.228 + * normalized representation, substrings are used to represent the
7.229 + * significand and exponent fields. The significand is
7.230 + * represented by the characters {@code "0x1."}
7.231 + * followed by a lowercase hexadecimal representation of the rest
7.232 + * of the significand as a fraction. Trailing zeros in the
7.233 + * hexadecimal representation are removed unless all the digits
7.234 + * are zero, in which case a single zero is used. Next, the
7.235 + * exponent is represented by {@code "p"} followed
7.236 + * by a decimal string of the unbiased exponent as if produced by
7.237 + * a call to {@link Integer#toString(int) Integer.toString} on the
7.238 + * exponent value.
7.239 + *
7.240 + * <li>If <i>m</i> is a {@code double} value with a subnormal
7.241 + * representation, the significand is represented by the
7.242 + * characters {@code "0x0."} followed by a
7.243 + * hexadecimal representation of the rest of the significand as a
7.244 + * fraction. Trailing zeros in the hexadecimal representation are
7.245 + * removed. Next, the exponent is represented by
7.246 + * {@code "p-1022"}. Note that there must be at
7.247 + * least one nonzero digit in a subnormal significand.
7.248 + *
7.249 + * </ul>
7.250 + *
7.251 + * </ul>
7.252 + *
7.253 + * <table border>
7.254 + * <caption><h3>Examples</h3></caption>
7.255 + * <tr><th>Floating-point Value</th><th>Hexadecimal String</th>
7.256 + * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td>
7.257 + * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td>
7.258 + * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td>
7.259 + * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td>
7.260 + * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td>
7.261 + * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td>
7.262 + * <tr><td>{@code Double.MAX_VALUE}</td>
7.263 + * <td>{@code 0x1.fffffffffffffp1023}</td>
7.264 + * <tr><td>{@code Minimum Normal Value}</td>
7.265 + * <td>{@code 0x1.0p-1022}</td>
7.266 + * <tr><td>{@code Maximum Subnormal Value}</td>
7.267 + * <td>{@code 0x0.fffffffffffffp-1022}</td>
7.268 + * <tr><td>{@code Double.MIN_VALUE}</td>
7.269 + * <td>{@code 0x0.0000000000001p-1022}</td>
7.270 + * </table>
7.271 + * @param d the {@code double} to be converted.
7.272 + * @return a hex string representation of the argument.
7.273 + * @since 1.5
7.274 + * @author Joseph D. Darcy
7.275 + */
7.276 + public static String toHexString(double d) {
7.277 + /*
7.278 + * Modeled after the "a" conversion specifier in C99, section
7.279 + * 7.19.6.1; however, the output of this method is more
7.280 + * tightly specified.
7.281 + */
7.282 + if (!FpUtils.isFinite(d) )
7.283 + // For infinity and NaN, use the decimal output.
7.284 + return Double.toString(d);
7.285 + else {
7.286 + // Initialized to maximum size of output.
7.287 + StringBuffer answer = new StringBuffer(24);
7.288 +
7.289 + if (FpUtils.rawCopySign(1.0, d) == -1.0) // value is negative,
7.290 + answer.append("-"); // so append sign info
7.291 +
7.292 + answer.append("0x");
7.293 +
7.294 + d = Math.abs(d);
7.295 +
7.296 + if(d == 0.0) {
7.297 + answer.append("0.0p0");
7.298 + }
7.299 + else {
7.300 + boolean subnormal = (d < DoubleConsts.MIN_NORMAL);
7.301 +
7.302 + // Isolate significand bits and OR in a high-order bit
7.303 + // so that the string representation has a known
7.304 + // length.
7.305 + long signifBits = (Double.doubleToLongBits(d)
7.306 + & DoubleConsts.SIGNIF_BIT_MASK) |
7.307 + 0x1000000000000000L;
7.308 +
7.309 + // Subnormal values have a 0 implicit bit; normal
7.310 + // values have a 1 implicit bit.
7.311 + answer.append(subnormal ? "0." : "1.");
7.312 +
7.313 + // Isolate the low-order 13 digits of the hex
7.314 + // representation. If all the digits are zero,
7.315 + // replace with a single 0; otherwise, remove all
7.316 + // trailing zeros.
7.317 + String signif = Long.toHexString(signifBits).substring(3,16);
7.318 + answer.append(signif.equals("0000000000000") ? // 13 zeros
7.319 + "0":
7.320 + signif.replaceFirst("0{1,12}$", ""));
7.321 +
7.322 + // If the value is subnormal, use the E_min exponent
7.323 + // value for double; otherwise, extract and report d's
7.324 + // exponent (the representation of a subnormal uses
7.325 + // E_min -1).
7.326 + answer.append("p" + (subnormal ?
7.327 + DoubleConsts.MIN_EXPONENT:
7.328 + FpUtils.getExponent(d) ));
7.329 + }
7.330 + return answer.toString();
7.331 + }
7.332 + }
7.333 +
7.334 + /**
7.335 + * Returns a {@code Double} object holding the
7.336 + * {@code double} value represented by the argument string
7.337 + * {@code s}.
7.338 + *
7.339 + * <p>If {@code s} is {@code null}, then a
7.340 + * {@code NullPointerException} is thrown.
7.341 + *
7.342 + * <p>Leading and trailing whitespace characters in {@code s}
7.343 + * are ignored. Whitespace is removed as if by the {@link
7.344 + * String#trim} method; that is, both ASCII space and control
7.345 + * characters are removed. The rest of {@code s} should
7.346 + * constitute a <i>FloatValue</i> as described by the lexical
7.347 + * syntax rules:
7.348 + *
7.349 + * <blockquote>
7.350 + * <dl>
7.351 + * <dt><i>FloatValue:</i>
7.352 + * <dd><i>Sign<sub>opt</sub></i> {@code NaN}
7.353 + * <dd><i>Sign<sub>opt</sub></i> {@code Infinity}
7.354 + * <dd><i>Sign<sub>opt</sub> FloatingPointLiteral</i>
7.355 + * <dd><i>Sign<sub>opt</sub> HexFloatingPointLiteral</i>
7.356 + * <dd><i>SignedInteger</i>
7.357 + * </dl>
7.358 + *
7.359 + * <p>
7.360 + *
7.361 + * <dl>
7.362 + * <dt><i>HexFloatingPointLiteral</i>:
7.363 + * <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
7.364 + * </dl>
7.365 + *
7.366 + * <p>
7.367 + *
7.368 + * <dl>
7.369 + * <dt><i>HexSignificand:</i>
7.370 + * <dd><i>HexNumeral</i>
7.371 + * <dd><i>HexNumeral</i> {@code .}
7.372 + * <dd>{@code 0x} <i>HexDigits<sub>opt</sub>
7.373 + * </i>{@code .}<i> HexDigits</i>
7.374 + * <dd>{@code 0X}<i> HexDigits<sub>opt</sub>
7.375 + * </i>{@code .} <i>HexDigits</i>
7.376 + * </dl>
7.377 + *
7.378 + * <p>
7.379 + *
7.380 + * <dl>
7.381 + * <dt><i>BinaryExponent:</i>
7.382 + * <dd><i>BinaryExponentIndicator SignedInteger</i>
7.383 + * </dl>
7.384 + *
7.385 + * <p>
7.386 + *
7.387 + * <dl>
7.388 + * <dt><i>BinaryExponentIndicator:</i>
7.389 + * <dd>{@code p}
7.390 + * <dd>{@code P}
7.391 + * </dl>
7.392 + *
7.393 + * </blockquote>
7.394 + *
7.395 + * where <i>Sign</i>, <i>FloatingPointLiteral</i>,
7.396 + * <i>HexNumeral</i>, <i>HexDigits</i>, <i>SignedInteger</i> and
7.397 + * <i>FloatTypeSuffix</i> are as defined in the lexical structure
7.398 + * sections of
7.399 + * <cite>The Java™ Language Specification</cite>,
7.400 + * except that underscores are not accepted between digits.
7.401 + * If {@code s} does not have the form of
7.402 + * a <i>FloatValue</i>, then a {@code NumberFormatException}
7.403 + * is thrown. Otherwise, {@code s} is regarded as
7.404 + * representing an exact decimal value in the usual
7.405 + * "computerized scientific notation" or as an exact
7.406 + * hexadecimal value; this exact numerical value is then
7.407 + * conceptually converted to an "infinitely precise"
7.408 + * binary value that is then rounded to type {@code double}
7.409 + * by the usual round-to-nearest rule of IEEE 754 floating-point
7.410 + * arithmetic, which includes preserving the sign of a zero
7.411 + * value.
7.412 + *
7.413 + * Note that the round-to-nearest rule also implies overflow and
7.414 + * underflow behaviour; if the exact value of {@code s} is large
7.415 + * enough in magnitude (greater than or equal to ({@link
7.416 + * #MAX_VALUE} + {@link Math#ulp(double) ulp(MAX_VALUE)}/2),
7.417 + * rounding to {@code double} will result in an infinity and if the
7.418 + * exact value of {@code s} is small enough in magnitude (less
7.419 + * than or equal to {@link #MIN_VALUE}/2), rounding to float will
7.420 + * result in a zero.
7.421 + *
7.422 + * Finally, after rounding a {@code Double} object representing
7.423 + * this {@code double} value is returned.
7.424 + *
7.425 + * <p> To interpret localized string representations of a
7.426 + * floating-point value, use subclasses of {@link
7.427 + * java.text.NumberFormat}.
7.428 + *
7.429 + * <p>Note that trailing format specifiers, specifiers that
7.430 + * determine the type of a floating-point literal
7.431 + * ({@code 1.0f} is a {@code float} value;
7.432 + * {@code 1.0d} is a {@code double} value), do
7.433 + * <em>not</em> influence the results of this method. In other
7.434 + * words, the numerical value of the input string is converted
7.435 + * directly to the target floating-point type. The two-step
7.436 + * sequence of conversions, string to {@code float} followed
7.437 + * by {@code float} to {@code double}, is <em>not</em>
7.438 + * equivalent to converting a string directly to
7.439 + * {@code double}. For example, the {@code float}
7.440 + * literal {@code 0.1f} is equal to the {@code double}
7.441 + * value {@code 0.10000000149011612}; the {@code float}
7.442 + * literal {@code 0.1f} represents a different numerical
7.443 + * value than the {@code double} literal
7.444 + * {@code 0.1}. (The numerical value 0.1 cannot be exactly
7.445 + * represented in a binary floating-point number.)
7.446 + *
7.447 + * <p>To avoid calling this method on an invalid string and having
7.448 + * a {@code NumberFormatException} be thrown, the regular
7.449 + * expression below can be used to screen the input string:
7.450 + *
7.451 + * <code>
7.452 + * <pre>
7.453 + * final String Digits = "(\\p{Digit}+)";
7.454 + * final String HexDigits = "(\\p{XDigit}+)";
7.455 + * // an exponent is 'e' or 'E' followed by an optionally
7.456 + * // signed decimal integer.
7.457 + * final String Exp = "[eE][+-]?"+Digits;
7.458 + * final String fpRegex =
7.459 + * ("[\\x00-\\x20]*"+ // Optional leading "whitespace"
7.460 + * "[+-]?(" + // Optional sign character
7.461 + * "NaN|" + // "NaN" string
7.462 + * "Infinity|" + // "Infinity" string
7.463 + *
7.464 + * // A decimal floating-point string representing a finite positive
7.465 + * // number without a leading sign has at most five basic pieces:
7.466 + * // Digits . Digits ExponentPart FloatTypeSuffix
7.467 + * //
7.468 + * // Since this method allows integer-only strings as input
7.469 + * // in addition to strings of floating-point literals, the
7.470 + * // two sub-patterns below are simplifications of the grammar
7.471 + * // productions from section 3.10.2 of
7.472 + * // <cite>The Java™ Language Specification</cite>.
7.473 + *
7.474 + * // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
7.475 + * "((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
7.476 + *
7.477 + * // . Digits ExponentPart_opt FloatTypeSuffix_opt
7.478 + * "(\\.("+Digits+")("+Exp+")?)|"+
7.479 + *
7.480 + * // Hexadecimal strings
7.481 + * "((" +
7.482 + * // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
7.483 + * "(0[xX]" + HexDigits + "(\\.)?)|" +
7.484 + *
7.485 + * // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
7.486 + * "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
7.487 + *
7.488 + * ")[pP][+-]?" + Digits + "))" +
7.489 + * "[fFdD]?))" +
7.490 + * "[\\x00-\\x20]*");// Optional trailing "whitespace"
7.491 + *
7.492 + * if (Pattern.matches(fpRegex, myString))
7.493 + * Double.valueOf(myString); // Will not throw NumberFormatException
7.494 + * else {
7.495 + * // Perform suitable alternative action
7.496 + * }
7.497 + * </pre>
7.498 + * </code>
7.499 + *
7.500 + * @param s the string to be parsed.
7.501 + * @return a {@code Double} object holding the value
7.502 + * represented by the {@code String} argument.
7.503 + * @throws NumberFormatException if the string does not contain a
7.504 + * parsable number.
7.505 + */
7.506 + public static Double valueOf(String s) throws NumberFormatException {
7.507 + return new Double(FloatingDecimal.readJavaFormatString(s).doubleValue());
7.508 + }
7.509 +
7.510 + /**
7.511 + * Returns a {@code Double} instance representing the specified
7.512 + * {@code double} value.
7.513 + * If a new {@code Double} instance is not required, this method
7.514 + * should generally be used in preference to the constructor
7.515 + * {@link #Double(double)}, as this method is likely to yield
7.516 + * significantly better space and time performance by caching
7.517 + * frequently requested values.
7.518 + *
7.519 + * @param d a double value.
7.520 + * @return a {@code Double} instance representing {@code d}.
7.521 + * @since 1.5
7.522 + */
7.523 + public static Double valueOf(double d) {
7.524 + return new Double(d);
7.525 + }
7.526 +
7.527 + /**
7.528 + * Returns a new {@code double} initialized to the value
7.529 + * represented by the specified {@code String}, as performed
7.530 + * by the {@code valueOf} method of class
7.531 + * {@code Double}.
7.532 + *
7.533 + * @param s the string to be parsed.
7.534 + * @return the {@code double} value represented by the string
7.535 + * argument.
7.536 + * @throws NullPointerException if the string is null
7.537 + * @throws NumberFormatException if the string does not contain
7.538 + * a parsable {@code double}.
7.539 + * @see java.lang.Double#valueOf(String)
7.540 + * @since 1.2
7.541 + */
7.542 + public static double parseDouble(String s) throws NumberFormatException {
7.543 + return FloatingDecimal.readJavaFormatString(s).doubleValue();
7.544 + }
7.545 +
7.546 + /**
7.547 + * Returns {@code true} if the specified number is a
7.548 + * Not-a-Number (NaN) value, {@code false} otherwise.
7.549 + *
7.550 + * @param v the value to be tested.
7.551 + * @return {@code true} if the value of the argument is NaN;
7.552 + * {@code false} otherwise.
7.553 + */
7.554 + static public boolean isNaN(double v) {
7.555 + return (v != v);
7.556 + }
7.557 +
7.558 + /**
7.559 + * Returns {@code true} if the specified number is infinitely
7.560 + * large in magnitude, {@code false} otherwise.
7.561 + *
7.562 + * @param v the value to be tested.
7.563 + * @return {@code true} if the value of the argument is positive
7.564 + * infinity or negative infinity; {@code false} otherwise.
7.565 + */
7.566 + static public boolean isInfinite(double v) {
7.567 + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
7.568 + }
7.569 +
7.570 + /**
7.571 + * The value of the Double.
7.572 + *
7.573 + * @serial
7.574 + */
7.575 + private final double value;
7.576 +
7.577 + /**
7.578 + * Constructs a newly allocated {@code Double} object that
7.579 + * represents the primitive {@code double} argument.
7.580 + *
7.581 + * @param value the value to be represented by the {@code Double}.
7.582 + */
7.583 + public Double(double value) {
7.584 + this.value = value;
7.585 + }
7.586 +
7.587 + /**
7.588 + * Constructs a newly allocated {@code Double} object that
7.589 + * represents the floating-point value of type {@code double}
7.590 + * represented by the string. The string is converted to a
7.591 + * {@code double} value as if by the {@code valueOf} method.
7.592 + *
7.593 + * @param s a string to be converted to a {@code Double}.
7.594 + * @throws NumberFormatException if the string does not contain a
7.595 + * parsable number.
7.596 + * @see java.lang.Double#valueOf(java.lang.String)
7.597 + */
7.598 + public Double(String s) throws NumberFormatException {
7.599 + // REMIND: this is inefficient
7.600 + this(valueOf(s).doubleValue());
7.601 + }
7.602 +
7.603 + /**
7.604 + * Returns {@code true} if this {@code Double} value is
7.605 + * a Not-a-Number (NaN), {@code false} otherwise.
7.606 + *
7.607 + * @return {@code true} if the value represented by this object is
7.608 + * NaN; {@code false} otherwise.
7.609 + */
7.610 + public boolean isNaN() {
7.611 + return isNaN(value);
7.612 + }
7.613 +
7.614 + /**
7.615 + * Returns {@code true} if this {@code Double} value is
7.616 + * infinitely large in magnitude, {@code false} otherwise.
7.617 + *
7.618 + * @return {@code true} if the value represented by this object is
7.619 + * positive infinity or negative infinity;
7.620 + * {@code false} otherwise.
7.621 + */
7.622 + public boolean isInfinite() {
7.623 + return isInfinite(value);
7.624 + }
7.625 +
7.626 + /**
7.627 + * Returns a string representation of this {@code Double} object.
7.628 + * The primitive {@code double} value represented by this
7.629 + * object is converted to a string exactly as if by the method
7.630 + * {@code toString} of one argument.
7.631 + *
7.632 + * @return a {@code String} representation of this object.
7.633 + * @see java.lang.Double#toString(double)
7.634 + */
7.635 + public String toString() {
7.636 + return toString(value);
7.637 + }
7.638 +
7.639 + /**
7.640 + * Returns the value of this {@code Double} as a {@code byte} (by
7.641 + * casting to a {@code byte}).
7.642 + *
7.643 + * @return the {@code double} value represented by this object
7.644 + * converted to type {@code byte}
7.645 + * @since JDK1.1
7.646 + */
7.647 + public byte byteValue() {
7.648 + return (byte)value;
7.649 + }
7.650 +
7.651 + /**
7.652 + * Returns the value of this {@code Double} as a
7.653 + * {@code short} (by casting to a {@code short}).
7.654 + *
7.655 + * @return the {@code double} value represented by this object
7.656 + * converted to type {@code short}
7.657 + * @since JDK1.1
7.658 + */
7.659 + public short shortValue() {
7.660 + return (short)value;
7.661 + }
7.662 +
7.663 + /**
7.664 + * Returns the value of this {@code Double} as an
7.665 + * {@code int} (by casting to type {@code int}).
7.666 + *
7.667 + * @return the {@code double} value represented by this object
7.668 + * converted to type {@code int}
7.669 + */
7.670 + public int intValue() {
7.671 + return (int)value;
7.672 + }
7.673 +
7.674 + /**
7.675 + * Returns the value of this {@code Double} as a
7.676 + * {@code long} (by casting to type {@code long}).
7.677 + *
7.678 + * @return the {@code double} value represented by this object
7.679 + * converted to type {@code long}
7.680 + */
7.681 + public long longValue() {
7.682 + return (long)value;
7.683 + }
7.684 +
7.685 + /**
7.686 + * Returns the {@code float} value of this
7.687 + * {@code Double} object.
7.688 + *
7.689 + * @return the {@code double} value represented by this object
7.690 + * converted to type {@code float}
7.691 + * @since JDK1.0
7.692 + */
7.693 + public float floatValue() {
7.694 + return (float)value;
7.695 + }
7.696 +
7.697 + /**
7.698 + * Returns the {@code double} value of this
7.699 + * {@code Double} object.
7.700 + *
7.701 + * @return the {@code double} value represented by this object
7.702 + */
7.703 + public double doubleValue() {
7.704 + return (double)value;
7.705 + }
7.706 +
7.707 + /**
7.708 + * Returns a hash code for this {@code Double} object. The
7.709 + * result is the exclusive OR of the two halves of the
7.710 + * {@code long} integer bit representation, exactly as
7.711 + * produced by the method {@link #doubleToLongBits(double)}, of
7.712 + * the primitive {@code double} value represented by this
7.713 + * {@code Double} object. That is, the hash code is the value
7.714 + * of the expression:
7.715 + *
7.716 + * <blockquote>
7.717 + * {@code (int)(v^(v>>>32))}
7.718 + * </blockquote>
7.719 + *
7.720 + * where {@code v} is defined by:
7.721 + *
7.722 + * <blockquote>
7.723 + * {@code long v = Double.doubleToLongBits(this.doubleValue());}
7.724 + * </blockquote>
7.725 + *
7.726 + * @return a {@code hash code} value for this object.
7.727 + */
7.728 + public int hashCode() {
7.729 + long bits = doubleToLongBits(value);
7.730 + return (int)(bits ^ (bits >>> 32));
7.731 + }
7.732 +
7.733 + /**
7.734 + * Compares this object against the specified object. The result
7.735 + * is {@code true} if and only if the argument is not
7.736 + * {@code null} and is a {@code Double} object that
7.737 + * represents a {@code double} that has the same value as the
7.738 + * {@code double} represented by this object. For this
7.739 + * purpose, two {@code double} values are considered to be
7.740 + * the same if and only if the method {@link
7.741 + * #doubleToLongBits(double)} returns the identical
7.742 + * {@code long} value when applied to each.
7.743 + *
7.744 + * <p>Note that in most cases, for two instances of class
7.745 + * {@code Double}, {@code d1} and {@code d2}, the
7.746 + * value of {@code d1.equals(d2)} is {@code true} if and
7.747 + * only if
7.748 + *
7.749 + * <blockquote>
7.750 + * {@code d1.doubleValue() == d2.doubleValue()}
7.751 + * </blockquote>
7.752 + *
7.753 + * <p>also has the value {@code true}. However, there are two
7.754 + * exceptions:
7.755 + * <ul>
7.756 + * <li>If {@code d1} and {@code d2} both represent
7.757 + * {@code Double.NaN}, then the {@code equals} method
7.758 + * returns {@code true}, even though
7.759 + * {@code Double.NaN==Double.NaN} has the value
7.760 + * {@code false}.
7.761 + * <li>If {@code d1} represents {@code +0.0} while
7.762 + * {@code d2} represents {@code -0.0}, or vice versa,
7.763 + * the {@code equal} test has the value {@code false},
7.764 + * even though {@code +0.0==-0.0} has the value {@code true}.
7.765 + * </ul>
7.766 + * This definition allows hash tables to operate properly.
7.767 + * @param obj the object to compare with.
7.768 + * @return {@code true} if the objects are the same;
7.769 + * {@code false} otherwise.
7.770 + * @see java.lang.Double#doubleToLongBits(double)
7.771 + */
7.772 + public boolean equals(Object obj) {
7.773 + return (obj instanceof Double)
7.774 + && (doubleToLongBits(((Double)obj).value) ==
7.775 + doubleToLongBits(value));
7.776 + }
7.777 +
7.778 + /**
7.779 + * Returns a representation of the specified floating-point value
7.780 + * according to the IEEE 754 floating-point "double
7.781 + * format" bit layout.
7.782 + *
7.783 + * <p>Bit 63 (the bit that is selected by the mask
7.784 + * {@code 0x8000000000000000L}) represents the sign of the
7.785 + * floating-point number. Bits
7.786 + * 62-52 (the bits that are selected by the mask
7.787 + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
7.788 + * (the bits that are selected by the mask
7.789 + * {@code 0x000fffffffffffffL}) represent the significand
7.790 + * (sometimes called the mantissa) of the floating-point number.
7.791 + *
7.792 + * <p>If the argument is positive infinity, the result is
7.793 + * {@code 0x7ff0000000000000L}.
7.794 + *
7.795 + * <p>If the argument is negative infinity, the result is
7.796 + * {@code 0xfff0000000000000L}.
7.797 + *
7.798 + * <p>If the argument is NaN, the result is
7.799 + * {@code 0x7ff8000000000000L}.
7.800 + *
7.801 + * <p>In all cases, the result is a {@code long} integer that, when
7.802 + * given to the {@link #longBitsToDouble(long)} method, will produce a
7.803 + * floating-point value the same as the argument to
7.804 + * {@code doubleToLongBits} (except all NaN values are
7.805 + * collapsed to a single "canonical" NaN value).
7.806 + *
7.807 + * @param value a {@code double} precision floating-point number.
7.808 + * @return the bits that represent the floating-point number.
7.809 + */
7.810 + public static long doubleToLongBits(double value) {
7.811 + long result = doubleToRawLongBits(value);
7.812 + // Check for NaN based on values of bit fields, maximum
7.813 + // exponent and nonzero significand.
7.814 + if ( ((result & DoubleConsts.EXP_BIT_MASK) ==
7.815 + DoubleConsts.EXP_BIT_MASK) &&
7.816 + (result & DoubleConsts.SIGNIF_BIT_MASK) != 0L)
7.817 + result = 0x7ff8000000000000L;
7.818 + return result;
7.819 + }
7.820 +
7.821 + /**
7.822 + * Returns a representation of the specified floating-point value
7.823 + * according to the IEEE 754 floating-point "double
7.824 + * format" bit layout, preserving Not-a-Number (NaN) values.
7.825 + *
7.826 + * <p>Bit 63 (the bit that is selected by the mask
7.827 + * {@code 0x8000000000000000L}) represents the sign of the
7.828 + * floating-point number. Bits
7.829 + * 62-52 (the bits that are selected by the mask
7.830 + * {@code 0x7ff0000000000000L}) represent the exponent. Bits 51-0
7.831 + * (the bits that are selected by the mask
7.832 + * {@code 0x000fffffffffffffL}) represent the significand
7.833 + * (sometimes called the mantissa) of the floating-point number.
7.834 + *
7.835 + * <p>If the argument is positive infinity, the result is
7.836 + * {@code 0x7ff0000000000000L}.
7.837 + *
7.838 + * <p>If the argument is negative infinity, the result is
7.839 + * {@code 0xfff0000000000000L}.
7.840 + *
7.841 + * <p>If the argument is NaN, the result is the {@code long}
7.842 + * integer representing the actual NaN value. Unlike the
7.843 + * {@code doubleToLongBits} method,
7.844 + * {@code doubleToRawLongBits} does not collapse all the bit
7.845 + * patterns encoding a NaN to a single "canonical" NaN
7.846 + * value.
7.847 + *
7.848 + * <p>In all cases, the result is a {@code long} integer that,
7.849 + * when given to the {@link #longBitsToDouble(long)} method, will
7.850 + * produce a floating-point value the same as the argument to
7.851 + * {@code doubleToRawLongBits}.
7.852 + *
7.853 + * @param value a {@code double} precision floating-point number.
7.854 + * @return the bits that represent the floating-point number.
7.855 + * @since 1.3
7.856 + */
7.857 + public static native long doubleToRawLongBits(double value);
7.858 +
7.859 + /**
7.860 + * Returns the {@code double} value corresponding to a given
7.861 + * bit representation.
7.862 + * The argument is considered to be a representation of a
7.863 + * floating-point value according to the IEEE 754 floating-point
7.864 + * "double format" bit layout.
7.865 + *
7.866 + * <p>If the argument is {@code 0x7ff0000000000000L}, the result
7.867 + * is positive infinity.
7.868 + *
7.869 + * <p>If the argument is {@code 0xfff0000000000000L}, the result
7.870 + * is negative infinity.
7.871 + *
7.872 + * <p>If the argument is any value in the range
7.873 + * {@code 0x7ff0000000000001L} through
7.874 + * {@code 0x7fffffffffffffffL} or in the range
7.875 + * {@code 0xfff0000000000001L} through
7.876 + * {@code 0xffffffffffffffffL}, the result is a NaN. No IEEE
7.877 + * 754 floating-point operation provided by Java can distinguish
7.878 + * between two NaN values of the same type with different bit
7.879 + * patterns. Distinct values of NaN are only distinguishable by
7.880 + * use of the {@code Double.doubleToRawLongBits} method.
7.881 + *
7.882 + * <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
7.883 + * values that can be computed from the argument:
7.884 + *
7.885 + * <blockquote><pre>
7.886 + * int s = ((bits >> 63) == 0) ? 1 : -1;
7.887 + * int e = (int)((bits >> 52) & 0x7ffL);
7.888 + * long m = (e == 0) ?
7.889 + * (bits & 0xfffffffffffffL) << 1 :
7.890 + * (bits & 0xfffffffffffffL) | 0x10000000000000L;
7.891 + * </pre></blockquote>
7.892 + *
7.893 + * Then the floating-point result equals the value of the mathematical
7.894 + * expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-1075</sup>.
7.895 + *
7.896 + * <p>Note that this method may not be able to return a
7.897 + * {@code double} NaN with exactly same bit pattern as the
7.898 + * {@code long} argument. IEEE 754 distinguishes between two
7.899 + * kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The
7.900 + * differences between the two kinds of NaN are generally not
7.901 + * visible in Java. Arithmetic operations on signaling NaNs turn
7.902 + * them into quiet NaNs with a different, but often similar, bit
7.903 + * pattern. However, on some processors merely copying a
7.904 + * signaling NaN also performs that conversion. In particular,
7.905 + * copying a signaling NaN to return it to the calling method
7.906 + * may perform this conversion. So {@code longBitsToDouble}
7.907 + * may not be able to return a {@code double} with a
7.908 + * signaling NaN bit pattern. Consequently, for some
7.909 + * {@code long} values,
7.910 + * {@code doubleToRawLongBits(longBitsToDouble(start))} may
7.911 + * <i>not</i> equal {@code start}. Moreover, which
7.912 + * particular bit patterns represent signaling NaNs is platform
7.913 + * dependent; although all NaN bit patterns, quiet or signaling,
7.914 + * must be in the NaN range identified above.
7.915 + *
7.916 + * @param bits any {@code long} integer.
7.917 + * @return the {@code double} floating-point value with the same
7.918 + * bit pattern.
7.919 + */
7.920 + public static native double longBitsToDouble(long bits);
7.921 +
7.922 + /**
7.923 + * Compares two {@code Double} objects numerically. There
7.924 + * are two ways in which comparisons performed by this method
7.925 + * differ from those performed by the Java language numerical
7.926 + * comparison operators ({@code <, <=, ==, >=, >})
7.927 + * when applied to primitive {@code double} values:
7.928 + * <ul><li>
7.929 + * {@code Double.NaN} is considered by this method
7.930 + * to be equal to itself and greater than all other
7.931 + * {@code double} values (including
7.932 + * {@code Double.POSITIVE_INFINITY}).
7.933 + * <li>
7.934 + * {@code 0.0d} is considered by this method to be greater
7.935 + * than {@code -0.0d}.
7.936 + * </ul>
7.937 + * This ensures that the <i>natural ordering</i> of
7.938 + * {@code Double} objects imposed by this method is <i>consistent
7.939 + * with equals</i>.
7.940 + *
7.941 + * @param anotherDouble the {@code Double} to be compared.
7.942 + * @return the value {@code 0} if {@code anotherDouble} is
7.943 + * numerically equal to this {@code Double}; a value
7.944 + * less than {@code 0} if this {@code Double}
7.945 + * is numerically less than {@code anotherDouble};
7.946 + * and a value greater than {@code 0} if this
7.947 + * {@code Double} is numerically greater than
7.948 + * {@code anotherDouble}.
7.949 + *
7.950 + * @since 1.2
7.951 + */
7.952 + public int compareTo(Double anotherDouble) {
7.953 + return Double.compare(value, anotherDouble.value);
7.954 + }
7.955 +
7.956 + /**
7.957 + * Compares the two specified {@code double} values. The sign
7.958 + * of the integer value returned is the same as that of the
7.959 + * integer that would be returned by the call:
7.960 + * <pre>
7.961 + * new Double(d1).compareTo(new Double(d2))
7.962 + * </pre>
7.963 + *
7.964 + * @param d1 the first {@code double} to compare
7.965 + * @param d2 the second {@code double} to compare
7.966 + * @return the value {@code 0} if {@code d1} is
7.967 + * numerically equal to {@code d2}; a value less than
7.968 + * {@code 0} if {@code d1} is numerically less than
7.969 + * {@code d2}; and a value greater than {@code 0}
7.970 + * if {@code d1} is numerically greater than
7.971 + * {@code d2}.
7.972 + * @since 1.4
7.973 + */
7.974 + public static int compare(double d1, double d2) {
7.975 + if (d1 < d2)
7.976 + return -1; // Neither val is NaN, thisVal is smaller
7.977 + if (d1 > d2)
7.978 + return 1; // Neither val is NaN, thisVal is larger
7.979 +
7.980 + // Cannot use doubleToRawLongBits because of possibility of NaNs.
7.981 + long thisBits = Double.doubleToLongBits(d1);
7.982 + long anotherBits = Double.doubleToLongBits(d2);
7.983 +
7.984 + return (thisBits == anotherBits ? 0 : // Values are equal
7.985 + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
7.986 + 1)); // (0.0, -0.0) or (NaN, !NaN)
7.987 + }
7.988 +
7.989 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
7.990 + private static final long serialVersionUID = -9172774392245257468L;
7.991 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/emul/src/main/java/java/lang/Enum.java Sun Sep 30 14:37:39 2012 -0700
8.3 @@ -0,0 +1,256 @@
8.4 +/*
8.5 + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8.7 + *
8.8 + * This code is free software; you can redistribute it and/or modify it
8.9 + * under the terms of the GNU General Public License version 2 only, as
8.10 + * published by the Free Software Foundation. Oracle designates this
8.11 + * particular file as subject to the "Classpath" exception as provided
8.12 + * by Oracle in the LICENSE file that accompanied this code.
8.13 + *
8.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
8.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8.17 + * version 2 for more details (a copy is included in the LICENSE file that
8.18 + * accompanied this code).
8.19 + *
8.20 + * You should have received a copy of the GNU General Public License version
8.21 + * 2 along with this work; if not, write to the Free Software Foundation,
8.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8.23 + *
8.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8.25 + * or visit www.oracle.com if you need additional information or have any
8.26 + * questions.
8.27 + */
8.28 +
8.29 +package java.lang;
8.30 +
8.31 +import java.io.Serializable;
8.32 +import java.io.IOException;
8.33 +import java.io.InvalidObjectException;
8.34 +import java.io.ObjectInputStream;
8.35 +import java.io.ObjectStreamException;
8.36 +
8.37 +/**
8.38 + * This is the common base class of all Java language enumeration types.
8.39 + *
8.40 + * More information about enums, including descriptions of the
8.41 + * implicitly declared methods synthesized by the compiler, can be
8.42 + * found in section 8.9 of
8.43 + * <cite>The Java™ Language Specification</cite>.
8.44 + *
8.45 + * <p> Note that when using an enumeration type as the type of a set
8.46 + * or as the type of the keys in a map, specialized and efficient
8.47 + * {@linkplain java.util.EnumSet set} and {@linkplain
8.48 + * java.util.EnumMap map} implementations are available.
8.49 + *
8.50 + * @param <E> The enum type subclass
8.51 + * @author Josh Bloch
8.52 + * @author Neal Gafter
8.53 + * @see Class#getEnumConstants()
8.54 + * @see java.util.EnumSet
8.55 + * @see java.util.EnumMap
8.56 + * @since 1.5
8.57 + */
8.58 +public abstract class Enum<E extends Enum<E>>
8.59 + implements Comparable<E>, Serializable {
8.60 + /**
8.61 + * The name of this enum constant, as declared in the enum declaration.
8.62 + * Most programmers should use the {@link #toString} method rather than
8.63 + * accessing this field.
8.64 + */
8.65 + private final String name;
8.66 +
8.67 + /**
8.68 + * Returns the name of this enum constant, exactly as declared in its
8.69 + * enum declaration.
8.70 + *
8.71 + * <b>Most programmers should use the {@link #toString} method in
8.72 + * preference to this one, as the toString method may return
8.73 + * a more user-friendly name.</b> This method is designed primarily for
8.74 + * use in specialized situations where correctness depends on getting the
8.75 + * exact name, which will not vary from release to release.
8.76 + *
8.77 + * @return the name of this enum constant
8.78 + */
8.79 + public final String name() {
8.80 + return name;
8.81 + }
8.82 +
8.83 + /**
8.84 + * The ordinal of this enumeration constant (its position
8.85 + * in the enum declaration, where the initial constant is assigned
8.86 + * an ordinal of zero).
8.87 + *
8.88 + * Most programmers will have no use for this field. It is designed
8.89 + * for use by sophisticated enum-based data structures, such as
8.90 + * {@link java.util.EnumSet} and {@link java.util.EnumMap}.
8.91 + */
8.92 + private final int ordinal;
8.93 +
8.94 + /**
8.95 + * Returns the ordinal of this enumeration constant (its position
8.96 + * in its enum declaration, where the initial constant is assigned
8.97 + * an ordinal of zero).
8.98 + *
8.99 + * Most programmers will have no use for this method. It is
8.100 + * designed for use by sophisticated enum-based data structures, such
8.101 + * as {@link java.util.EnumSet} and {@link java.util.EnumMap}.
8.102 + *
8.103 + * @return the ordinal of this enumeration constant
8.104 + */
8.105 + public final int ordinal() {
8.106 + return ordinal;
8.107 + }
8.108 +
8.109 + /**
8.110 + * Sole constructor. Programmers cannot invoke this constructor.
8.111 + * It is for use by code emitted by the compiler in response to
8.112 + * enum type declarations.
8.113 + *
8.114 + * @param name - The name of this enum constant, which is the identifier
8.115 + * used to declare it.
8.116 + * @param ordinal - The ordinal of this enumeration constant (its position
8.117 + * in the enum declaration, where the initial constant is assigned
8.118 + * an ordinal of zero).
8.119 + */
8.120 + protected Enum(String name, int ordinal) {
8.121 + this.name = name;
8.122 + this.ordinal = ordinal;
8.123 + }
8.124 +
8.125 + /**
8.126 + * Returns the name of this enum constant, as contained in the
8.127 + * declaration. This method may be overridden, though it typically
8.128 + * isn't necessary or desirable. An enum type should override this
8.129 + * method when a more "programmer-friendly" string form exists.
8.130 + *
8.131 + * @return the name of this enum constant
8.132 + */
8.133 + public String toString() {
8.134 + return name;
8.135 + }
8.136 +
8.137 + /**
8.138 + * Returns true if the specified object is equal to this
8.139 + * enum constant.
8.140 + *
8.141 + * @param other the object to be compared for equality with this object.
8.142 + * @return true if the specified object is equal to this
8.143 + * enum constant.
8.144 + */
8.145 + public final boolean equals(Object other) {
8.146 + return this==other;
8.147 + }
8.148 +
8.149 + /**
8.150 + * Returns a hash code for this enum constant.
8.151 + *
8.152 + * @return a hash code for this enum constant.
8.153 + */
8.154 + public final int hashCode() {
8.155 + return super.hashCode();
8.156 + }
8.157 +
8.158 + /**
8.159 + * Throws CloneNotSupportedException. This guarantees that enums
8.160 + * are never cloned, which is necessary to preserve their "singleton"
8.161 + * status.
8.162 + *
8.163 + * @return (never returns)
8.164 + */
8.165 + protected final Object clone() throws CloneNotSupportedException {
8.166 + throw new CloneNotSupportedException();
8.167 + }
8.168 +
8.169 + /**
8.170 + * Compares this enum with the specified object for order. Returns a
8.171 + * negative integer, zero, or a positive integer as this object is less
8.172 + * than, equal to, or greater than the specified object.
8.173 + *
8.174 + * Enum constants are only comparable to other enum constants of the
8.175 + * same enum type. The natural order implemented by this
8.176 + * method is the order in which the constants are declared.
8.177 + */
8.178 + public final int compareTo(E o) {
8.179 + Enum other = (Enum)o;
8.180 + Enum self = this;
8.181 + if (self.getClass() != other.getClass() && // optimization
8.182 + self.getDeclaringClass() != other.getDeclaringClass())
8.183 + throw new ClassCastException();
8.184 + return self.ordinal - other.ordinal;
8.185 + }
8.186 +
8.187 + /**
8.188 + * Returns the Class object corresponding to this enum constant's
8.189 + * enum type. Two enum constants e1 and e2 are of the
8.190 + * same enum type if and only if
8.191 + * e1.getDeclaringClass() == e2.getDeclaringClass().
8.192 + * (The value returned by this method may differ from the one returned
8.193 + * by the {@link Object#getClass} method for enum constants with
8.194 + * constant-specific class bodies.)
8.195 + *
8.196 + * @return the Class object corresponding to this enum constant's
8.197 + * enum type
8.198 + */
8.199 + public final Class<E> getDeclaringClass() {
8.200 + Class clazz = getClass();
8.201 + Class zuper = clazz.getSuperclass();
8.202 + return (zuper == Enum.class) ? clazz : zuper;
8.203 + }
8.204 +
8.205 + /**
8.206 + * Returns the enum constant of the specified enum type with the
8.207 + * specified name. The name must match exactly an identifier used
8.208 + * to declare an enum constant in this type. (Extraneous whitespace
8.209 + * characters are not permitted.)
8.210 + *
8.211 + * <p>Note that for a particular enum type {@code T}, the
8.212 + * implicitly declared {@code public static T valueOf(String)}
8.213 + * method on that enum may be used instead of this method to map
8.214 + * from a name to the corresponding enum constant. All the
8.215 + * constants of an enum type can be obtained by calling the
8.216 + * implicit {@code public static T[] values()} method of that
8.217 + * type.
8.218 + *
8.219 + * @param <T> The enum type whose constant is to be returned
8.220 + * @param enumType the {@code Class} object of the enum type from which
8.221 + * to return a constant
8.222 + * @param name the name of the constant to return
8.223 + * @return the enum constant of the specified enum type with the
8.224 + * specified name
8.225 + * @throws IllegalArgumentException if the specified enum type has
8.226 + * no constant with the specified name, or the specified
8.227 + * class object does not represent an enum type
8.228 + * @throws NullPointerException if {@code enumType} or {@code name}
8.229 + * is null
8.230 + * @since 1.5
8.231 + */
8.232 + public static <T extends Enum<T>> T valueOf(Class<T> enumType,
8.233 + String name) {
8.234 + T result = enumType.enumConstantDirectory().get(name);
8.235 + if (result != null)
8.236 + return result;
8.237 + if (name == null)
8.238 + throw new NullPointerException("Name is null");
8.239 + throw new IllegalArgumentException(
8.240 + "No enum constant " + enumType.getCanonicalName() + "." + name);
8.241 + }
8.242 +
8.243 + /**
8.244 + * enum classes cannot have finalize methods.
8.245 + */
8.246 + protected final void finalize() { }
8.247 +
8.248 + /**
8.249 + * prevent default deserialization
8.250 + */
8.251 + private void readObject(ObjectInputStream in) throws IOException,
8.252 + ClassNotFoundException {
8.253 + throw new InvalidObjectException("can't deserialize enum");
8.254 + }
8.255 +
8.256 + private void readObjectNoData() throws ObjectStreamException {
8.257 + throw new InvalidObjectException("can't deserialize enum");
8.258 + }
8.259 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/emul/src/main/java/java/lang/Error.java Sun Sep 30 14:37:39 2012 -0700
9.3 @@ -0,0 +1,128 @@
9.4 +/*
9.5 + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9.7 + *
9.8 + * This code is free software; you can redistribute it and/or modify it
9.9 + * under the terms of the GNU General Public License version 2 only, as
9.10 + * published by the Free Software Foundation. Oracle designates this
9.11 + * particular file as subject to the "Classpath" exception as provided
9.12 + * by Oracle in the LICENSE file that accompanied this code.
9.13 + *
9.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
9.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9.17 + * version 2 for more details (a copy is included in the LICENSE file that
9.18 + * accompanied this code).
9.19 + *
9.20 + * You should have received a copy of the GNU General Public License version
9.21 + * 2 along with this work; if not, write to the Free Software Foundation,
9.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9.23 + *
9.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9.25 + * or visit www.oracle.com if you need additional information or have any
9.26 + * questions.
9.27 + */
9.28 +
9.29 +package java.lang;
9.30 +
9.31 +/**
9.32 + * An {@code Error} is a subclass of {@code Throwable}
9.33 + * that indicates serious problems that a reasonable application
9.34 + * should not try to catch. Most such errors are abnormal conditions.
9.35 + * The {@code ThreadDeath} error, though a "normal" condition,
9.36 + * is also a subclass of {@code Error} because most applications
9.37 + * should not try to catch it.
9.38 + * <p>
9.39 + * A method is not required to declare in its {@code throws}
9.40 + * clause any subclasses of {@code Error} that might be thrown
9.41 + * during the execution of the method but not caught, since these
9.42 + * errors are abnormal conditions that should never occur.
9.43 + *
9.44 + * That is, {@code Error} and its subclasses are regarded as unchecked
9.45 + * exceptions for the purposes of compile-time checking of exceptions.
9.46 + *
9.47 + * @author Frank Yellin
9.48 + * @see java.lang.ThreadDeath
9.49 + * @jls 11.2 Compile-Time Checking of Exceptions
9.50 + * @since JDK1.0
9.51 + */
9.52 +public class Error extends Throwable {
9.53 + static final long serialVersionUID = 4980196508277280342L;
9.54 +
9.55 + /**
9.56 + * Constructs a new error with {@code null} as its detail message.
9.57 + * The cause is not initialized, and may subsequently be initialized by a
9.58 + * call to {@link #initCause}.
9.59 + */
9.60 + public Error() {
9.61 + super();
9.62 + }
9.63 +
9.64 + /**
9.65 + * Constructs a new error with the specified detail message. The
9.66 + * cause is not initialized, and may subsequently be initialized by
9.67 + * a call to {@link #initCause}.
9.68 + *
9.69 + * @param message the detail message. The detail message is saved for
9.70 + * later retrieval by the {@link #getMessage()} method.
9.71 + */
9.72 + public Error(String message) {
9.73 + super(message);
9.74 + }
9.75 +
9.76 + /**
9.77 + * Constructs a new error with the specified detail message and
9.78 + * cause. <p>Note that the detail message associated with
9.79 + * {@code cause} is <i>not</i> automatically incorporated in
9.80 + * this error's detail message.
9.81 + *
9.82 + * @param message the detail message (which is saved for later retrieval
9.83 + * by the {@link #getMessage()} method).
9.84 + * @param cause the cause (which is saved for later retrieval by the
9.85 + * {@link #getCause()} method). (A {@code null} value is
9.86 + * permitted, and indicates that the cause is nonexistent or
9.87 + * unknown.)
9.88 + * @since 1.4
9.89 + */
9.90 + public Error(String message, Throwable cause) {
9.91 + super(message, cause);
9.92 + }
9.93 +
9.94 + /**
9.95 + * Constructs a new error with the specified cause and a detail
9.96 + * message of {@code (cause==null ? null : cause.toString())} (which
9.97 + * typically contains the class and detail message of {@code cause}).
9.98 + * This constructor is useful for errors that are little more than
9.99 + * wrappers for other throwables.
9.100 + *
9.101 + * @param cause the cause (which is saved for later retrieval by the
9.102 + * {@link #getCause()} method). (A {@code null} value is
9.103 + * permitted, and indicates that the cause is nonexistent or
9.104 + * unknown.)
9.105 + * @since 1.4
9.106 + */
9.107 + public Error(Throwable cause) {
9.108 + super(cause);
9.109 + }
9.110 +
9.111 + /**
9.112 + * Constructs a new error with the specified detail message,
9.113 + * cause, suppression enabled or disabled, and writable stack
9.114 + * trace enabled or disabled.
9.115 + *
9.116 + * @param message the detail message.
9.117 + * @param cause the cause. (A {@code null} value is permitted,
9.118 + * and indicates that the cause is nonexistent or unknown.)
9.119 + * @param enableSuppression whether or not suppression is enabled
9.120 + * or disabled
9.121 + * @param writableStackTrace whether or not the stack trace should
9.122 + * be writable
9.123 + *
9.124 + * @since 1.7
9.125 + */
9.126 + protected Error(String message, Throwable cause,
9.127 + boolean enableSuppression,
9.128 + boolean writableStackTrace) {
9.129 + super(message, cause, enableSuppression, writableStackTrace);
9.130 + }
9.131 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/emul/src/main/java/java/lang/Float.java Sun Sep 30 14:37:39 2012 -0700
10.3 @@ -0,0 +1,892 @@
10.4 +/*
10.5 + * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10.7 + *
10.8 + * This code is free software; you can redistribute it and/or modify it
10.9 + * under the terms of the GNU General Public License version 2 only, as
10.10 + * published by the Free Software Foundation. Oracle designates this
10.11 + * particular file as subject to the "Classpath" exception as provided
10.12 + * by Oracle in the LICENSE file that accompanied this code.
10.13 + *
10.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
10.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
10.17 + * version 2 for more details (a copy is included in the LICENSE file that
10.18 + * accompanied this code).
10.19 + *
10.20 + * You should have received a copy of the GNU General Public License version
10.21 + * 2 along with this work; if not, write to the Free Software Foundation,
10.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10.23 + *
10.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
10.25 + * or visit www.oracle.com if you need additional information or have any
10.26 + * questions.
10.27 + */
10.28 +
10.29 +package java.lang;
10.30 +
10.31 +import sun.misc.FloatingDecimal;
10.32 +import sun.misc.FpUtils;
10.33 +import sun.misc.FloatConsts;
10.34 +import sun.misc.DoubleConsts;
10.35 +
10.36 +/**
10.37 + * The {@code Float} class wraps a value of primitive type
10.38 + * {@code float} in an object. An object of type
10.39 + * {@code Float} contains a single field whose type is
10.40 + * {@code float}.
10.41 + *
10.42 + * <p>In addition, this class provides several methods for converting a
10.43 + * {@code float} to a {@code String} and a
10.44 + * {@code String} to a {@code float}, as well as other
10.45 + * constants and methods useful when dealing with a
10.46 + * {@code float}.
10.47 + *
10.48 + * @author Lee Boynton
10.49 + * @author Arthur van Hoff
10.50 + * @author Joseph D. Darcy
10.51 + * @since JDK1.0
10.52 + */
10.53 +public final class Float extends Number implements Comparable<Float> {
10.54 + /**
10.55 + * A constant holding the positive infinity of type
10.56 + * {@code float}. It is equal to the value returned by
10.57 + * {@code Float.intBitsToFloat(0x7f800000)}.
10.58 + */
10.59 + public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
10.60 +
10.61 + /**
10.62 + * A constant holding the negative infinity of type
10.63 + * {@code float}. It is equal to the value returned by
10.64 + * {@code Float.intBitsToFloat(0xff800000)}.
10.65 + */
10.66 + public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
10.67 +
10.68 + /**
10.69 + * A constant holding a Not-a-Number (NaN) value of type
10.70 + * {@code float}. It is equivalent to the value returned by
10.71 + * {@code Float.intBitsToFloat(0x7fc00000)}.
10.72 + */
10.73 + public static final float NaN = 0.0f / 0.0f;
10.74 +
10.75 + /**
10.76 + * A constant holding the largest positive finite value of type
10.77 + * {@code float}, (2-2<sup>-23</sup>)·2<sup>127</sup>.
10.78 + * It is equal to the hexadecimal floating-point literal
10.79 + * {@code 0x1.fffffeP+127f} and also equal to
10.80 + * {@code Float.intBitsToFloat(0x7f7fffff)}.
10.81 + */
10.82 + public static final float MAX_VALUE = 0x1.fffffeP+127f; // 3.4028235e+38f
10.83 +
10.84 + /**
10.85 + * A constant holding the smallest positive normal value of type
10.86 + * {@code float}, 2<sup>-126</sup>. It is equal to the
10.87 + * hexadecimal floating-point literal {@code 0x1.0p-126f} and also
10.88 + * equal to {@code Float.intBitsToFloat(0x00800000)}.
10.89 + *
10.90 + * @since 1.6
10.91 + */
10.92 + public static final float MIN_NORMAL = 0x1.0p-126f; // 1.17549435E-38f
10.93 +
10.94 + /**
10.95 + * A constant holding the smallest positive nonzero value of type
10.96 + * {@code float}, 2<sup>-149</sup>. It is equal to the
10.97 + * hexadecimal floating-point literal {@code 0x0.000002P-126f}
10.98 + * and also equal to {@code Float.intBitsToFloat(0x1)}.
10.99 + */
10.100 + public static final float MIN_VALUE = 0x0.000002P-126f; // 1.4e-45f
10.101 +
10.102 + /**
10.103 + * Maximum exponent a finite {@code float} variable may have. It
10.104 + * is equal to the value returned by {@code
10.105 + * Math.getExponent(Float.MAX_VALUE)}.
10.106 + *
10.107 + * @since 1.6
10.108 + */
10.109 + public static final int MAX_EXPONENT = 127;
10.110 +
10.111 + /**
10.112 + * Minimum exponent a normalized {@code float} variable may have.
10.113 + * It is equal to the value returned by {@code
10.114 + * Math.getExponent(Float.MIN_NORMAL)}.
10.115 + *
10.116 + * @since 1.6
10.117 + */
10.118 + public static final int MIN_EXPONENT = -126;
10.119 +
10.120 + /**
10.121 + * The number of bits used to represent a {@code float} value.
10.122 + *
10.123 + * @since 1.5
10.124 + */
10.125 + public static final int SIZE = 32;
10.126 +
10.127 + /**
10.128 + * The {@code Class} instance representing the primitive type
10.129 + * {@code float}.
10.130 + *
10.131 + * @since JDK1.1
10.132 + */
10.133 + public static final Class<Float> TYPE = Class.getPrimitiveClass("float");
10.134 +
10.135 + /**
10.136 + * Returns a string representation of the {@code float}
10.137 + * argument. All characters mentioned below are ASCII characters.
10.138 + * <ul>
10.139 + * <li>If the argument is NaN, the result is the string
10.140 + * "{@code NaN}".
10.141 + * <li>Otherwise, the result is a string that represents the sign and
10.142 + * magnitude (absolute value) of the argument. If the sign is
10.143 + * negative, the first character of the result is
10.144 + * '{@code -}' (<code>'\u002D'</code>); if the sign is
10.145 + * positive, no sign character appears in the result. As for
10.146 + * the magnitude <i>m</i>:
10.147 + * <ul>
10.148 + * <li>If <i>m</i> is infinity, it is represented by the characters
10.149 + * {@code "Infinity"}; thus, positive infinity produces
10.150 + * the result {@code "Infinity"} and negative infinity
10.151 + * produces the result {@code "-Infinity"}.
10.152 + * <li>If <i>m</i> is zero, it is represented by the characters
10.153 + * {@code "0.0"}; thus, negative zero produces the result
10.154 + * {@code "-0.0"} and positive zero produces the result
10.155 + * {@code "0.0"}.
10.156 + * <li> If <i>m</i> is greater than or equal to 10<sup>-3</sup> but
10.157 + * less than 10<sup>7</sup>, then it is represented as the
10.158 + * integer part of <i>m</i>, in decimal form with no leading
10.159 + * zeroes, followed by '{@code .}'
10.160 + * (<code>'\u002E'</code>), followed by one or more
10.161 + * decimal digits representing the fractional part of
10.162 + * <i>m</i>.
10.163 + * <li> If <i>m</i> is less than 10<sup>-3</sup> or greater than or
10.164 + * equal to 10<sup>7</sup>, then it is represented in
10.165 + * so-called "computerized scientific notation." Let <i>n</i>
10.166 + * be the unique integer such that 10<sup><i>n</i> </sup>≤
10.167 + * <i>m</i> {@literal <} 10<sup><i>n</i>+1</sup>; then let <i>a</i>
10.168 + * be the mathematically exact quotient of <i>m</i> and
10.169 + * 10<sup><i>n</i></sup> so that 1 ≤ <i>a</i> {@literal <} 10.
10.170 + * The magnitude is then represented as the integer part of
10.171 + * <i>a</i>, as a single decimal digit, followed by
10.172 + * '{@code .}' (<code>'\u002E'</code>), followed by
10.173 + * decimal digits representing the fractional part of
10.174 + * <i>a</i>, followed by the letter '{@code E}'
10.175 + * (<code>'\u0045'</code>), followed by a representation
10.176 + * of <i>n</i> as a decimal integer, as produced by the
10.177 + * method {@link java.lang.Integer#toString(int)}.
10.178 + *
10.179 + * </ul>
10.180 + * </ul>
10.181 + * How many digits must be printed for the fractional part of
10.182 + * <i>m</i> or <i>a</i>? There must be at least one digit
10.183 + * to represent the fractional part, and beyond that as many, but
10.184 + * only as many, more digits as are needed to uniquely distinguish
10.185 + * the argument value from adjacent values of type
10.186 + * {@code float}. That is, suppose that <i>x</i> is the
10.187 + * exact mathematical value represented by the decimal
10.188 + * representation produced by this method for a finite nonzero
10.189 + * argument <i>f</i>. Then <i>f</i> must be the {@code float}
10.190 + * value nearest to <i>x</i>; or, if two {@code float} values are
10.191 + * equally close to <i>x</i>, then <i>f</i> must be one of
10.192 + * them and the least significant bit of the significand of
10.193 + * <i>f</i> must be {@code 0}.
10.194 + *
10.195 + * <p>To create localized string representations of a floating-point
10.196 + * value, use subclasses of {@link java.text.NumberFormat}.
10.197 + *
10.198 + * @param f the float to be converted.
10.199 + * @return a string representation of the argument.
10.200 + */
10.201 + public static String toString(float f) {
10.202 + return new FloatingDecimal(f).toJavaFormatString();
10.203 + }
10.204 +
10.205 + /**
10.206 + * Returns a hexadecimal string representation of the
10.207 + * {@code float} argument. All characters mentioned below are
10.208 + * ASCII characters.
10.209 + *
10.210 + * <ul>
10.211 + * <li>If the argument is NaN, the result is the string
10.212 + * "{@code NaN}".
10.213 + * <li>Otherwise, the result is a string that represents the sign and
10.214 + * magnitude (absolute value) of the argument. If the sign is negative,
10.215 + * the first character of the result is '{@code -}'
10.216 + * (<code>'\u002D'</code>); if the sign is positive, no sign character
10.217 + * appears in the result. As for the magnitude <i>m</i>:
10.218 + *
10.219 + * <ul>
10.220 + * <li>If <i>m</i> is infinity, it is represented by the string
10.221 + * {@code "Infinity"}; thus, positive infinity produces the
10.222 + * result {@code "Infinity"} and negative infinity produces
10.223 + * the result {@code "-Infinity"}.
10.224 + *
10.225 + * <li>If <i>m</i> is zero, it is represented by the string
10.226 + * {@code "0x0.0p0"}; thus, negative zero produces the result
10.227 + * {@code "-0x0.0p0"} and positive zero produces the result
10.228 + * {@code "0x0.0p0"}.
10.229 + *
10.230 + * <li>If <i>m</i> is a {@code float} value with a
10.231 + * normalized representation, substrings are used to represent the
10.232 + * significand and exponent fields. The significand is
10.233 + * represented by the characters {@code "0x1."}
10.234 + * followed by a lowercase hexadecimal representation of the rest
10.235 + * of the significand as a fraction. Trailing zeros in the
10.236 + * hexadecimal representation are removed unless all the digits
10.237 + * are zero, in which case a single zero is used. Next, the
10.238 + * exponent is represented by {@code "p"} followed
10.239 + * by a decimal string of the unbiased exponent as if produced by
10.240 + * a call to {@link Integer#toString(int) Integer.toString} on the
10.241 + * exponent value.
10.242 + *
10.243 + * <li>If <i>m</i> is a {@code float} value with a subnormal
10.244 + * representation, the significand is represented by the
10.245 + * characters {@code "0x0."} followed by a
10.246 + * hexadecimal representation of the rest of the significand as a
10.247 + * fraction. Trailing zeros in the hexadecimal representation are
10.248 + * removed. Next, the exponent is represented by
10.249 + * {@code "p-126"}. Note that there must be at
10.250 + * least one nonzero digit in a subnormal significand.
10.251 + *
10.252 + * </ul>
10.253 + *
10.254 + * </ul>
10.255 + *
10.256 + * <table border>
10.257 + * <caption><h3>Examples</h3></caption>
10.258 + * <tr><th>Floating-point Value</th><th>Hexadecimal String</th>
10.259 + * <tr><td>{@code 1.0}</td> <td>{@code 0x1.0p0}</td>
10.260 + * <tr><td>{@code -1.0}</td> <td>{@code -0x1.0p0}</td>
10.261 + * <tr><td>{@code 2.0}</td> <td>{@code 0x1.0p1}</td>
10.262 + * <tr><td>{@code 3.0}</td> <td>{@code 0x1.8p1}</td>
10.263 + * <tr><td>{@code 0.5}</td> <td>{@code 0x1.0p-1}</td>
10.264 + * <tr><td>{@code 0.25}</td> <td>{@code 0x1.0p-2}</td>
10.265 + * <tr><td>{@code Float.MAX_VALUE}</td>
10.266 + * <td>{@code 0x1.fffffep127}</td>
10.267 + * <tr><td>{@code Minimum Normal Value}</td>
10.268 + * <td>{@code 0x1.0p-126}</td>
10.269 + * <tr><td>{@code Maximum Subnormal Value}</td>
10.270 + * <td>{@code 0x0.fffffep-126}</td>
10.271 + * <tr><td>{@code Float.MIN_VALUE}</td>
10.272 + * <td>{@code 0x0.000002p-126}</td>
10.273 + * </table>
10.274 + * @param f the {@code float} to be converted.
10.275 + * @return a hex string representation of the argument.
10.276 + * @since 1.5
10.277 + * @author Joseph D. Darcy
10.278 + */
10.279 + public static String toHexString(float f) {
10.280 + if (Math.abs(f) < FloatConsts.MIN_NORMAL
10.281 + && f != 0.0f ) {// float subnormal
10.282 + // Adjust exponent to create subnormal double, then
10.283 + // replace subnormal double exponent with subnormal float
10.284 + // exponent
10.285 + String s = Double.toHexString(FpUtils.scalb((double)f,
10.286 + /* -1022+126 */
10.287 + DoubleConsts.MIN_EXPONENT-
10.288 + FloatConsts.MIN_EXPONENT));
10.289 + return s.replaceFirst("p-1022$", "p-126");
10.290 + }
10.291 + else // double string will be the same as float string
10.292 + return Double.toHexString(f);
10.293 + }
10.294 +
10.295 + /**
10.296 + * Returns a {@code Float} object holding the
10.297 + * {@code float} value represented by the argument string
10.298 + * {@code s}.
10.299 + *
10.300 + * <p>If {@code s} is {@code null}, then a
10.301 + * {@code NullPointerException} is thrown.
10.302 + *
10.303 + * <p>Leading and trailing whitespace characters in {@code s}
10.304 + * are ignored. Whitespace is removed as if by the {@link
10.305 + * String#trim} method; that is, both ASCII space and control
10.306 + * characters are removed. The rest of {@code s} should
10.307 + * constitute a <i>FloatValue</i> as described by the lexical
10.308 + * syntax rules:
10.309 + *
10.310 + * <blockquote>
10.311 + * <dl>
10.312 + * <dt><i>FloatValue:</i>
10.313 + * <dd><i>Sign<sub>opt</sub></i> {@code NaN}
10.314 + * <dd><i>Sign<sub>opt</sub></i> {@code Infinity}
10.315 + * <dd><i>Sign<sub>opt</sub> FloatingPointLiteral</i>
10.316 + * <dd><i>Sign<sub>opt</sub> HexFloatingPointLiteral</i>
10.317 + * <dd><i>SignedInteger</i>
10.318 + * </dl>
10.319 + *
10.320 + * <p>
10.321 + *
10.322 + * <dl>
10.323 + * <dt><i>HexFloatingPointLiteral</i>:
10.324 + * <dd> <i>HexSignificand BinaryExponent FloatTypeSuffix<sub>opt</sub></i>
10.325 + * </dl>
10.326 + *
10.327 + * <p>
10.328 + *
10.329 + * <dl>
10.330 + * <dt><i>HexSignificand:</i>
10.331 + * <dd><i>HexNumeral</i>
10.332 + * <dd><i>HexNumeral</i> {@code .}
10.333 + * <dd>{@code 0x} <i>HexDigits<sub>opt</sub>
10.334 + * </i>{@code .}<i> HexDigits</i>
10.335 + * <dd>{@code 0X}<i> HexDigits<sub>opt</sub>
10.336 + * </i>{@code .} <i>HexDigits</i>
10.337 + * </dl>
10.338 + *
10.339 + * <p>
10.340 + *
10.341 + * <dl>
10.342 + * <dt><i>BinaryExponent:</i>
10.343 + * <dd><i>BinaryExponentIndicator SignedInteger</i>
10.344 + * </dl>
10.345 + *
10.346 + * <p>
10.347 + *
10.348 + * <dl>
10.349 + * <dt><i>BinaryExponentIndicator:</i>
10.350 + * <dd>{@code p}
10.351 + * <dd>{@code P}
10.352 + * </dl>
10.353 + *
10.354 + * </blockquote>
10.355 + *
10.356 + * where <i>Sign</i>, <i>FloatingPointLiteral</i>,
10.357 + * <i>HexNumeral</i>, <i>HexDigits</i>, <i>SignedInteger</i> and
10.358 + * <i>FloatTypeSuffix</i> are as defined in the lexical structure
10.359 + * sections of
10.360 + * <cite>The Java™ Language Specification</cite>,
10.361 + * except that underscores are not accepted between digits.
10.362 + * If {@code s} does not have the form of
10.363 + * a <i>FloatValue</i>, then a {@code NumberFormatException}
10.364 + * is thrown. Otherwise, {@code s} is regarded as
10.365 + * representing an exact decimal value in the usual
10.366 + * "computerized scientific notation" or as an exact
10.367 + * hexadecimal value; this exact numerical value is then
10.368 + * conceptually converted to an "infinitely precise"
10.369 + * binary value that is then rounded to type {@code float}
10.370 + * by the usual round-to-nearest rule of IEEE 754 floating-point
10.371 + * arithmetic, which includes preserving the sign of a zero
10.372 + * value.
10.373 + *
10.374 + * Note that the round-to-nearest rule also implies overflow and
10.375 + * underflow behaviour; if the exact value of {@code s} is large
10.376 + * enough in magnitude (greater than or equal to ({@link
10.377 + * #MAX_VALUE} + {@link Math#ulp(float) ulp(MAX_VALUE)}/2),
10.378 + * rounding to {@code float} will result in an infinity and if the
10.379 + * exact value of {@code s} is small enough in magnitude (less
10.380 + * than or equal to {@link #MIN_VALUE}/2), rounding to float will
10.381 + * result in a zero.
10.382 + *
10.383 + * Finally, after rounding a {@code Float} object representing
10.384 + * this {@code float} value is returned.
10.385 + *
10.386 + * <p>To interpret localized string representations of a
10.387 + * floating-point value, use subclasses of {@link
10.388 + * java.text.NumberFormat}.
10.389 + *
10.390 + * <p>Note that trailing format specifiers, specifiers that
10.391 + * determine the type of a floating-point literal
10.392 + * ({@code 1.0f} is a {@code float} value;
10.393 + * {@code 1.0d} is a {@code double} value), do
10.394 + * <em>not</em> influence the results of this method. In other
10.395 + * words, the numerical value of the input string is converted
10.396 + * directly to the target floating-point type. In general, the
10.397 + * two-step sequence of conversions, string to {@code double}
10.398 + * followed by {@code double} to {@code float}, is
10.399 + * <em>not</em> equivalent to converting a string directly to
10.400 + * {@code float}. For example, if first converted to an
10.401 + * intermediate {@code double} and then to
10.402 + * {@code float}, the string<br>
10.403 + * {@code "1.00000017881393421514957253748434595763683319091796875001d"}<br>
10.404 + * results in the {@code float} value
10.405 + * {@code 1.0000002f}; if the string is converted directly to
10.406 + * {@code float}, <code>1.000000<b>1</b>f</code> results.
10.407 + *
10.408 + * <p>To avoid calling this method on an invalid string and having
10.409 + * a {@code NumberFormatException} be thrown, the documentation
10.410 + * for {@link Double#valueOf Double.valueOf} lists a regular
10.411 + * expression which can be used to screen the input.
10.412 + *
10.413 + * @param s the string to be parsed.
10.414 + * @return a {@code Float} object holding the value
10.415 + * represented by the {@code String} argument.
10.416 + * @throws NumberFormatException if the string does not contain a
10.417 + * parsable number.
10.418 + */
10.419 + public static Float valueOf(String s) throws NumberFormatException {
10.420 + return new Float(FloatingDecimal.readJavaFormatString(s).floatValue());
10.421 + }
10.422 +
10.423 + /**
10.424 + * Returns a {@code Float} instance representing the specified
10.425 + * {@code float} value.
10.426 + * If a new {@code Float} instance is not required, this method
10.427 + * should generally be used in preference to the constructor
10.428 + * {@link #Float(float)}, as this method is likely to yield
10.429 + * significantly better space and time performance by caching
10.430 + * frequently requested values.
10.431 + *
10.432 + * @param f a float value.
10.433 + * @return a {@code Float} instance representing {@code f}.
10.434 + * @since 1.5
10.435 + */
10.436 + public static Float valueOf(float f) {
10.437 + return new Float(f);
10.438 + }
10.439 +
10.440 + /**
10.441 + * Returns a new {@code float} initialized to the value
10.442 + * represented by the specified {@code String}, as performed
10.443 + * by the {@code valueOf} method of class {@code Float}.
10.444 + *
10.445 + * @param s the string to be parsed.
10.446 + * @return the {@code float} value represented by the string
10.447 + * argument.
10.448 + * @throws NullPointerException if the string is null
10.449 + * @throws NumberFormatException if the string does not contain a
10.450 + * parsable {@code float}.
10.451 + * @see java.lang.Float#valueOf(String)
10.452 + * @since 1.2
10.453 + */
10.454 + public static float parseFloat(String s) throws NumberFormatException {
10.455 + return FloatingDecimal.readJavaFormatString(s).floatValue();
10.456 + }
10.457 +
10.458 + /**
10.459 + * Returns {@code true} if the specified number is a
10.460 + * Not-a-Number (NaN) value, {@code false} otherwise.
10.461 + *
10.462 + * @param v the value to be tested.
10.463 + * @return {@code true} if the argument is NaN;
10.464 + * {@code false} otherwise.
10.465 + */
10.466 + static public boolean isNaN(float v) {
10.467 + return (v != v);
10.468 + }
10.469 +
10.470 + /**
10.471 + * Returns {@code true} if the specified number is infinitely
10.472 + * large in magnitude, {@code false} otherwise.
10.473 + *
10.474 + * @param v the value to be tested.
10.475 + * @return {@code true} if the argument is positive infinity or
10.476 + * negative infinity; {@code false} otherwise.
10.477 + */
10.478 + static public boolean isInfinite(float v) {
10.479 + return (v == POSITIVE_INFINITY) || (v == NEGATIVE_INFINITY);
10.480 + }
10.481 +
10.482 + /**
10.483 + * The value of the Float.
10.484 + *
10.485 + * @serial
10.486 + */
10.487 + private final float value;
10.488 +
10.489 + /**
10.490 + * Constructs a newly allocated {@code Float} object that
10.491 + * represents the primitive {@code float} argument.
10.492 + *
10.493 + * @param value the value to be represented by the {@code Float}.
10.494 + */
10.495 + public Float(float value) {
10.496 + this.value = value;
10.497 + }
10.498 +
10.499 + /**
10.500 + * Constructs a newly allocated {@code Float} object that
10.501 + * represents the argument converted to type {@code float}.
10.502 + *
10.503 + * @param value the value to be represented by the {@code Float}.
10.504 + */
10.505 + public Float(double value) {
10.506 + this.value = (float)value;
10.507 + }
10.508 +
10.509 + /**
10.510 + * Constructs a newly allocated {@code Float} object that
10.511 + * represents the floating-point value of type {@code float}
10.512 + * represented by the string. The string is converted to a
10.513 + * {@code float} value as if by the {@code valueOf} method.
10.514 + *
10.515 + * @param s a string to be converted to a {@code Float}.
10.516 + * @throws NumberFormatException if the string does not contain a
10.517 + * parsable number.
10.518 + * @see java.lang.Float#valueOf(java.lang.String)
10.519 + */
10.520 + public Float(String s) throws NumberFormatException {
10.521 + // REMIND: this is inefficient
10.522 + this(valueOf(s).floatValue());
10.523 + }
10.524 +
10.525 + /**
10.526 + * Returns {@code true} if this {@code Float} value is a
10.527 + * Not-a-Number (NaN), {@code false} otherwise.
10.528 + *
10.529 + * @return {@code true} if the value represented by this object is
10.530 + * NaN; {@code false} otherwise.
10.531 + */
10.532 + public boolean isNaN() {
10.533 + return isNaN(value);
10.534 + }
10.535 +
10.536 + /**
10.537 + * Returns {@code true} if this {@code Float} value is
10.538 + * infinitely large in magnitude, {@code false} otherwise.
10.539 + *
10.540 + * @return {@code true} if the value represented by this object is
10.541 + * positive infinity or negative infinity;
10.542 + * {@code false} otherwise.
10.543 + */
10.544 + public boolean isInfinite() {
10.545 + return isInfinite(value);
10.546 + }
10.547 +
10.548 + /**
10.549 + * Returns a string representation of this {@code Float} object.
10.550 + * The primitive {@code float} value represented by this object
10.551 + * is converted to a {@code String} exactly as if by the method
10.552 + * {@code toString} of one argument.
10.553 + *
10.554 + * @return a {@code String} representation of this object.
10.555 + * @see java.lang.Float#toString(float)
10.556 + */
10.557 + public String toString() {
10.558 + return Float.toString(value);
10.559 + }
10.560 +
10.561 + /**
10.562 + * Returns the value of this {@code Float} as a {@code byte} (by
10.563 + * casting to a {@code byte}).
10.564 + *
10.565 + * @return the {@code float} value represented by this object
10.566 + * converted to type {@code byte}
10.567 + */
10.568 + public byte byteValue() {
10.569 + return (byte)value;
10.570 + }
10.571 +
10.572 + /**
10.573 + * Returns the value of this {@code Float} as a {@code short} (by
10.574 + * casting to a {@code short}).
10.575 + *
10.576 + * @return the {@code float} value represented by this object
10.577 + * converted to type {@code short}
10.578 + * @since JDK1.1
10.579 + */
10.580 + public short shortValue() {
10.581 + return (short)value;
10.582 + }
10.583 +
10.584 + /**
10.585 + * Returns the value of this {@code Float} as an {@code int} (by
10.586 + * casting to type {@code int}).
10.587 + *
10.588 + * @return the {@code float} value represented by this object
10.589 + * converted to type {@code int}
10.590 + */
10.591 + public int intValue() {
10.592 + return (int)value;
10.593 + }
10.594 +
10.595 + /**
10.596 + * Returns value of this {@code Float} as a {@code long} (by
10.597 + * casting to type {@code long}).
10.598 + *
10.599 + * @return the {@code float} value represented by this object
10.600 + * converted to type {@code long}
10.601 + */
10.602 + public long longValue() {
10.603 + return (long)value;
10.604 + }
10.605 +
10.606 + /**
10.607 + * Returns the {@code float} value of this {@code Float} object.
10.608 + *
10.609 + * @return the {@code float} value represented by this object
10.610 + */
10.611 + public float floatValue() {
10.612 + return value;
10.613 + }
10.614 +
10.615 + /**
10.616 + * Returns the {@code double} value of this {@code Float} object.
10.617 + *
10.618 + * @return the {@code float} value represented by this
10.619 + * object is converted to type {@code double} and the
10.620 + * result of the conversion is returned.
10.621 + */
10.622 + public double doubleValue() {
10.623 + return (double)value;
10.624 + }
10.625 +
10.626 + /**
10.627 + * Returns a hash code for this {@code Float} object. The
10.628 + * result is the integer bit representation, exactly as produced
10.629 + * by the method {@link #floatToIntBits(float)}, of the primitive
10.630 + * {@code float} value represented by this {@code Float}
10.631 + * object.
10.632 + *
10.633 + * @return a hash code value for this object.
10.634 + */
10.635 + public int hashCode() {
10.636 + return floatToIntBits(value);
10.637 + }
10.638 +
10.639 + /**
10.640 +
10.641 + * Compares this object against the specified object. The result
10.642 + * is {@code true} if and only if the argument is not
10.643 + * {@code null} and is a {@code Float} object that
10.644 + * represents a {@code float} with the same value as the
10.645 + * {@code float} represented by this object. For this
10.646 + * purpose, two {@code float} values are considered to be the
10.647 + * same if and only if the method {@link #floatToIntBits(float)}
10.648 + * returns the identical {@code int} value when applied to
10.649 + * each.
10.650 + *
10.651 + * <p>Note that in most cases, for two instances of class
10.652 + * {@code Float}, {@code f1} and {@code f2}, the value
10.653 + * of {@code f1.equals(f2)} is {@code true} if and only if
10.654 + *
10.655 + * <blockquote><pre>
10.656 + * f1.floatValue() == f2.floatValue()
10.657 + * </pre></blockquote>
10.658 + *
10.659 + * <p>also has the value {@code true}. However, there are two exceptions:
10.660 + * <ul>
10.661 + * <li>If {@code f1} and {@code f2} both represent
10.662 + * {@code Float.NaN}, then the {@code equals} method returns
10.663 + * {@code true}, even though {@code Float.NaN==Float.NaN}
10.664 + * has the value {@code false}.
10.665 + * <li>If {@code f1} represents {@code +0.0f} while
10.666 + * {@code f2} represents {@code -0.0f}, or vice
10.667 + * versa, the {@code equal} test has the value
10.668 + * {@code false}, even though {@code 0.0f==-0.0f}
10.669 + * has the value {@code true}.
10.670 + * </ul>
10.671 + *
10.672 + * This definition allows hash tables to operate properly.
10.673 + *
10.674 + * @param obj the object to be compared
10.675 + * @return {@code true} if the objects are the same;
10.676 + * {@code false} otherwise.
10.677 + * @see java.lang.Float#floatToIntBits(float)
10.678 + */
10.679 + public boolean equals(Object obj) {
10.680 + return (obj instanceof Float)
10.681 + && (floatToIntBits(((Float)obj).value) == floatToIntBits(value));
10.682 + }
10.683 +
10.684 + /**
10.685 + * Returns a representation of the specified floating-point value
10.686 + * according to the IEEE 754 floating-point "single format" bit
10.687 + * layout.
10.688 + *
10.689 + * <p>Bit 31 (the bit that is selected by the mask
10.690 + * {@code 0x80000000}) represents the sign of the floating-point
10.691 + * number.
10.692 + * Bits 30-23 (the bits that are selected by the mask
10.693 + * {@code 0x7f800000}) represent the exponent.
10.694 + * Bits 22-0 (the bits that are selected by the mask
10.695 + * {@code 0x007fffff}) represent the significand (sometimes called
10.696 + * the mantissa) of the floating-point number.
10.697 + *
10.698 + * <p>If the argument is positive infinity, the result is
10.699 + * {@code 0x7f800000}.
10.700 + *
10.701 + * <p>If the argument is negative infinity, the result is
10.702 + * {@code 0xff800000}.
10.703 + *
10.704 + * <p>If the argument is NaN, the result is {@code 0x7fc00000}.
10.705 + *
10.706 + * <p>In all cases, the result is an integer that, when given to the
10.707 + * {@link #intBitsToFloat(int)} method, will produce a floating-point
10.708 + * value the same as the argument to {@code floatToIntBits}
10.709 + * (except all NaN values are collapsed to a single
10.710 + * "canonical" NaN value).
10.711 + *
10.712 + * @param value a floating-point number.
10.713 + * @return the bits that represent the floating-point number.
10.714 + */
10.715 + public static int floatToIntBits(float value) {
10.716 + int result = floatToRawIntBits(value);
10.717 + // Check for NaN based on values of bit fields, maximum
10.718 + // exponent and nonzero significand.
10.719 + if ( ((result & FloatConsts.EXP_BIT_MASK) ==
10.720 + FloatConsts.EXP_BIT_MASK) &&
10.721 + (result & FloatConsts.SIGNIF_BIT_MASK) != 0)
10.722 + result = 0x7fc00000;
10.723 + return result;
10.724 + }
10.725 +
10.726 + /**
10.727 + * Returns a representation of the specified floating-point value
10.728 + * according to the IEEE 754 floating-point "single format" bit
10.729 + * layout, preserving Not-a-Number (NaN) values.
10.730 + *
10.731 + * <p>Bit 31 (the bit that is selected by the mask
10.732 + * {@code 0x80000000}) represents the sign of the floating-point
10.733 + * number.
10.734 + * Bits 30-23 (the bits that are selected by the mask
10.735 + * {@code 0x7f800000}) represent the exponent.
10.736 + * Bits 22-0 (the bits that are selected by the mask
10.737 + * {@code 0x007fffff}) represent the significand (sometimes called
10.738 + * the mantissa) of the floating-point number.
10.739 + *
10.740 + * <p>If the argument is positive infinity, the result is
10.741 + * {@code 0x7f800000}.
10.742 + *
10.743 + * <p>If the argument is negative infinity, the result is
10.744 + * {@code 0xff800000}.
10.745 + *
10.746 + * <p>If the argument is NaN, the result is the integer representing
10.747 + * the actual NaN value. Unlike the {@code floatToIntBits}
10.748 + * method, {@code floatToRawIntBits} does not collapse all the
10.749 + * bit patterns encoding a NaN to a single "canonical"
10.750 + * NaN value.
10.751 + *
10.752 + * <p>In all cases, the result is an integer that, when given to the
10.753 + * {@link #intBitsToFloat(int)} method, will produce a
10.754 + * floating-point value the same as the argument to
10.755 + * {@code floatToRawIntBits}.
10.756 + *
10.757 + * @param value a floating-point number.
10.758 + * @return the bits that represent the floating-point number.
10.759 + * @since 1.3
10.760 + */
10.761 + public static native int floatToRawIntBits(float value);
10.762 +
10.763 + /**
10.764 + * Returns the {@code float} value corresponding to a given
10.765 + * bit representation.
10.766 + * The argument is considered to be a representation of a
10.767 + * floating-point value according to the IEEE 754 floating-point
10.768 + * "single format" bit layout.
10.769 + *
10.770 + * <p>If the argument is {@code 0x7f800000}, the result is positive
10.771 + * infinity.
10.772 + *
10.773 + * <p>If the argument is {@code 0xff800000}, the result is negative
10.774 + * infinity.
10.775 + *
10.776 + * <p>If the argument is any value in the range
10.777 + * {@code 0x7f800001} through {@code 0x7fffffff} or in
10.778 + * the range {@code 0xff800001} through
10.779 + * {@code 0xffffffff}, the result is a NaN. No IEEE 754
10.780 + * floating-point operation provided by Java can distinguish
10.781 + * between two NaN values of the same type with different bit
10.782 + * patterns. Distinct values of NaN are only distinguishable by
10.783 + * use of the {@code Float.floatToRawIntBits} method.
10.784 + *
10.785 + * <p>In all other cases, let <i>s</i>, <i>e</i>, and <i>m</i> be three
10.786 + * values that can be computed from the argument:
10.787 + *
10.788 + * <blockquote><pre>
10.789 + * int s = ((bits >> 31) == 0) ? 1 : -1;
10.790 + * int e = ((bits >> 23) & 0xff);
10.791 + * int m = (e == 0) ?
10.792 + * (bits & 0x7fffff) << 1 :
10.793 + * (bits & 0x7fffff) | 0x800000;
10.794 + * </pre></blockquote>
10.795 + *
10.796 + * Then the floating-point result equals the value of the mathematical
10.797 + * expression <i>s</i>·<i>m</i>·2<sup><i>e</i>-150</sup>.
10.798 + *
10.799 + * <p>Note that this method may not be able to return a
10.800 + * {@code float} NaN with exactly same bit pattern as the
10.801 + * {@code int} argument. IEEE 754 distinguishes between two
10.802 + * kinds of NaNs, quiet NaNs and <i>signaling NaNs</i>. The
10.803 + * differences between the two kinds of NaN are generally not
10.804 + * visible in Java. Arithmetic operations on signaling NaNs turn
10.805 + * them into quiet NaNs with a different, but often similar, bit
10.806 + * pattern. However, on some processors merely copying a
10.807 + * signaling NaN also performs that conversion. In particular,
10.808 + * copying a signaling NaN to return it to the calling method may
10.809 + * perform this conversion. So {@code intBitsToFloat} may
10.810 + * not be able to return a {@code float} with a signaling NaN
10.811 + * bit pattern. Consequently, for some {@code int} values,
10.812 + * {@code floatToRawIntBits(intBitsToFloat(start))} may
10.813 + * <i>not</i> equal {@code start}. Moreover, which
10.814 + * particular bit patterns represent signaling NaNs is platform
10.815 + * dependent; although all NaN bit patterns, quiet or signaling,
10.816 + * must be in the NaN range identified above.
10.817 + *
10.818 + * @param bits an integer.
10.819 + * @return the {@code float} floating-point value with the same bit
10.820 + * pattern.
10.821 + */
10.822 + public static native float intBitsToFloat(int bits);
10.823 +
10.824 + /**
10.825 + * Compares two {@code Float} objects numerically. There are
10.826 + * two ways in which comparisons performed by this method differ
10.827 + * from those performed by the Java language numerical comparison
10.828 + * operators ({@code <, <=, ==, >=, >}) when
10.829 + * applied to primitive {@code float} values:
10.830 + *
10.831 + * <ul><li>
10.832 + * {@code Float.NaN} is considered by this method to
10.833 + * be equal to itself and greater than all other
10.834 + * {@code float} values
10.835 + * (including {@code Float.POSITIVE_INFINITY}).
10.836 + * <li>
10.837 + * {@code 0.0f} is considered by this method to be greater
10.838 + * than {@code -0.0f}.
10.839 + * </ul>
10.840 + *
10.841 + * This ensures that the <i>natural ordering</i> of {@code Float}
10.842 + * objects imposed by this method is <i>consistent with equals</i>.
10.843 + *
10.844 + * @param anotherFloat the {@code Float} to be compared.
10.845 + * @return the value {@code 0} if {@code anotherFloat} is
10.846 + * numerically equal to this {@code Float}; a value
10.847 + * less than {@code 0} if this {@code Float}
10.848 + * is numerically less than {@code anotherFloat};
10.849 + * and a value greater than {@code 0} if this
10.850 + * {@code Float} is numerically greater than
10.851 + * {@code anotherFloat}.
10.852 + *
10.853 + * @since 1.2
10.854 + * @see Comparable#compareTo(Object)
10.855 + */
10.856 + public int compareTo(Float anotherFloat) {
10.857 + return Float.compare(value, anotherFloat.value);
10.858 + }
10.859 +
10.860 + /**
10.861 + * Compares the two specified {@code float} values. The sign
10.862 + * of the integer value returned is the same as that of the
10.863 + * integer that would be returned by the call:
10.864 + * <pre>
10.865 + * new Float(f1).compareTo(new Float(f2))
10.866 + * </pre>
10.867 + *
10.868 + * @param f1 the first {@code float} to compare.
10.869 + * @param f2 the second {@code float} to compare.
10.870 + * @return the value {@code 0} if {@code f1} is
10.871 + * numerically equal to {@code f2}; a value less than
10.872 + * {@code 0} if {@code f1} is numerically less than
10.873 + * {@code f2}; and a value greater than {@code 0}
10.874 + * if {@code f1} is numerically greater than
10.875 + * {@code f2}.
10.876 + * @since 1.4
10.877 + */
10.878 + public static int compare(float f1, float f2) {
10.879 + if (f1 < f2)
10.880 + return -1; // Neither val is NaN, thisVal is smaller
10.881 + if (f1 > f2)
10.882 + return 1; // Neither val is NaN, thisVal is larger
10.883 +
10.884 + // Cannot use floatToRawIntBits because of possibility of NaNs.
10.885 + int thisBits = Float.floatToIntBits(f1);
10.886 + int anotherBits = Float.floatToIntBits(f2);
10.887 +
10.888 + return (thisBits == anotherBits ? 0 : // Values are equal
10.889 + (thisBits < anotherBits ? -1 : // (-0.0, 0.0) or (!NaN, NaN)
10.890 + 1)); // (0.0, -0.0) or (NaN, !NaN)
10.891 + }
10.892 +
10.893 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
10.894 + private static final long serialVersionUID = -2671257302660747028L;
10.895 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/emul/src/main/java/java/lang/IllegalAccessException.java Sun Sep 30 14:37:39 2012 -0700
11.3 @@ -0,0 +1,78 @@
11.4 +/*
11.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11.7 + *
11.8 + * This code is free software; you can redistribute it and/or modify it
11.9 + * under the terms of the GNU General Public License version 2 only, as
11.10 + * published by the Free Software Foundation. Oracle designates this
11.11 + * particular file as subject to the "Classpath" exception as provided
11.12 + * by Oracle in the LICENSE file that accompanied this code.
11.13 + *
11.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
11.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11.17 + * version 2 for more details (a copy is included in the LICENSE file that
11.18 + * accompanied this code).
11.19 + *
11.20 + * You should have received a copy of the GNU General Public License version
11.21 + * 2 along with this work; if not, write to the Free Software Foundation,
11.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11.23 + *
11.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11.25 + * or visit www.oracle.com if you need additional information or have any
11.26 + * questions.
11.27 + */
11.28 +
11.29 +package java.lang;
11.30 +
11.31 +/**
11.32 + * An IllegalAccessException is thrown when an application tries
11.33 + * to reflectively create an instance (other than an array),
11.34 + * set or get a field, or invoke a method, but the currently
11.35 + * executing method does not have access to the definition of
11.36 + * the specified class, field, method or constructor.
11.37 + *
11.38 + * @author unascribed
11.39 + * @see Class#newInstance()
11.40 + * @see java.lang.reflect.Field#set(Object, Object)
11.41 + * @see java.lang.reflect.Field#setBoolean(Object, boolean)
11.42 + * @see java.lang.reflect.Field#setByte(Object, byte)
11.43 + * @see java.lang.reflect.Field#setShort(Object, short)
11.44 + * @see java.lang.reflect.Field#setChar(Object, char)
11.45 + * @see java.lang.reflect.Field#setInt(Object, int)
11.46 + * @see java.lang.reflect.Field#setLong(Object, long)
11.47 + * @see java.lang.reflect.Field#setFloat(Object, float)
11.48 + * @see java.lang.reflect.Field#setDouble(Object, double)
11.49 + * @see java.lang.reflect.Field#get(Object)
11.50 + * @see java.lang.reflect.Field#getBoolean(Object)
11.51 + * @see java.lang.reflect.Field#getByte(Object)
11.52 + * @see java.lang.reflect.Field#getShort(Object)
11.53 + * @see java.lang.reflect.Field#getChar(Object)
11.54 + * @see java.lang.reflect.Field#getInt(Object)
11.55 + * @see java.lang.reflect.Field#getLong(Object)
11.56 + * @see java.lang.reflect.Field#getFloat(Object)
11.57 + * @see java.lang.reflect.Field#getDouble(Object)
11.58 + * @see java.lang.reflect.Method#invoke(Object, Object[])
11.59 + * @see java.lang.reflect.Constructor#newInstance(Object[])
11.60 + * @since JDK1.0
11.61 + */
11.62 +public class IllegalAccessException extends ReflectiveOperationException {
11.63 + private static final long serialVersionUID = 6616958222490762034L;
11.64 +
11.65 + /**
11.66 + * Constructs an <code>IllegalAccessException</code> without a
11.67 + * detail message.
11.68 + */
11.69 + public IllegalAccessException() {
11.70 + super();
11.71 + }
11.72 +
11.73 + /**
11.74 + * Constructs an <code>IllegalAccessException</code> with a detail message.
11.75 + *
11.76 + * @param s the detail message.
11.77 + */
11.78 + public IllegalAccessException(String s) {
11.79 + super(s);
11.80 + }
11.81 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/emul/src/main/java/java/lang/IllegalStateException.java Sun Sep 30 14:37:39 2012 -0700
12.3 @@ -0,0 +1,97 @@
12.4 +/*
12.5 + * Copyright (c) 1996, 2003, Oracle and/or its affiliates. All rights reserved.
12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12.7 + *
12.8 + * This code is free software; you can redistribute it and/or modify it
12.9 + * under the terms of the GNU General Public License version 2 only, as
12.10 + * published by the Free Software Foundation. Oracle designates this
12.11 + * particular file as subject to the "Classpath" exception as provided
12.12 + * by Oracle in the LICENSE file that accompanied this code.
12.13 + *
12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12.17 + * version 2 for more details (a copy is included in the LICENSE file that
12.18 + * accompanied this code).
12.19 + *
12.20 + * You should have received a copy of the GNU General Public License version
12.21 + * 2 along with this work; if not, write to the Free Software Foundation,
12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12.23 + *
12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12.25 + * or visit www.oracle.com if you need additional information or have any
12.26 + * questions.
12.27 + */
12.28 +
12.29 +package java.lang;
12.30 +
12.31 +/**
12.32 + * Signals that a method has been invoked at an illegal or
12.33 + * inappropriate time. In other words, the Java environment or
12.34 + * Java application is not in an appropriate state for the requested
12.35 + * operation.
12.36 + *
12.37 + * @author Jonni Kanerva
12.38 + * @since JDK1.1
12.39 + */
12.40 +public
12.41 +class IllegalStateException extends RuntimeException {
12.42 + /**
12.43 + * Constructs an IllegalStateException with no detail message.
12.44 + * A detail message is a String that describes this particular exception.
12.45 + */
12.46 + public IllegalStateException() {
12.47 + super();
12.48 + }
12.49 +
12.50 + /**
12.51 + * Constructs an IllegalStateException with the specified detail
12.52 + * message. A detail message is a String that describes this particular
12.53 + * exception.
12.54 + *
12.55 + * @param s the String that contains a detailed message
12.56 + */
12.57 + public IllegalStateException(String s) {
12.58 + super(s);
12.59 + }
12.60 +
12.61 + /**
12.62 + * Constructs a new exception with the specified detail message and
12.63 + * cause.
12.64 + *
12.65 + * <p>Note that the detail message associated with <code>cause</code> is
12.66 + * <i>not</i> automatically incorporated in this exception's detail
12.67 + * message.
12.68 + *
12.69 + * @param message the detail message (which is saved for later retrieval
12.70 + * by the {@link Throwable#getMessage()} method).
12.71 + * @param cause the cause (which is saved for later retrieval by the
12.72 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value
12.73 + * is permitted, and indicates that the cause is nonexistent or
12.74 + * unknown.)
12.75 + * @since 1.5
12.76 + */
12.77 + public IllegalStateException(String message, Throwable cause) {
12.78 + super(message, cause);
12.79 + }
12.80 +
12.81 + /**
12.82 + * Constructs a new exception with the specified cause and a detail
12.83 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
12.84 + * typically contains the class and detail message of <tt>cause</tt>).
12.85 + * This constructor is useful for exceptions that are little more than
12.86 + * wrappers for other throwables (for example, {@link
12.87 + * java.security.PrivilegedActionException}).
12.88 + *
12.89 + * @param cause the cause (which is saved for later retrieval by the
12.90 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value is
12.91 + * permitted, and indicates that the cause is nonexistent or
12.92 + * unknown.)
12.93 + * @since 1.5
12.94 + */
12.95 + public IllegalStateException(Throwable cause) {
12.96 + super(cause);
12.97 + }
12.98 +
12.99 + static final long serialVersionUID = -1848914673093119416L;
12.100 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/emul/src/main/java/java/lang/IndexOutOfBoundsException.java Sun Sep 30 14:37:39 2012 -0700
13.3 @@ -0,0 +1,58 @@
13.4 +/*
13.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13.7 + *
13.8 + * This code is free software; you can redistribute it and/or modify it
13.9 + * under the terms of the GNU General Public License version 2 only, as
13.10 + * published by the Free Software Foundation. Oracle designates this
13.11 + * particular file as subject to the "Classpath" exception as provided
13.12 + * by Oracle in the LICENSE file that accompanied this code.
13.13 + *
13.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
13.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13.17 + * version 2 for more details (a copy is included in the LICENSE file that
13.18 + * accompanied this code).
13.19 + *
13.20 + * You should have received a copy of the GNU General Public License version
13.21 + * 2 along with this work; if not, write to the Free Software Foundation,
13.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
13.23 + *
13.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
13.25 + * or visit www.oracle.com if you need additional information or have any
13.26 + * questions.
13.27 + */
13.28 +
13.29 +package java.lang;
13.30 +
13.31 +/**
13.32 + * Thrown to indicate that an index of some sort (such as to an array, to a
13.33 + * string, or to a vector) is out of range.
13.34 + * <p>
13.35 + * Applications can subclass this class to indicate similar exceptions.
13.36 + *
13.37 + * @author Frank Yellin
13.38 + * @since JDK1.0
13.39 + */
13.40 +public
13.41 +class IndexOutOfBoundsException extends RuntimeException {
13.42 + private static final long serialVersionUID = 234122996006267687L;
13.43 +
13.44 + /**
13.45 + * Constructs an <code>IndexOutOfBoundsException</code> with no
13.46 + * detail message.
13.47 + */
13.48 + public IndexOutOfBoundsException() {
13.49 + super();
13.50 + }
13.51 +
13.52 + /**
13.53 + * Constructs an <code>IndexOutOfBoundsException</code> with the
13.54 + * specified detail message.
13.55 + *
13.56 + * @param s the detail message.
13.57 + */
13.58 + public IndexOutOfBoundsException(String s) {
13.59 + super(s);
13.60 + }
13.61 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/emul/src/main/java/java/lang/InstantiationException.java Sun Sep 30 14:37:39 2012 -0700
14.3 @@ -0,0 +1,65 @@
14.4 +/*
14.5 + * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14.7 + *
14.8 + * This code is free software; you can redistribute it and/or modify it
14.9 + * under the terms of the GNU General Public License version 2 only, as
14.10 + * published by the Free Software Foundation. Oracle designates this
14.11 + * particular file as subject to the "Classpath" exception as provided
14.12 + * by Oracle in the LICENSE file that accompanied this code.
14.13 + *
14.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
14.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14.17 + * version 2 for more details (a copy is included in the LICENSE file that
14.18 + * accompanied this code).
14.19 + *
14.20 + * You should have received a copy of the GNU General Public License version
14.21 + * 2 along with this work; if not, write to the Free Software Foundation,
14.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
14.23 + *
14.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14.25 + * or visit www.oracle.com if you need additional information or have any
14.26 + * questions.
14.27 + */
14.28 +
14.29 +package java.lang;
14.30 +
14.31 +/**
14.32 + * Thrown when an application tries to create an instance of a class
14.33 + * using the {@code newInstance} method in class
14.34 + * {@code Class}, but the specified class object cannot be
14.35 + * instantiated. The instantiation can fail for a variety of
14.36 + * reasons including but not limited to:
14.37 + *
14.38 + * <ul>
14.39 + * <li> the class object represents an abstract class, an interface,
14.40 + * an array class, a primitive type, or {@code void}
14.41 + * <li> the class has no nullary constructor
14.42 + *</ul>
14.43 + *
14.44 + * @author unascribed
14.45 + * @see java.lang.Class#newInstance()
14.46 + * @since JDK1.0
14.47 + */
14.48 +public
14.49 +class InstantiationException extends ReflectiveOperationException {
14.50 + private static final long serialVersionUID = -8441929162975509110L;
14.51 +
14.52 + /**
14.53 + * Constructs an {@code InstantiationException} with no detail message.
14.54 + */
14.55 + public InstantiationException() {
14.56 + super();
14.57 + }
14.58 +
14.59 + /**
14.60 + * Constructs an {@code InstantiationException} with the
14.61 + * specified detail message.
14.62 + *
14.63 + * @param s the detail message.
14.64 + */
14.65 + public InstantiationException(String s) {
14.66 + super(s);
14.67 + }
14.68 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/emul/src/main/java/java/lang/Long.java Sun Sep 30 14:37:39 2012 -0700
15.3 @@ -0,0 +1,1199 @@
15.4 +/*
15.5 + * Copyright (c) 1994, 2009, Oracle and/or its affiliates. All rights reserved.
15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
15.7 + *
15.8 + * This code is free software; you can redistribute it and/or modify it
15.9 + * under the terms of the GNU General Public License version 2 only, as
15.10 + * published by the Free Software Foundation. Oracle designates this
15.11 + * particular file as subject to the "Classpath" exception as provided
15.12 + * by Oracle in the LICENSE file that accompanied this code.
15.13 + *
15.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
15.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15.17 + * version 2 for more details (a copy is included in the LICENSE file that
15.18 + * accompanied this code).
15.19 + *
15.20 + * You should have received a copy of the GNU General Public License version
15.21 + * 2 along with this work; if not, write to the Free Software Foundation,
15.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15.23 + *
15.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15.25 + * or visit www.oracle.com if you need additional information or have any
15.26 + * questions.
15.27 + */
15.28 +
15.29 +package java.lang;
15.30 +
15.31 +/**
15.32 + * The {@code Long} class wraps a value of the primitive type {@code
15.33 + * long} in an object. An object of type {@code Long} contains a
15.34 + * single field whose type is {@code long}.
15.35 + *
15.36 + * <p> In addition, this class provides several methods for converting
15.37 + * a {@code long} to a {@code String} and a {@code String} to a {@code
15.38 + * long}, as well as other constants and methods useful when dealing
15.39 + * with a {@code long}.
15.40 + *
15.41 + * <p>Implementation note: The implementations of the "bit twiddling"
15.42 + * methods (such as {@link #highestOneBit(long) highestOneBit} and
15.43 + * {@link #numberOfTrailingZeros(long) numberOfTrailingZeros}) are
15.44 + * based on material from Henry S. Warren, Jr.'s <i>Hacker's
15.45 + * Delight</i>, (Addison Wesley, 2002).
15.46 + *
15.47 + * @author Lee Boynton
15.48 + * @author Arthur van Hoff
15.49 + * @author Josh Bloch
15.50 + * @author Joseph D. Darcy
15.51 + * @since JDK1.0
15.52 + */
15.53 +public final class Long extends Number implements Comparable<Long> {
15.54 + /**
15.55 + * A constant holding the minimum value a {@code long} can
15.56 + * have, -2<sup>63</sup>.
15.57 + */
15.58 + public static final long MIN_VALUE = 0x8000000000000000L;
15.59 +
15.60 + /**
15.61 + * A constant holding the maximum value a {@code long} can
15.62 + * have, 2<sup>63</sup>-1.
15.63 + */
15.64 + public static final long MAX_VALUE = 0x7fffffffffffffffL;
15.65 +
15.66 + /**
15.67 + * The {@code Class} instance representing the primitive type
15.68 + * {@code long}.
15.69 + *
15.70 + * @since JDK1.1
15.71 + */
15.72 + public static final Class<Long> TYPE = (Class<Long>) Class.getPrimitiveClass("long");
15.73 +
15.74 + /**
15.75 + * Returns a string representation of the first argument in the
15.76 + * radix specified by the second argument.
15.77 + *
15.78 + * <p>If the radix is smaller than {@code Character.MIN_RADIX}
15.79 + * or larger than {@code Character.MAX_RADIX}, then the radix
15.80 + * {@code 10} is used instead.
15.81 + *
15.82 + * <p>If the first argument is negative, the first element of the
15.83 + * result is the ASCII minus sign {@code '-'}
15.84 + * (<code>'\u002d'</code>). If the first argument is not
15.85 + * negative, no sign character appears in the result.
15.86 + *
15.87 + * <p>The remaining characters of the result represent the magnitude
15.88 + * of the first argument. If the magnitude is zero, it is
15.89 + * represented by a single zero character {@code '0'}
15.90 + * (<code>'\u0030'</code>); otherwise, the first character of
15.91 + * the representation of the magnitude will not be the zero
15.92 + * character. The following ASCII characters are used as digits:
15.93 + *
15.94 + * <blockquote>
15.95 + * {@code 0123456789abcdefghijklmnopqrstuvwxyz}
15.96 + * </blockquote>
15.97 + *
15.98 + * These are <code>'\u0030'</code> through
15.99 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
15.100 + * <code>'\u007a'</code>. If {@code radix} is
15.101 + * <var>N</var>, then the first <var>N</var> of these characters
15.102 + * are used as radix-<var>N</var> digits in the order shown. Thus,
15.103 + * the digits for hexadecimal (radix 16) are
15.104 + * {@code 0123456789abcdef}. If uppercase letters are
15.105 + * desired, the {@link java.lang.String#toUpperCase()} method may
15.106 + * be called on the result:
15.107 + *
15.108 + * <blockquote>
15.109 + * {@code Long.toString(n, 16).toUpperCase()}
15.110 + * </blockquote>
15.111 + *
15.112 + * @param i a {@code long} to be converted to a string.
15.113 + * @param radix the radix to use in the string representation.
15.114 + * @return a string representation of the argument in the specified radix.
15.115 + * @see java.lang.Character#MAX_RADIX
15.116 + * @see java.lang.Character#MIN_RADIX
15.117 + */
15.118 + public static String toString(long i, int radix) {
15.119 + if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
15.120 + radix = 10;
15.121 + if (radix == 10)
15.122 + return toString(i);
15.123 + char[] buf = new char[65];
15.124 + int charPos = 64;
15.125 + boolean negative = (i < 0);
15.126 +
15.127 + if (!negative) {
15.128 + i = -i;
15.129 + }
15.130 +
15.131 + while (i <= -radix) {
15.132 + buf[charPos--] = Integer.digits[(int)(-(i % radix))];
15.133 + i = i / radix;
15.134 + }
15.135 + buf[charPos] = Integer.digits[(int)(-i)];
15.136 +
15.137 + if (negative) {
15.138 + buf[--charPos] = '-';
15.139 + }
15.140 +
15.141 + return new String(buf, charPos, (65 - charPos));
15.142 + }
15.143 +
15.144 + /**
15.145 + * Returns a string representation of the {@code long}
15.146 + * argument as an unsigned integer in base 16.
15.147 + *
15.148 + * <p>The unsigned {@code long} value is the argument plus
15.149 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
15.150 + * equal to the argument. This value is converted to a string of
15.151 + * ASCII digits in hexadecimal (base 16) with no extra
15.152 + * leading {@code 0}s. If the unsigned magnitude is zero, it
15.153 + * is represented by a single zero character {@code '0'}
15.154 + * (<code>'\u0030'</code>); otherwise, the first character of
15.155 + * the representation of the unsigned magnitude will not be the
15.156 + * zero character. The following characters are used as
15.157 + * hexadecimal digits:
15.158 + *
15.159 + * <blockquote>
15.160 + * {@code 0123456789abcdef}
15.161 + * </blockquote>
15.162 + *
15.163 + * These are the characters <code>'\u0030'</code> through
15.164 + * <code>'\u0039'</code> and <code>'\u0061'</code> through
15.165 + * <code>'\u0066'</code>. If uppercase letters are desired,
15.166 + * the {@link java.lang.String#toUpperCase()} method may be called
15.167 + * on the result:
15.168 + *
15.169 + * <blockquote>
15.170 + * {@code Long.toHexString(n).toUpperCase()}
15.171 + * </blockquote>
15.172 + *
15.173 + * @param i a {@code long} to be converted to a string.
15.174 + * @return the string representation of the unsigned {@code long}
15.175 + * value represented by the argument in hexadecimal
15.176 + * (base 16).
15.177 + * @since JDK 1.0.2
15.178 + */
15.179 + public static String toHexString(long i) {
15.180 + return toUnsignedString(i, 4);
15.181 + }
15.182 +
15.183 + /**
15.184 + * Returns a string representation of the {@code long}
15.185 + * argument as an unsigned integer in base 8.
15.186 + *
15.187 + * <p>The unsigned {@code long} value is the argument plus
15.188 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
15.189 + * equal to the argument. This value is converted to a string of
15.190 + * ASCII digits in octal (base 8) with no extra leading
15.191 + * {@code 0}s.
15.192 + *
15.193 + * <p>If the unsigned magnitude is zero, it is represented by a
15.194 + * single zero character {@code '0'}
15.195 + * (<code>'\u0030'</code>); otherwise, the first character of
15.196 + * the representation of the unsigned magnitude will not be the
15.197 + * zero character. The following characters are used as octal
15.198 + * digits:
15.199 + *
15.200 + * <blockquote>
15.201 + * {@code 01234567}
15.202 + * </blockquote>
15.203 + *
15.204 + * These are the characters <code>'\u0030'</code> through
15.205 + * <code>'\u0037'</code>.
15.206 + *
15.207 + * @param i a {@code long} to be converted to a string.
15.208 + * @return the string representation of the unsigned {@code long}
15.209 + * value represented by the argument in octal (base 8).
15.210 + * @since JDK 1.0.2
15.211 + */
15.212 + public static String toOctalString(long i) {
15.213 + return toUnsignedString(i, 3);
15.214 + }
15.215 +
15.216 + /**
15.217 + * Returns a string representation of the {@code long}
15.218 + * argument as an unsigned integer in base 2.
15.219 + *
15.220 + * <p>The unsigned {@code long} value is the argument plus
15.221 + * 2<sup>64</sup> if the argument is negative; otherwise, it is
15.222 + * equal to the argument. This value is converted to a string of
15.223 + * ASCII digits in binary (base 2) with no extra leading
15.224 + * {@code 0}s. If the unsigned magnitude is zero, it is
15.225 + * represented by a single zero character {@code '0'}
15.226 + * (<code>'\u0030'</code>); otherwise, the first character of
15.227 + * the representation of the unsigned magnitude will not be the
15.228 + * zero character. The characters {@code '0'}
15.229 + * (<code>'\u0030'</code>) and {@code '1'}
15.230 + * (<code>'\u0031'</code>) are used as binary digits.
15.231 + *
15.232 + * @param i a {@code long} to be converted to a string.
15.233 + * @return the string representation of the unsigned {@code long}
15.234 + * value represented by the argument in binary (base 2).
15.235 + * @since JDK 1.0.2
15.236 + */
15.237 + public static String toBinaryString(long i) {
15.238 + return toUnsignedString(i, 1);
15.239 + }
15.240 +
15.241 + /**
15.242 + * Convert the integer to an unsigned number.
15.243 + */
15.244 + private static String toUnsignedString(long i, int shift) {
15.245 + char[] buf = new char[64];
15.246 + int charPos = 64;
15.247 + int radix = 1 << shift;
15.248 + long mask = radix - 1;
15.249 + do {
15.250 + buf[--charPos] = Integer.digits[(int)(i & mask)];
15.251 + i >>>= shift;
15.252 + } while (i != 0);
15.253 + return new String(buf, charPos, (64 - charPos));
15.254 + }
15.255 +
15.256 + /**
15.257 + * Returns a {@code String} object representing the specified
15.258 + * {@code long}. The argument is converted to signed decimal
15.259 + * representation and returned as a string, exactly as if the
15.260 + * argument and the radix 10 were given as arguments to the {@link
15.261 + * #toString(long, int)} method.
15.262 + *
15.263 + * @param i a {@code long} to be converted.
15.264 + * @return a string representation of the argument in base 10.
15.265 + */
15.266 + public static String toString(long i) {
15.267 + if (i == Long.MIN_VALUE)
15.268 + return "-9223372036854775808";
15.269 + int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i);
15.270 + char[] buf = new char[size];
15.271 + getChars(i, size, buf);
15.272 + return new String(0, size, buf);
15.273 + }
15.274 +
15.275 + /**
15.276 + * Places characters representing the integer i into the
15.277 + * character array buf. The characters are placed into
15.278 + * the buffer backwards starting with the least significant
15.279 + * digit at the specified index (exclusive), and working
15.280 + * backwards from there.
15.281 + *
15.282 + * Will fail if i == Long.MIN_VALUE
15.283 + */
15.284 + static void getChars(long i, int index, char[] buf) {
15.285 + long q;
15.286 + int r;
15.287 + int charPos = index;
15.288 + char sign = 0;
15.289 +
15.290 + if (i < 0) {
15.291 + sign = '-';
15.292 + i = -i;
15.293 + }
15.294 +
15.295 + // Get 2 digits/iteration using longs until quotient fits into an int
15.296 + while (i > Integer.MAX_VALUE) {
15.297 + q = i / 100;
15.298 + // really: r = i - (q * 100);
15.299 + r = (int)(i - ((q << 6) + (q << 5) + (q << 2)));
15.300 + i = q;
15.301 + buf[--charPos] = Integer.DigitOnes[r];
15.302 + buf[--charPos] = Integer.DigitTens[r];
15.303 + }
15.304 +
15.305 + // Get 2 digits/iteration using ints
15.306 + int q2;
15.307 + int i2 = (int)i;
15.308 + while (i2 >= 65536) {
15.309 + q2 = i2 / 100;
15.310 + // really: r = i2 - (q * 100);
15.311 + r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2));
15.312 + i2 = q2;
15.313 + buf[--charPos] = Integer.DigitOnes[r];
15.314 + buf[--charPos] = Integer.DigitTens[r];
15.315 + }
15.316 +
15.317 + // Fall thru to fast mode for smaller numbers
15.318 + // assert(i2 <= 65536, i2);
15.319 + for (;;) {
15.320 + q2 = (i2 * 52429) >>> (16+3);
15.321 + r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ...
15.322 + buf[--charPos] = Integer.digits[r];
15.323 + i2 = q2;
15.324 + if (i2 == 0) break;
15.325 + }
15.326 + if (sign != 0) {
15.327 + buf[--charPos] = sign;
15.328 + }
15.329 + }
15.330 +
15.331 + // Requires positive x
15.332 + static int stringSize(long x) {
15.333 + long p = 10;
15.334 + for (int i=1; i<19; i++) {
15.335 + if (x < p)
15.336 + return i;
15.337 + p = 10*p;
15.338 + }
15.339 + return 19;
15.340 + }
15.341 +
15.342 + /**
15.343 + * Parses the string argument as a signed {@code long} in the
15.344 + * radix specified by the second argument. The characters in the
15.345 + * string must all be digits of the specified radix (as determined
15.346 + * by whether {@link java.lang.Character#digit(char, int)} returns
15.347 + * a nonnegative value), except that the first character may be an
15.348 + * ASCII minus sign {@code '-'} (<code>'\u002D'</code>) to
15.349 + * indicate a negative value or an ASCII plus sign {@code '+'}
15.350 + * (<code>'\u002B'</code>) to indicate a positive value. The
15.351 + * resulting {@code long} value is returned.
15.352 + *
15.353 + * <p>Note that neither the character {@code L}
15.354 + * (<code>'\u004C'</code>) nor {@code l}
15.355 + * (<code>'\u006C'</code>) is permitted to appear at the end
15.356 + * of the string as a type indicator, as would be permitted in
15.357 + * Java programming language source code - except that either
15.358 + * {@code L} or {@code l} may appear as a digit for a
15.359 + * radix greater than 22.
15.360 + *
15.361 + * <p>An exception of type {@code NumberFormatException} is
15.362 + * thrown if any of the following situations occurs:
15.363 + * <ul>
15.364 + *
15.365 + * <li>The first argument is {@code null} or is a string of
15.366 + * length zero.
15.367 + *
15.368 + * <li>The {@code radix} is either smaller than {@link
15.369 + * java.lang.Character#MIN_RADIX} or larger than {@link
15.370 + * java.lang.Character#MAX_RADIX}.
15.371 + *
15.372 + * <li>Any character of the string is not a digit of the specified
15.373 + * radix, except that the first character may be a minus sign
15.374 + * {@code '-'} (<code>'\u002d'</code>) or plus sign {@code
15.375 + * '+'} (<code>'\u002B'</code>) provided that the string is
15.376 + * longer than length 1.
15.377 + *
15.378 + * <li>The value represented by the string is not a value of type
15.379 + * {@code long}.
15.380 + * </ul>
15.381 + *
15.382 + * <p>Examples:
15.383 + * <blockquote><pre>
15.384 + * parseLong("0", 10) returns 0L
15.385 + * parseLong("473", 10) returns 473L
15.386 + * parseLong("+42", 10) returns 42L
15.387 + * parseLong("-0", 10) returns 0L
15.388 + * parseLong("-FF", 16) returns -255L
15.389 + * parseLong("1100110", 2) returns 102L
15.390 + * parseLong("99", 8) throws a NumberFormatException
15.391 + * parseLong("Hazelnut", 10) throws a NumberFormatException
15.392 + * parseLong("Hazelnut", 36) returns 1356099454469L
15.393 + * </pre></blockquote>
15.394 + *
15.395 + * @param s the {@code String} containing the
15.396 + * {@code long} representation to be parsed.
15.397 + * @param radix the radix to be used while parsing {@code s}.
15.398 + * @return the {@code long} represented by the string argument in
15.399 + * the specified radix.
15.400 + * @throws NumberFormatException if the string does not contain a
15.401 + * parsable {@code long}.
15.402 + */
15.403 + public static long parseLong(String s, int radix)
15.404 + throws NumberFormatException
15.405 + {
15.406 + if (s == null) {
15.407 + throw new NumberFormatException("null");
15.408 + }
15.409 +
15.410 + if (radix < Character.MIN_RADIX) {
15.411 + throw new NumberFormatException("radix " + radix +
15.412 + " less than Character.MIN_RADIX");
15.413 + }
15.414 + if (radix > Character.MAX_RADIX) {
15.415 + throw new NumberFormatException("radix " + radix +
15.416 + " greater than Character.MAX_RADIX");
15.417 + }
15.418 +
15.419 + long result = 0;
15.420 + boolean negative = false;
15.421 + int i = 0, len = s.length();
15.422 + long limit = -Long.MAX_VALUE;
15.423 + long multmin;
15.424 + int digit;
15.425 +
15.426 + if (len > 0) {
15.427 + char firstChar = s.charAt(0);
15.428 + if (firstChar < '0') { // Possible leading "+" or "-"
15.429 + if (firstChar == '-') {
15.430 + negative = true;
15.431 + limit = Long.MIN_VALUE;
15.432 + } else if (firstChar != '+')
15.433 + throw NumberFormatException.forInputString(s);
15.434 +
15.435 + if (len == 1) // Cannot have lone "+" or "-"
15.436 + throw NumberFormatException.forInputString(s);
15.437 + i++;
15.438 + }
15.439 + multmin = limit / radix;
15.440 + while (i < len) {
15.441 + // Accumulating negatively avoids surprises near MAX_VALUE
15.442 + digit = Character.digit(s.charAt(i++),radix);
15.443 + if (digit < 0) {
15.444 + throw NumberFormatException.forInputString(s);
15.445 + }
15.446 + if (result < multmin) {
15.447 + throw NumberFormatException.forInputString(s);
15.448 + }
15.449 + result *= radix;
15.450 + if (result < limit + digit) {
15.451 + throw NumberFormatException.forInputString(s);
15.452 + }
15.453 + result -= digit;
15.454 + }
15.455 + } else {
15.456 + throw NumberFormatException.forInputString(s);
15.457 + }
15.458 + return negative ? result : -result;
15.459 + }
15.460 +
15.461 + /**
15.462 + * Parses the string argument as a signed decimal {@code long}.
15.463 + * The characters in the string must all be decimal digits, except
15.464 + * that the first character may be an ASCII minus sign {@code '-'}
15.465 + * (<code>\u002D'</code>) to indicate a negative value or an
15.466 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
15.467 + * indicate a positive value. The resulting {@code long} value is
15.468 + * returned, exactly as if the argument and the radix {@code 10}
15.469 + * were given as arguments to the {@link
15.470 + * #parseLong(java.lang.String, int)} method.
15.471 + *
15.472 + * <p>Note that neither the character {@code L}
15.473 + * (<code>'\u004C'</code>) nor {@code l}
15.474 + * (<code>'\u006C'</code>) is permitted to appear at the end
15.475 + * of the string as a type indicator, as would be permitted in
15.476 + * Java programming language source code.
15.477 + *
15.478 + * @param s a {@code String} containing the {@code long}
15.479 + * representation to be parsed
15.480 + * @return the {@code long} represented by the argument in
15.481 + * decimal.
15.482 + * @throws NumberFormatException if the string does not contain a
15.483 + * parsable {@code long}.
15.484 + */
15.485 + public static long parseLong(String s) throws NumberFormatException {
15.486 + return parseLong(s, 10);
15.487 + }
15.488 +
15.489 + /**
15.490 + * Returns a {@code Long} object holding the value
15.491 + * extracted from the specified {@code String} when parsed
15.492 + * with the radix given by the second argument. The first
15.493 + * argument is interpreted as representing a signed
15.494 + * {@code long} in the radix specified by the second
15.495 + * argument, exactly as if the arguments were given to the {@link
15.496 + * #parseLong(java.lang.String, int)} method. The result is a
15.497 + * {@code Long} object that represents the {@code long}
15.498 + * value specified by the string.
15.499 + *
15.500 + * <p>In other words, this method returns a {@code Long} object equal
15.501 + * to the value of:
15.502 + *
15.503 + * <blockquote>
15.504 + * {@code new Long(Long.parseLong(s, radix))}
15.505 + * </blockquote>
15.506 + *
15.507 + * @param s the string to be parsed
15.508 + * @param radix the radix to be used in interpreting {@code s}
15.509 + * @return a {@code Long} object holding the value
15.510 + * represented by the string argument in the specified
15.511 + * radix.
15.512 + * @throws NumberFormatException If the {@code String} does not
15.513 + * contain a parsable {@code long}.
15.514 + */
15.515 + public static Long valueOf(String s, int radix) throws NumberFormatException {
15.516 + return Long.valueOf(parseLong(s, radix));
15.517 + }
15.518 +
15.519 + /**
15.520 + * Returns a {@code Long} object holding the value
15.521 + * of the specified {@code String}. The argument is
15.522 + * interpreted as representing a signed decimal {@code long},
15.523 + * exactly as if the argument were given to the {@link
15.524 + * #parseLong(java.lang.String)} method. The result is a
15.525 + * {@code Long} object that represents the integer value
15.526 + * specified by the string.
15.527 + *
15.528 + * <p>In other words, this method returns a {@code Long} object
15.529 + * equal to the value of:
15.530 + *
15.531 + * <blockquote>
15.532 + * {@code new Long(Long.parseLong(s))}
15.533 + * </blockquote>
15.534 + *
15.535 + * @param s the string to be parsed.
15.536 + * @return a {@code Long} object holding the value
15.537 + * represented by the string argument.
15.538 + * @throws NumberFormatException If the string cannot be parsed
15.539 + * as a {@code long}.
15.540 + */
15.541 + public static Long valueOf(String s) throws NumberFormatException
15.542 + {
15.543 + return Long.valueOf(parseLong(s, 10));
15.544 + }
15.545 +
15.546 + private static class LongCache {
15.547 + private LongCache(){}
15.548 +
15.549 + static final Long cache[] = new Long[-(-128) + 127 + 1];
15.550 +
15.551 + static {
15.552 + for(int i = 0; i < cache.length; i++)
15.553 + cache[i] = new Long(i - 128);
15.554 + }
15.555 + }
15.556 +
15.557 + /**
15.558 + * Returns a {@code Long} instance representing the specified
15.559 + * {@code long} value.
15.560 + * If a new {@code Long} instance is not required, this method
15.561 + * should generally be used in preference to the constructor
15.562 + * {@link #Long(long)}, as this method is likely to yield
15.563 + * significantly better space and time performance by caching
15.564 + * frequently requested values.
15.565 + *
15.566 + * Note that unlike the {@linkplain Integer#valueOf(int)
15.567 + * corresponding method} in the {@code Integer} class, this method
15.568 + * is <em>not</em> required to cache values within a particular
15.569 + * range.
15.570 + *
15.571 + * @param l a long value.
15.572 + * @return a {@code Long} instance representing {@code l}.
15.573 + * @since 1.5
15.574 + */
15.575 + public static Long valueOf(long l) {
15.576 + final int offset = 128;
15.577 + if (l >= -128 && l <= 127) { // will cache
15.578 + return LongCache.cache[(int)l + offset];
15.579 + }
15.580 + return new Long(l);
15.581 + }
15.582 +
15.583 + /**
15.584 + * Decodes a {@code String} into a {@code Long}.
15.585 + * Accepts decimal, hexadecimal, and octal numbers given by the
15.586 + * following grammar:
15.587 + *
15.588 + * <blockquote>
15.589 + * <dl>
15.590 + * <dt><i>DecodableString:</i>
15.591 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
15.592 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
15.593 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
15.594 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
15.595 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
15.596 + * <p>
15.597 + * <dt><i>Sign:</i>
15.598 + * <dd>{@code -}
15.599 + * <dd>{@code +}
15.600 + * </dl>
15.601 + * </blockquote>
15.602 + *
15.603 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
15.604 + * are as defined in section 3.10.1 of
15.605 + * <cite>The Java™ Language Specification</cite>,
15.606 + * except that underscores are not accepted between digits.
15.607 + *
15.608 + * <p>The sequence of characters following an optional
15.609 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
15.610 + * "{@code #}", or leading zero) is parsed as by the {@code
15.611 + * Long.parseLong} method with the indicated radix (10, 16, or 8).
15.612 + * This sequence of characters must represent a positive value or
15.613 + * a {@link NumberFormatException} will be thrown. The result is
15.614 + * negated if first character of the specified {@code String} is
15.615 + * the minus sign. No whitespace characters are permitted in the
15.616 + * {@code String}.
15.617 + *
15.618 + * @param nm the {@code String} to decode.
15.619 + * @return a {@code Long} object holding the {@code long}
15.620 + * value represented by {@code nm}
15.621 + * @throws NumberFormatException if the {@code String} does not
15.622 + * contain a parsable {@code long}.
15.623 + * @see java.lang.Long#parseLong(String, int)
15.624 + * @since 1.2
15.625 + */
15.626 + public static Long decode(String nm) throws NumberFormatException {
15.627 + int radix = 10;
15.628 + int index = 0;
15.629 + boolean negative = false;
15.630 + Long result;
15.631 +
15.632 + if (nm.length() == 0)
15.633 + throw new NumberFormatException("Zero length string");
15.634 + char firstChar = nm.charAt(0);
15.635 + // Handle sign, if present
15.636 + if (firstChar == '-') {
15.637 + negative = true;
15.638 + index++;
15.639 + } else if (firstChar == '+')
15.640 + index++;
15.641 +
15.642 + // Handle radix specifier, if present
15.643 + if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) {
15.644 + index += 2;
15.645 + radix = 16;
15.646 + }
15.647 + else if (nm.startsWith("#", index)) {
15.648 + index ++;
15.649 + radix = 16;
15.650 + }
15.651 + else if (nm.startsWith("0", index) && nm.length() > 1 + index) {
15.652 + index ++;
15.653 + radix = 8;
15.654 + }
15.655 +
15.656 + if (nm.startsWith("-", index) || nm.startsWith("+", index))
15.657 + throw new NumberFormatException("Sign character in wrong position");
15.658 +
15.659 + try {
15.660 + result = Long.valueOf(nm.substring(index), radix);
15.661 + result = negative ? Long.valueOf(-result.longValue()) : result;
15.662 + } catch (NumberFormatException e) {
15.663 + // If number is Long.MIN_VALUE, we'll end up here. The next line
15.664 + // handles this case, and causes any genuine format error to be
15.665 + // rethrown.
15.666 + String constant = negative ? ("-" + nm.substring(index))
15.667 + : nm.substring(index);
15.668 + result = Long.valueOf(constant, radix);
15.669 + }
15.670 + return result;
15.671 + }
15.672 +
15.673 + /**
15.674 + * The value of the {@code Long}.
15.675 + *
15.676 + * @serial
15.677 + */
15.678 + private final long value;
15.679 +
15.680 + /**
15.681 + * Constructs a newly allocated {@code Long} object that
15.682 + * represents the specified {@code long} argument.
15.683 + *
15.684 + * @param value the value to be represented by the
15.685 + * {@code Long} object.
15.686 + */
15.687 + public Long(long value) {
15.688 + this.value = value;
15.689 + }
15.690 +
15.691 + /**
15.692 + * Constructs a newly allocated {@code Long} object that
15.693 + * represents the {@code long} value indicated by the
15.694 + * {@code String} parameter. The string is converted to a
15.695 + * {@code long} value in exactly the manner used by the
15.696 + * {@code parseLong} method for radix 10.
15.697 + *
15.698 + * @param s the {@code String} to be converted to a
15.699 + * {@code Long}.
15.700 + * @throws NumberFormatException if the {@code String} does not
15.701 + * contain a parsable {@code long}.
15.702 + * @see java.lang.Long#parseLong(java.lang.String, int)
15.703 + */
15.704 + public Long(String s) throws NumberFormatException {
15.705 + this.value = parseLong(s, 10);
15.706 + }
15.707 +
15.708 + /**
15.709 + * Returns the value of this {@code Long} as a
15.710 + * {@code byte}.
15.711 + */
15.712 + public byte byteValue() {
15.713 + return (byte)value;
15.714 + }
15.715 +
15.716 + /**
15.717 + * Returns the value of this {@code Long} as a
15.718 + * {@code short}.
15.719 + */
15.720 + public short shortValue() {
15.721 + return (short)value;
15.722 + }
15.723 +
15.724 + /**
15.725 + * Returns the value of this {@code Long} as an
15.726 + * {@code int}.
15.727 + */
15.728 + public int intValue() {
15.729 + return (int)value;
15.730 + }
15.731 +
15.732 + /**
15.733 + * Returns the value of this {@code Long} as a
15.734 + * {@code long} value.
15.735 + */
15.736 + public long longValue() {
15.737 + return (long)value;
15.738 + }
15.739 +
15.740 + /**
15.741 + * Returns the value of this {@code Long} as a
15.742 + * {@code float}.
15.743 + */
15.744 + public float floatValue() {
15.745 + return (float)value;
15.746 + }
15.747 +
15.748 + /**
15.749 + * Returns the value of this {@code Long} as a
15.750 + * {@code double}.
15.751 + */
15.752 + public double doubleValue() {
15.753 + return (double)value;
15.754 + }
15.755 +
15.756 + /**
15.757 + * Returns a {@code String} object representing this
15.758 + * {@code Long}'s value. The value is converted to signed
15.759 + * decimal representation and returned as a string, exactly as if
15.760 + * the {@code long} value were given as an argument to the
15.761 + * {@link java.lang.Long#toString(long)} method.
15.762 + *
15.763 + * @return a string representation of the value of this object in
15.764 + * base 10.
15.765 + */
15.766 + public String toString() {
15.767 + return toString(value);
15.768 + }
15.769 +
15.770 + /**
15.771 + * Returns a hash code for this {@code Long}. The result is
15.772 + * the exclusive OR of the two halves of the primitive
15.773 + * {@code long} value held by this {@code Long}
15.774 + * object. That is, the hashcode is the value of the expression:
15.775 + *
15.776 + * <blockquote>
15.777 + * {@code (int)(this.longValue()^(this.longValue()>>>32))}
15.778 + * </blockquote>
15.779 + *
15.780 + * @return a hash code value for this object.
15.781 + */
15.782 + public int hashCode() {
15.783 + return (int)(value ^ (value >>> 32));
15.784 + }
15.785 +
15.786 + /**
15.787 + * Compares this object to the specified object. The result is
15.788 + * {@code true} if and only if the argument is not
15.789 + * {@code null} and is a {@code Long} object that
15.790 + * contains the same {@code long} value as this object.
15.791 + *
15.792 + * @param obj the object to compare with.
15.793 + * @return {@code true} if the objects are the same;
15.794 + * {@code false} otherwise.
15.795 + */
15.796 + public boolean equals(Object obj) {
15.797 + if (obj instanceof Long) {
15.798 + return value == ((Long)obj).longValue();
15.799 + }
15.800 + return false;
15.801 + }
15.802 +
15.803 + /**
15.804 + * Determines the {@code long} value of the system property
15.805 + * with the specified name.
15.806 + *
15.807 + * <p>The first argument is treated as the name of a system property.
15.808 + * System properties are accessible through the {@link
15.809 + * java.lang.System#getProperty(java.lang.String)} method. The
15.810 + * string value of this property is then interpreted as a
15.811 + * {@code long} value and a {@code Long} object
15.812 + * representing this value is returned. Details of possible
15.813 + * numeric formats can be found with the definition of
15.814 + * {@code getProperty}.
15.815 + *
15.816 + * <p>If there is no property with the specified name, if the
15.817 + * specified name is empty or {@code null}, or if the
15.818 + * property does not have the correct numeric format, then
15.819 + * {@code null} is returned.
15.820 + *
15.821 + * <p>In other words, this method returns a {@code Long} object equal to
15.822 + * the value of:
15.823 + *
15.824 + * <blockquote>
15.825 + * {@code getLong(nm, null)}
15.826 + * </blockquote>
15.827 + *
15.828 + * @param nm property name.
15.829 + * @return the {@code Long} value of the property.
15.830 + * @see java.lang.System#getProperty(java.lang.String)
15.831 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
15.832 + */
15.833 + public static Long getLong(String nm) {
15.834 + return getLong(nm, null);
15.835 + }
15.836 +
15.837 + /**
15.838 + * Determines the {@code long} value of the system property
15.839 + * with the specified name.
15.840 + *
15.841 + * <p>The first argument is treated as the name of a system property.
15.842 + * System properties are accessible through the {@link
15.843 + * java.lang.System#getProperty(java.lang.String)} method. The
15.844 + * string value of this property is then interpreted as a
15.845 + * {@code long} value and a {@code Long} object
15.846 + * representing this value is returned. Details of possible
15.847 + * numeric formats can be found with the definition of
15.848 + * {@code getProperty}.
15.849 + *
15.850 + * <p>The second argument is the default value. A {@code Long} object
15.851 + * that represents the value of the second argument is returned if there
15.852 + * is no property of the specified name, if the property does not have
15.853 + * the correct numeric format, or if the specified name is empty or null.
15.854 + *
15.855 + * <p>In other words, this method returns a {@code Long} object equal
15.856 + * to the value of:
15.857 + *
15.858 + * <blockquote>
15.859 + * {@code getLong(nm, new Long(val))}
15.860 + * </blockquote>
15.861 + *
15.862 + * but in practice it may be implemented in a manner such as:
15.863 + *
15.864 + * <blockquote><pre>
15.865 + * Long result = getLong(nm, null);
15.866 + * return (result == null) ? new Long(val) : result;
15.867 + * </pre></blockquote>
15.868 + *
15.869 + * to avoid the unnecessary allocation of a {@code Long} object when
15.870 + * the default value is not needed.
15.871 + *
15.872 + * @param nm property name.
15.873 + * @param val default value.
15.874 + * @return the {@code Long} value of the property.
15.875 + * @see java.lang.System#getProperty(java.lang.String)
15.876 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
15.877 + */
15.878 + public static Long getLong(String nm, long val) {
15.879 + Long result = Long.getLong(nm, null);
15.880 + return (result == null) ? Long.valueOf(val) : result;
15.881 + }
15.882 +
15.883 + /**
15.884 + * Returns the {@code long} value of the system property with
15.885 + * the specified name. The first argument is treated as the name
15.886 + * of a system property. System properties are accessible through
15.887 + * the {@link java.lang.System#getProperty(java.lang.String)}
15.888 + * method. The string value of this property is then interpreted
15.889 + * as a {@code long} value, as per the
15.890 + * {@code Long.decode} method, and a {@code Long} object
15.891 + * representing this value is returned.
15.892 + *
15.893 + * <ul>
15.894 + * <li>If the property value begins with the two ASCII characters
15.895 + * {@code 0x} or the ASCII character {@code #}, not followed by
15.896 + * a minus sign, then the rest of it is parsed as a hexadecimal integer
15.897 + * exactly as for the method {@link #valueOf(java.lang.String, int)}
15.898 + * with radix 16.
15.899 + * <li>If the property value begins with the ASCII character
15.900 + * {@code 0} followed by another character, it is parsed as
15.901 + * an octal integer exactly as by the method {@link
15.902 + * #valueOf(java.lang.String, int)} with radix 8.
15.903 + * <li>Otherwise the property value is parsed as a decimal
15.904 + * integer exactly as by the method
15.905 + * {@link #valueOf(java.lang.String, int)} with radix 10.
15.906 + * </ul>
15.907 + *
15.908 + * <p>Note that, in every case, neither {@code L}
15.909 + * (<code>'\u004C'</code>) nor {@code l}
15.910 + * (<code>'\u006C'</code>) is permitted to appear at the end
15.911 + * of the property value as a type indicator, as would be
15.912 + * permitted in Java programming language source code.
15.913 + *
15.914 + * <p>The second argument is the default value. The default value is
15.915 + * returned if there is no property of the specified name, if the
15.916 + * property does not have the correct numeric format, or if the
15.917 + * specified name is empty or {@code null}.
15.918 + *
15.919 + * @param nm property name.
15.920 + * @param val default value.
15.921 + * @return the {@code Long} value of the property.
15.922 + * @see java.lang.System#getProperty(java.lang.String)
15.923 + * @see java.lang.System#getProperty(java.lang.String, java.lang.String)
15.924 + * @see java.lang.Long#decode
15.925 + */
15.926 + public static Long getLong(String nm, Long val) {
15.927 + String v = null;
15.928 + try {
15.929 + v = System.getProperty(nm);
15.930 + } catch (IllegalArgumentException e) {
15.931 + } catch (NullPointerException e) {
15.932 + }
15.933 + if (v != null) {
15.934 + try {
15.935 + return Long.decode(v);
15.936 + } catch (NumberFormatException e) {
15.937 + }
15.938 + }
15.939 + return val;
15.940 + }
15.941 +
15.942 + /**
15.943 + * Compares two {@code Long} objects numerically.
15.944 + *
15.945 + * @param anotherLong the {@code Long} to be compared.
15.946 + * @return the value {@code 0} if this {@code Long} is
15.947 + * equal to the argument {@code Long}; a value less than
15.948 + * {@code 0} if this {@code Long} is numerically less
15.949 + * than the argument {@code Long}; and a value greater
15.950 + * than {@code 0} if this {@code Long} is numerically
15.951 + * greater than the argument {@code Long} (signed
15.952 + * comparison).
15.953 + * @since 1.2
15.954 + */
15.955 + public int compareTo(Long anotherLong) {
15.956 + return compare(this.value, anotherLong.value);
15.957 + }
15.958 +
15.959 + /**
15.960 + * Compares two {@code long} values numerically.
15.961 + * The value returned is identical to what would be returned by:
15.962 + * <pre>
15.963 + * Long.valueOf(x).compareTo(Long.valueOf(y))
15.964 + * </pre>
15.965 + *
15.966 + * @param x the first {@code long} to compare
15.967 + * @param y the second {@code long} to compare
15.968 + * @return the value {@code 0} if {@code x == y};
15.969 + * a value less than {@code 0} if {@code x < y}; and
15.970 + * a value greater than {@code 0} if {@code x > y}
15.971 + * @since 1.7
15.972 + */
15.973 + public static int compare(long x, long y) {
15.974 + return (x < y) ? -1 : ((x == y) ? 0 : 1);
15.975 + }
15.976 +
15.977 +
15.978 + // Bit Twiddling
15.979 +
15.980 + /**
15.981 + * The number of bits used to represent a {@code long} value in two's
15.982 + * complement binary form.
15.983 + *
15.984 + * @since 1.5
15.985 + */
15.986 + public static final int SIZE = 64;
15.987 +
15.988 + /**
15.989 + * Returns a {@code long} value with at most a single one-bit, in the
15.990 + * position of the highest-order ("leftmost") one-bit in the specified
15.991 + * {@code long} value. Returns zero if the specified value has no
15.992 + * one-bits in its two's complement binary representation, that is, if it
15.993 + * is equal to zero.
15.994 + *
15.995 + * @return a {@code long} value with a single one-bit, in the position
15.996 + * of the highest-order one-bit in the specified value, or zero if
15.997 + * the specified value is itself equal to zero.
15.998 + * @since 1.5
15.999 + */
15.1000 + public static long highestOneBit(long i) {
15.1001 + // HD, Figure 3-1
15.1002 + i |= (i >> 1);
15.1003 + i |= (i >> 2);
15.1004 + i |= (i >> 4);
15.1005 + i |= (i >> 8);
15.1006 + i |= (i >> 16);
15.1007 + i |= (i >> 32);
15.1008 + return i - (i >>> 1);
15.1009 + }
15.1010 +
15.1011 + /**
15.1012 + * Returns a {@code long} value with at most a single one-bit, in the
15.1013 + * position of the lowest-order ("rightmost") one-bit in the specified
15.1014 + * {@code long} value. Returns zero if the specified value has no
15.1015 + * one-bits in its two's complement binary representation, that is, if it
15.1016 + * is equal to zero.
15.1017 + *
15.1018 + * @return a {@code long} value with a single one-bit, in the position
15.1019 + * of the lowest-order one-bit in the specified value, or zero if
15.1020 + * the specified value is itself equal to zero.
15.1021 + * @since 1.5
15.1022 + */
15.1023 + public static long lowestOneBit(long i) {
15.1024 + // HD, Section 2-1
15.1025 + return i & -i;
15.1026 + }
15.1027 +
15.1028 + /**
15.1029 + * Returns the number of zero bits preceding the highest-order
15.1030 + * ("leftmost") one-bit in the two's complement binary representation
15.1031 + * of the specified {@code long} value. Returns 64 if the
15.1032 + * specified value has no one-bits in its two's complement representation,
15.1033 + * in other words if it is equal to zero.
15.1034 + *
15.1035 + * <p>Note that this method is closely related to the logarithm base 2.
15.1036 + * For all positive {@code long} values x:
15.1037 + * <ul>
15.1038 + * <li>floor(log<sub>2</sub>(x)) = {@code 63 - numberOfLeadingZeros(x)}
15.1039 + * <li>ceil(log<sub>2</sub>(x)) = {@code 64 - numberOfLeadingZeros(x - 1)}
15.1040 + * </ul>
15.1041 + *
15.1042 + * @return the number of zero bits preceding the highest-order
15.1043 + * ("leftmost") one-bit in the two's complement binary representation
15.1044 + * of the specified {@code long} value, or 64 if the value
15.1045 + * is equal to zero.
15.1046 + * @since 1.5
15.1047 + */
15.1048 + public static int numberOfLeadingZeros(long i) {
15.1049 + // HD, Figure 5-6
15.1050 + if (i == 0)
15.1051 + return 64;
15.1052 + int n = 1;
15.1053 + int x = (int)(i >>> 32);
15.1054 + if (x == 0) { n += 32; x = (int)i; }
15.1055 + if (x >>> 16 == 0) { n += 16; x <<= 16; }
15.1056 + if (x >>> 24 == 0) { n += 8; x <<= 8; }
15.1057 + if (x >>> 28 == 0) { n += 4; x <<= 4; }
15.1058 + if (x >>> 30 == 0) { n += 2; x <<= 2; }
15.1059 + n -= x >>> 31;
15.1060 + return n;
15.1061 + }
15.1062 +
15.1063 + /**
15.1064 + * Returns the number of zero bits following the lowest-order ("rightmost")
15.1065 + * one-bit in the two's complement binary representation of the specified
15.1066 + * {@code long} value. Returns 64 if the specified value has no
15.1067 + * one-bits in its two's complement representation, in other words if it is
15.1068 + * equal to zero.
15.1069 + *
15.1070 + * @return the number of zero bits following the lowest-order ("rightmost")
15.1071 + * one-bit in the two's complement binary representation of the
15.1072 + * specified {@code long} value, or 64 if the value is equal
15.1073 + * to zero.
15.1074 + * @since 1.5
15.1075 + */
15.1076 + public static int numberOfTrailingZeros(long i) {
15.1077 + // HD, Figure 5-14
15.1078 + int x, y;
15.1079 + if (i == 0) return 64;
15.1080 + int n = 63;
15.1081 + y = (int)i; if (y != 0) { n = n -32; x = y; } else x = (int)(i>>>32);
15.1082 + y = x <<16; if (y != 0) { n = n -16; x = y; }
15.1083 + y = x << 8; if (y != 0) { n = n - 8; x = y; }
15.1084 + y = x << 4; if (y != 0) { n = n - 4; x = y; }
15.1085 + y = x << 2; if (y != 0) { n = n - 2; x = y; }
15.1086 + return n - ((x << 1) >>> 31);
15.1087 + }
15.1088 +
15.1089 + /**
15.1090 + * Returns the number of one-bits in the two's complement binary
15.1091 + * representation of the specified {@code long} value. This function is
15.1092 + * sometimes referred to as the <i>population count</i>.
15.1093 + *
15.1094 + * @return the number of one-bits in the two's complement binary
15.1095 + * representation of the specified {@code long} value.
15.1096 + * @since 1.5
15.1097 + */
15.1098 + public static int bitCount(long i) {
15.1099 + // HD, Figure 5-14
15.1100 + i = i - ((i >>> 1) & 0x5555555555555555L);
15.1101 + i = (i & 0x3333333333333333L) + ((i >>> 2) & 0x3333333333333333L);
15.1102 + i = (i + (i >>> 4)) & 0x0f0f0f0f0f0f0f0fL;
15.1103 + i = i + (i >>> 8);
15.1104 + i = i + (i >>> 16);
15.1105 + i = i + (i >>> 32);
15.1106 + return (int)i & 0x7f;
15.1107 + }
15.1108 +
15.1109 + /**
15.1110 + * Returns the value obtained by rotating the two's complement binary
15.1111 + * representation of the specified {@code long} value left by the
15.1112 + * specified number of bits. (Bits shifted out of the left hand, or
15.1113 + * high-order, side reenter on the right, or low-order.)
15.1114 + *
15.1115 + * <p>Note that left rotation with a negative distance is equivalent to
15.1116 + * right rotation: {@code rotateLeft(val, -distance) == rotateRight(val,
15.1117 + * distance)}. Note also that rotation by any multiple of 64 is a
15.1118 + * no-op, so all but the last six bits of the rotation distance can be
15.1119 + * ignored, even if the distance is negative: {@code rotateLeft(val,
15.1120 + * distance) == rotateLeft(val, distance & 0x3F)}.
15.1121 + *
15.1122 + * @return the value obtained by rotating the two's complement binary
15.1123 + * representation of the specified {@code long} value left by the
15.1124 + * specified number of bits.
15.1125 + * @since 1.5
15.1126 + */
15.1127 + public static long rotateLeft(long i, int distance) {
15.1128 + return (i << distance) | (i >>> -distance);
15.1129 + }
15.1130 +
15.1131 + /**
15.1132 + * Returns the value obtained by rotating the two's complement binary
15.1133 + * representation of the specified {@code long} value right by the
15.1134 + * specified number of bits. (Bits shifted out of the right hand, or
15.1135 + * low-order, side reenter on the left, or high-order.)
15.1136 + *
15.1137 + * <p>Note that right rotation with a negative distance is equivalent to
15.1138 + * left rotation: {@code rotateRight(val, -distance) == rotateLeft(val,
15.1139 + * distance)}. Note also that rotation by any multiple of 64 is a
15.1140 + * no-op, so all but the last six bits of the rotation distance can be
15.1141 + * ignored, even if the distance is negative: {@code rotateRight(val,
15.1142 + * distance) == rotateRight(val, distance & 0x3F)}.
15.1143 + *
15.1144 + * @return the value obtained by rotating the two's complement binary
15.1145 + * representation of the specified {@code long} value right by the
15.1146 + * specified number of bits.
15.1147 + * @since 1.5
15.1148 + */
15.1149 + public static long rotateRight(long i, int distance) {
15.1150 + return (i >>> distance) | (i << -distance);
15.1151 + }
15.1152 +
15.1153 + /**
15.1154 + * Returns the value obtained by reversing the order of the bits in the
15.1155 + * two's complement binary representation of the specified {@code long}
15.1156 + * value.
15.1157 + *
15.1158 + * @return the value obtained by reversing order of the bits in the
15.1159 + * specified {@code long} value.
15.1160 + * @since 1.5
15.1161 + */
15.1162 + public static long reverse(long i) {
15.1163 + // HD, Figure 7-1
15.1164 + i = (i & 0x5555555555555555L) << 1 | (i >>> 1) & 0x5555555555555555L;
15.1165 + i = (i & 0x3333333333333333L) << 2 | (i >>> 2) & 0x3333333333333333L;
15.1166 + i = (i & 0x0f0f0f0f0f0f0f0fL) << 4 | (i >>> 4) & 0x0f0f0f0f0f0f0f0fL;
15.1167 + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL;
15.1168 + i = (i << 48) | ((i & 0xffff0000L) << 16) |
15.1169 + ((i >>> 16) & 0xffff0000L) | (i >>> 48);
15.1170 + return i;
15.1171 + }
15.1172 +
15.1173 + /**
15.1174 + * Returns the signum function of the specified {@code long} value. (The
15.1175 + * return value is -1 if the specified value is negative; 0 if the
15.1176 + * specified value is zero; and 1 if the specified value is positive.)
15.1177 + *
15.1178 + * @return the signum function of the specified {@code long} value.
15.1179 + * @since 1.5
15.1180 + */
15.1181 + public static int signum(long i) {
15.1182 + // HD, Section 2-7
15.1183 + return (int) ((i >> 63) | (-i >>> 63));
15.1184 + }
15.1185 +
15.1186 + /**
15.1187 + * Returns the value obtained by reversing the order of the bytes in the
15.1188 + * two's complement representation of the specified {@code long} value.
15.1189 + *
15.1190 + * @return the value obtained by reversing the bytes in the specified
15.1191 + * {@code long} value.
15.1192 + * @since 1.5
15.1193 + */
15.1194 + public static long reverseBytes(long i) {
15.1195 + i = (i & 0x00ff00ff00ff00ffL) << 8 | (i >>> 8) & 0x00ff00ff00ff00ffL;
15.1196 + return (i << 48) | ((i & 0xffff0000L) << 16) |
15.1197 + ((i >>> 16) & 0xffff0000L) | (i >>> 48);
15.1198 + }
15.1199 +
15.1200 + /** use serialVersionUID from JDK 1.0.2 for interoperability */
15.1201 + private static final long serialVersionUID = 4290774380558885855L;
15.1202 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/emul/src/main/java/java/lang/Math.java Sun Sep 30 14:37:39 2012 -0700
16.3 @@ -0,0 +1,1526 @@
16.4 +/*
16.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
16.7 + *
16.8 + * This code is free software; you can redistribute it and/or modify it
16.9 + * under the terms of the GNU General Public License version 2 only, as
16.10 + * published by the Free Software Foundation. Oracle designates this
16.11 + * particular file as subject to the "Classpath" exception as provided
16.12 + * by Oracle in the LICENSE file that accompanied this code.
16.13 + *
16.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
16.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16.17 + * version 2 for more details (a copy is included in the LICENSE file that
16.18 + * accompanied this code).
16.19 + *
16.20 + * You should have received a copy of the GNU General Public License version
16.21 + * 2 along with this work; if not, write to the Free Software Foundation,
16.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16.23 + *
16.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
16.25 + * or visit www.oracle.com if you need additional information or have any
16.26 + * questions.
16.27 + */
16.28 +
16.29 +package java.lang;
16.30 +import java.util.Random;
16.31 +
16.32 +
16.33 +/**
16.34 + * The class {@code Math} contains methods for performing basic
16.35 + * numeric operations such as the elementary exponential, logarithm,
16.36 + * square root, and trigonometric functions.
16.37 + *
16.38 + * <p>Unlike some of the numeric methods of class
16.39 + * {@code StrictMath}, all implementations of the equivalent
16.40 + * functions of class {@code Math} are not defined to return the
16.41 + * bit-for-bit same results. This relaxation permits
16.42 + * better-performing implementations where strict reproducibility is
16.43 + * not required.
16.44 + *
16.45 + * <p>By default many of the {@code Math} methods simply call
16.46 + * the equivalent method in {@code StrictMath} for their
16.47 + * implementation. Code generators are encouraged to use
16.48 + * platform-specific native libraries or microprocessor instructions,
16.49 + * where available, to provide higher-performance implementations of
16.50 + * {@code Math} methods. Such higher-performance
16.51 + * implementations still must conform to the specification for
16.52 + * {@code Math}.
16.53 + *
16.54 + * <p>The quality of implementation specifications concern two
16.55 + * properties, accuracy of the returned result and monotonicity of the
16.56 + * method. Accuracy of the floating-point {@code Math} methods
16.57 + * is measured in terms of <i>ulps</i>, units in the last place. For
16.58 + * a given floating-point format, an ulp of a specific real number
16.59 + * value is the distance between the two floating-point values
16.60 + * bracketing that numerical value. When discussing the accuracy of a
16.61 + * method as a whole rather than at a specific argument, the number of
16.62 + * ulps cited is for the worst-case error at any argument. If a
16.63 + * method always has an error less than 0.5 ulps, the method always
16.64 + * returns the floating-point number nearest the exact result; such a
16.65 + * method is <i>correctly rounded</i>. A correctly rounded method is
16.66 + * generally the best a floating-point approximation can be; however,
16.67 + * it is impractical for many floating-point methods to be correctly
16.68 + * rounded. Instead, for the {@code Math} class, a larger error
16.69 + * bound of 1 or 2 ulps is allowed for certain methods. Informally,
16.70 + * with a 1 ulp error bound, when the exact result is a representable
16.71 + * number, the exact result should be returned as the computed result;
16.72 + * otherwise, either of the two floating-point values which bracket
16.73 + * the exact result may be returned. For exact results large in
16.74 + * magnitude, one of the endpoints of the bracket may be infinite.
16.75 + * Besides accuracy at individual arguments, maintaining proper
16.76 + * relations between the method at different arguments is also
16.77 + * important. Therefore, most methods with more than 0.5 ulp errors
16.78 + * are required to be <i>semi-monotonic</i>: whenever the mathematical
16.79 + * function is non-decreasing, so is the floating-point approximation,
16.80 + * likewise, whenever the mathematical function is non-increasing, so
16.81 + * is the floating-point approximation. Not all approximations that
16.82 + * have 1 ulp accuracy will automatically meet the monotonicity
16.83 + * requirements.
16.84 + *
16.85 + * @author unascribed
16.86 + * @author Joseph D. Darcy
16.87 + * @since JDK1.0
16.88 + */
16.89 +
16.90 +public final class Math {
16.91 +
16.92 + /**
16.93 + * Don't let anyone instantiate this class.
16.94 + */
16.95 + private Math() {}
16.96 +
16.97 + /**
16.98 + * The {@code double} value that is closer than any other to
16.99 + * <i>e</i>, the base of the natural logarithms.
16.100 + */
16.101 + public static final double E = 2.7182818284590452354;
16.102 +
16.103 + /**
16.104 + * The {@code double} value that is closer than any other to
16.105 + * <i>pi</i>, the ratio of the circumference of a circle to its
16.106 + * diameter.
16.107 + */
16.108 + public static final double PI = 3.14159265358979323846;
16.109 +
16.110 + /**
16.111 + * Returns the trigonometric sine of an angle. Special cases:
16.112 + * <ul><li>If the argument is NaN or an infinity, then the
16.113 + * result is NaN.
16.114 + * <li>If the argument is zero, then the result is a zero with the
16.115 + * same sign as the argument.</ul>
16.116 + *
16.117 + * <p>The computed result must be within 1 ulp of the exact result.
16.118 + * Results must be semi-monotonic.
16.119 + *
16.120 + * @param a an angle, in radians.
16.121 + * @return the sine of the argument.
16.122 + */
16.123 + public static double sin(double a) {
16.124 + return StrictMath.sin(a); // default impl. delegates to StrictMath
16.125 + }
16.126 +
16.127 + /**
16.128 + * Returns the trigonometric cosine of an angle. Special cases:
16.129 + * <ul><li>If the argument is NaN or an infinity, then the
16.130 + * result is NaN.</ul>
16.131 + *
16.132 + * <p>The computed result must be within 1 ulp of the exact result.
16.133 + * Results must be semi-monotonic.
16.134 + *
16.135 + * @param a an angle, in radians.
16.136 + * @return the cosine of the argument.
16.137 + */
16.138 + public static double cos(double a) {
16.139 + return StrictMath.cos(a); // default impl. delegates to StrictMath
16.140 + }
16.141 +
16.142 + /**
16.143 + * Returns the trigonometric tangent of an angle. Special cases:
16.144 + * <ul><li>If the argument is NaN or an infinity, then the result
16.145 + * is NaN.
16.146 + * <li>If the argument is zero, then the result is a zero with the
16.147 + * same sign as the argument.</ul>
16.148 + *
16.149 + * <p>The computed result must be within 1 ulp of the exact result.
16.150 + * Results must be semi-monotonic.
16.151 + *
16.152 + * @param a an angle, in radians.
16.153 + * @return the tangent of the argument.
16.154 + */
16.155 + public static double tan(double a) {
16.156 + return StrictMath.tan(a); // default impl. delegates to StrictMath
16.157 + }
16.158 +
16.159 + /**
16.160 + * Returns the arc sine of a value; the returned angle is in the
16.161 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
16.162 + * <ul><li>If the argument is NaN or its absolute value is greater
16.163 + * than 1, then the result is NaN.
16.164 + * <li>If the argument is zero, then the result is a zero with the
16.165 + * same sign as the argument.</ul>
16.166 + *
16.167 + * <p>The computed result must be within 1 ulp of the exact result.
16.168 + * Results must be semi-monotonic.
16.169 + *
16.170 + * @param a the value whose arc sine is to be returned.
16.171 + * @return the arc sine of the argument.
16.172 + */
16.173 + public static double asin(double a) {
16.174 + return StrictMath.asin(a); // default impl. delegates to StrictMath
16.175 + }
16.176 +
16.177 + /**
16.178 + * Returns the arc cosine of a value; the returned angle is in the
16.179 + * range 0.0 through <i>pi</i>. Special case:
16.180 + * <ul><li>If the argument is NaN or its absolute value is greater
16.181 + * than 1, then the result is NaN.</ul>
16.182 + *
16.183 + * <p>The computed result must be within 1 ulp of the exact result.
16.184 + * Results must be semi-monotonic.
16.185 + *
16.186 + * @param a the value whose arc cosine is to be returned.
16.187 + * @return the arc cosine of the argument.
16.188 + */
16.189 + public static double acos(double a) {
16.190 + return StrictMath.acos(a); // default impl. delegates to StrictMath
16.191 + }
16.192 +
16.193 + /**
16.194 + * Returns the arc tangent of a value; the returned angle is in the
16.195 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
16.196 + * <ul><li>If the argument is NaN, then the result is NaN.
16.197 + * <li>If the argument is zero, then the result is a zero with the
16.198 + * same sign as the argument.</ul>
16.199 + *
16.200 + * <p>The computed result must be within 1 ulp of the exact result.
16.201 + * Results must be semi-monotonic.
16.202 + *
16.203 + * @param a the value whose arc tangent is to be returned.
16.204 + * @return the arc tangent of the argument.
16.205 + */
16.206 + public static double atan(double a) {
16.207 + return StrictMath.atan(a); // default impl. delegates to StrictMath
16.208 + }
16.209 +
16.210 + /**
16.211 + * Converts an angle measured in degrees to an approximately
16.212 + * equivalent angle measured in radians. The conversion from
16.213 + * degrees to radians is generally inexact.
16.214 + *
16.215 + * @param angdeg an angle, in degrees
16.216 + * @return the measurement of the angle {@code angdeg}
16.217 + * in radians.
16.218 + * @since 1.2
16.219 + */
16.220 + public static double toRadians(double angdeg) {
16.221 + return angdeg / 180.0 * PI;
16.222 + }
16.223 +
16.224 + /**
16.225 + * Converts an angle measured in radians to an approximately
16.226 + * equivalent angle measured in degrees. The conversion from
16.227 + * radians to degrees is generally inexact; users should
16.228 + * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
16.229 + * equal {@code 0.0}.
16.230 + *
16.231 + * @param angrad an angle, in radians
16.232 + * @return the measurement of the angle {@code angrad}
16.233 + * in degrees.
16.234 + * @since 1.2
16.235 + */
16.236 + public static double toDegrees(double angrad) {
16.237 + return angrad * 180.0 / PI;
16.238 + }
16.239 +
16.240 + /**
16.241 + * Returns Euler's number <i>e</i> raised to the power of a
16.242 + * {@code double} value. Special cases:
16.243 + * <ul><li>If the argument is NaN, the result is NaN.
16.244 + * <li>If the argument is positive infinity, then the result is
16.245 + * positive infinity.
16.246 + * <li>If the argument is negative infinity, then the result is
16.247 + * positive zero.</ul>
16.248 + *
16.249 + * <p>The computed result must be within 1 ulp of the exact result.
16.250 + * Results must be semi-monotonic.
16.251 + *
16.252 + * @param a the exponent to raise <i>e</i> to.
16.253 + * @return the value <i>e</i><sup>{@code a}</sup>,
16.254 + * where <i>e</i> is the base of the natural logarithms.
16.255 + */
16.256 + public static double exp(double a) {
16.257 + return StrictMath.exp(a); // default impl. delegates to StrictMath
16.258 + }
16.259 +
16.260 + /**
16.261 + * Returns the natural logarithm (base <i>e</i>) of a {@code double}
16.262 + * value. Special cases:
16.263 + * <ul><li>If the argument is NaN or less than zero, then the result
16.264 + * is NaN.
16.265 + * <li>If the argument is positive infinity, then the result is
16.266 + * positive infinity.
16.267 + * <li>If the argument is positive zero or negative zero, then the
16.268 + * result is negative infinity.</ul>
16.269 + *
16.270 + * <p>The computed result must be within 1 ulp of the exact result.
16.271 + * Results must be semi-monotonic.
16.272 + *
16.273 + * @param a a value
16.274 + * @return the value ln {@code a}, the natural logarithm of
16.275 + * {@code a}.
16.276 + */
16.277 + public static double log(double a) {
16.278 + return StrictMath.log(a); // default impl. delegates to StrictMath
16.279 + }
16.280 +
16.281 + /**
16.282 + * Returns the base 10 logarithm of a {@code double} value.
16.283 + * Special cases:
16.284 + *
16.285 + * <ul><li>If the argument is NaN or less than zero, then the result
16.286 + * is NaN.
16.287 + * <li>If the argument is positive infinity, then the result is
16.288 + * positive infinity.
16.289 + * <li>If the argument is positive zero or negative zero, then the
16.290 + * result is negative infinity.
16.291 + * <li> If the argument is equal to 10<sup><i>n</i></sup> for
16.292 + * integer <i>n</i>, then the result is <i>n</i>.
16.293 + * </ul>
16.294 + *
16.295 + * <p>The computed result must be within 1 ulp of the exact result.
16.296 + * Results must be semi-monotonic.
16.297 + *
16.298 + * @param a a value
16.299 + * @return the base 10 logarithm of {@code a}.
16.300 + * @since 1.5
16.301 + */
16.302 + public static double log10(double a) {
16.303 + return StrictMath.log10(a); // default impl. delegates to StrictMath
16.304 + }
16.305 +
16.306 + /**
16.307 + * Returns the correctly rounded positive square root of a
16.308 + * {@code double} value.
16.309 + * Special cases:
16.310 + * <ul><li>If the argument is NaN or less than zero, then the result
16.311 + * is NaN.
16.312 + * <li>If the argument is positive infinity, then the result is positive
16.313 + * infinity.
16.314 + * <li>If the argument is positive zero or negative zero, then the
16.315 + * result is the same as the argument.</ul>
16.316 + * Otherwise, the result is the {@code double} value closest to
16.317 + * the true mathematical square root of the argument value.
16.318 + *
16.319 + * @param a a value.
16.320 + * @return the positive square root of {@code a}.
16.321 + * If the argument is NaN or less than zero, the result is NaN.
16.322 + */
16.323 + public static double sqrt(double a) {
16.324 + return StrictMath.sqrt(a); // default impl. delegates to StrictMath
16.325 + // Note that hardware sqrt instructions
16.326 + // frequently can be directly used by JITs
16.327 + // and should be much faster than doing
16.328 + // Math.sqrt in software.
16.329 + }
16.330 +
16.331 +
16.332 + /**
16.333 + * Returns the cube root of a {@code double} value. For
16.334 + * positive finite {@code x}, {@code cbrt(-x) ==
16.335 + * -cbrt(x)}; that is, the cube root of a negative value is
16.336 + * the negative of the cube root of that value's magnitude.
16.337 + *
16.338 + * Special cases:
16.339 + *
16.340 + * <ul>
16.341 + *
16.342 + * <li>If the argument is NaN, then the result is NaN.
16.343 + *
16.344 + * <li>If the argument is infinite, then the result is an infinity
16.345 + * with the same sign as the argument.
16.346 + *
16.347 + * <li>If the argument is zero, then the result is a zero with the
16.348 + * same sign as the argument.
16.349 + *
16.350 + * </ul>
16.351 + *
16.352 + * <p>The computed result must be within 1 ulp of the exact result.
16.353 + *
16.354 + * @param a a value.
16.355 + * @return the cube root of {@code a}.
16.356 + * @since 1.5
16.357 + */
16.358 + public static double cbrt(double a) {
16.359 + return StrictMath.cbrt(a);
16.360 + }
16.361 +
16.362 + /**
16.363 + * Computes the remainder operation on two arguments as prescribed
16.364 + * by the IEEE 754 standard.
16.365 + * The remainder value is mathematically equal to
16.366 + * <code>f1 - f2</code> × <i>n</i>,
16.367 + * where <i>n</i> is the mathematical integer closest to the exact
16.368 + * mathematical value of the quotient {@code f1/f2}, and if two
16.369 + * mathematical integers are equally close to {@code f1/f2},
16.370 + * then <i>n</i> is the integer that is even. If the remainder is
16.371 + * zero, its sign is the same as the sign of the first argument.
16.372 + * Special cases:
16.373 + * <ul><li>If either argument is NaN, or the first argument is infinite,
16.374 + * or the second argument is positive zero or negative zero, then the
16.375 + * result is NaN.
16.376 + * <li>If the first argument is finite and the second argument is
16.377 + * infinite, then the result is the same as the first argument.</ul>
16.378 + *
16.379 + * @param f1 the dividend.
16.380 + * @param f2 the divisor.
16.381 + * @return the remainder when {@code f1} is divided by
16.382 + * {@code f2}.
16.383 + */
16.384 + public static double IEEEremainder(double f1, double f2) {
16.385 + return StrictMath.IEEEremainder(f1, f2); // delegate to StrictMath
16.386 + }
16.387 +
16.388 + /**
16.389 + * Returns the smallest (closest to negative infinity)
16.390 + * {@code double} value that is greater than or equal to the
16.391 + * argument and is equal to a mathematical integer. Special cases:
16.392 + * <ul><li>If the argument value is already equal to a
16.393 + * mathematical integer, then the result is the same as the
16.394 + * argument. <li>If the argument is NaN or an infinity or
16.395 + * positive zero or negative zero, then the result is the same as
16.396 + * the argument. <li>If the argument value is less than zero but
16.397 + * greater than -1.0, then the result is negative zero.</ul> Note
16.398 + * that the value of {@code Math.ceil(x)} is exactly the
16.399 + * value of {@code -Math.floor(-x)}.
16.400 + *
16.401 + *
16.402 + * @param a a value.
16.403 + * @return the smallest (closest to negative infinity)
16.404 + * floating-point value that is greater than or equal to
16.405 + * the argument and is equal to a mathematical integer.
16.406 + */
16.407 + public static double ceil(double a) {
16.408 + return StrictMath.ceil(a); // default impl. delegates to StrictMath
16.409 + }
16.410 +
16.411 + /**
16.412 + * Returns the largest (closest to positive infinity)
16.413 + * {@code double} value that is less than or equal to the
16.414 + * argument and is equal to a mathematical integer. Special cases:
16.415 + * <ul><li>If the argument value is already equal to a
16.416 + * mathematical integer, then the result is the same as the
16.417 + * argument. <li>If the argument is NaN or an infinity or
16.418 + * positive zero or negative zero, then the result is the same as
16.419 + * the argument.</ul>
16.420 + *
16.421 + * @param a a value.
16.422 + * @return the largest (closest to positive infinity)
16.423 + * floating-point value that less than or equal to the argument
16.424 + * and is equal to a mathematical integer.
16.425 + */
16.426 + public static double floor(double a) {
16.427 + return StrictMath.floor(a); // default impl. delegates to StrictMath
16.428 + }
16.429 +
16.430 + /**
16.431 + * Returns the {@code double} value that is closest in value
16.432 + * to the argument and is equal to a mathematical integer. If two
16.433 + * {@code double} values that are mathematical integers are
16.434 + * equally close, the result is the integer value that is
16.435 + * even. Special cases:
16.436 + * <ul><li>If the argument value is already equal to a mathematical
16.437 + * integer, then the result is the same as the argument.
16.438 + * <li>If the argument is NaN or an infinity or positive zero or negative
16.439 + * zero, then the result is the same as the argument.</ul>
16.440 + *
16.441 + * @param a a {@code double} value.
16.442 + * @return the closest floating-point value to {@code a} that is
16.443 + * equal to a mathematical integer.
16.444 + */
16.445 + public static double rint(double a) {
16.446 + return StrictMath.rint(a); // default impl. delegates to StrictMath
16.447 + }
16.448 +
16.449 + /**
16.450 + * Returns the angle <i>theta</i> from the conversion of rectangular
16.451 + * coordinates ({@code x}, {@code y}) to polar
16.452 + * coordinates (r, <i>theta</i>).
16.453 + * This method computes the phase <i>theta</i> by computing an arc tangent
16.454 + * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
16.455 + * cases:
16.456 + * <ul><li>If either argument is NaN, then the result is NaN.
16.457 + * <li>If the first argument is positive zero and the second argument
16.458 + * is positive, or the first argument is positive and finite and the
16.459 + * second argument is positive infinity, then the result is positive
16.460 + * zero.
16.461 + * <li>If the first argument is negative zero and the second argument
16.462 + * is positive, or the first argument is negative and finite and the
16.463 + * second argument is positive infinity, then the result is negative zero.
16.464 + * <li>If the first argument is positive zero and the second argument
16.465 + * is negative, or the first argument is positive and finite and the
16.466 + * second argument is negative infinity, then the result is the
16.467 + * {@code double} value closest to <i>pi</i>.
16.468 + * <li>If the first argument is negative zero and the second argument
16.469 + * is negative, or the first argument is negative and finite and the
16.470 + * second argument is negative infinity, then the result is the
16.471 + * {@code double} value closest to -<i>pi</i>.
16.472 + * <li>If the first argument is positive and the second argument is
16.473 + * positive zero or negative zero, or the first argument is positive
16.474 + * infinity and the second argument is finite, then the result is the
16.475 + * {@code double} value closest to <i>pi</i>/2.
16.476 + * <li>If the first argument is negative and the second argument is
16.477 + * positive zero or negative zero, or the first argument is negative
16.478 + * infinity and the second argument is finite, then the result is the
16.479 + * {@code double} value closest to -<i>pi</i>/2.
16.480 + * <li>If both arguments are positive infinity, then the result is the
16.481 + * {@code double} value closest to <i>pi</i>/4.
16.482 + * <li>If the first argument is positive infinity and the second argument
16.483 + * is negative infinity, then the result is the {@code double}
16.484 + * value closest to 3*<i>pi</i>/4.
16.485 + * <li>If the first argument is negative infinity and the second argument
16.486 + * is positive infinity, then the result is the {@code double} value
16.487 + * closest to -<i>pi</i>/4.
16.488 + * <li>If both arguments are negative infinity, then the result is the
16.489 + * {@code double} value closest to -3*<i>pi</i>/4.</ul>
16.490 + *
16.491 + * <p>The computed result must be within 2 ulps of the exact result.
16.492 + * Results must be semi-monotonic.
16.493 + *
16.494 + * @param y the ordinate coordinate
16.495 + * @param x the abscissa coordinate
16.496 + * @return the <i>theta</i> component of the point
16.497 + * (<i>r</i>, <i>theta</i>)
16.498 + * in polar coordinates that corresponds to the point
16.499 + * (<i>x</i>, <i>y</i>) in Cartesian coordinates.
16.500 + */
16.501 + public static double atan2(double y, double x) {
16.502 + return StrictMath.atan2(y, x); // default impl. delegates to StrictMath
16.503 + }
16.504 +
16.505 + /**
16.506 + * Returns the value of the first argument raised to the power of the
16.507 + * second argument. Special cases:
16.508 + *
16.509 + * <ul><li>If the second argument is positive or negative zero, then the
16.510 + * result is 1.0.
16.511 + * <li>If the second argument is 1.0, then the result is the same as the
16.512 + * first argument.
16.513 + * <li>If the second argument is NaN, then the result is NaN.
16.514 + * <li>If the first argument is NaN and the second argument is nonzero,
16.515 + * then the result is NaN.
16.516 + *
16.517 + * <li>If
16.518 + * <ul>
16.519 + * <li>the absolute value of the first argument is greater than 1
16.520 + * and the second argument is positive infinity, or
16.521 + * <li>the absolute value of the first argument is less than 1 and
16.522 + * the second argument is negative infinity,
16.523 + * </ul>
16.524 + * then the result is positive infinity.
16.525 + *
16.526 + * <li>If
16.527 + * <ul>
16.528 + * <li>the absolute value of the first argument is greater than 1 and
16.529 + * the second argument is negative infinity, or
16.530 + * <li>the absolute value of the
16.531 + * first argument is less than 1 and the second argument is positive
16.532 + * infinity,
16.533 + * </ul>
16.534 + * then the result is positive zero.
16.535 + *
16.536 + * <li>If the absolute value of the first argument equals 1 and the
16.537 + * second argument is infinite, then the result is NaN.
16.538 + *
16.539 + * <li>If
16.540 + * <ul>
16.541 + * <li>the first argument is positive zero and the second argument
16.542 + * is greater than zero, or
16.543 + * <li>the first argument is positive infinity and the second
16.544 + * argument is less than zero,
16.545 + * </ul>
16.546 + * then the result is positive zero.
16.547 + *
16.548 + * <li>If
16.549 + * <ul>
16.550 + * <li>the first argument is positive zero and the second argument
16.551 + * is less than zero, or
16.552 + * <li>the first argument is positive infinity and the second
16.553 + * argument is greater than zero,
16.554 + * </ul>
16.555 + * then the result is positive infinity.
16.556 + *
16.557 + * <li>If
16.558 + * <ul>
16.559 + * <li>the first argument is negative zero and the second argument
16.560 + * is greater than zero but not a finite odd integer, or
16.561 + * <li>the first argument is negative infinity and the second
16.562 + * argument is less than zero but not a finite odd integer,
16.563 + * </ul>
16.564 + * then the result is positive zero.
16.565 + *
16.566 + * <li>If
16.567 + * <ul>
16.568 + * <li>the first argument is negative zero and the second argument
16.569 + * is a positive finite odd integer, or
16.570 + * <li>the first argument is negative infinity and the second
16.571 + * argument is a negative finite odd integer,
16.572 + * </ul>
16.573 + * then the result is negative zero.
16.574 + *
16.575 + * <li>If
16.576 + * <ul>
16.577 + * <li>the first argument is negative zero and the second argument
16.578 + * is less than zero but not a finite odd integer, or
16.579 + * <li>the first argument is negative infinity and the second
16.580 + * argument is greater than zero but not a finite odd integer,
16.581 + * </ul>
16.582 + * then the result is positive infinity.
16.583 + *
16.584 + * <li>If
16.585 + * <ul>
16.586 + * <li>the first argument is negative zero and the second argument
16.587 + * is a negative finite odd integer, or
16.588 + * <li>the first argument is negative infinity and the second
16.589 + * argument is a positive finite odd integer,
16.590 + * </ul>
16.591 + * then the result is negative infinity.
16.592 + *
16.593 + * <li>If the first argument is finite and less than zero
16.594 + * <ul>
16.595 + * <li> if the second argument is a finite even integer, the
16.596 + * result is equal to the result of raising the absolute value of
16.597 + * the first argument to the power of the second argument
16.598 + *
16.599 + * <li>if the second argument is a finite odd integer, the result
16.600 + * is equal to the negative of the result of raising the absolute
16.601 + * value of the first argument to the power of the second
16.602 + * argument
16.603 + *
16.604 + * <li>if the second argument is finite and not an integer, then
16.605 + * the result is NaN.
16.606 + * </ul>
16.607 + *
16.608 + * <li>If both arguments are integers, then the result is exactly equal
16.609 + * to the mathematical result of raising the first argument to the power
16.610 + * of the second argument if that result can in fact be represented
16.611 + * exactly as a {@code double} value.</ul>
16.612 + *
16.613 + * <p>(In the foregoing descriptions, a floating-point value is
16.614 + * considered to be an integer if and only if it is finite and a
16.615 + * fixed point of the method {@link #ceil ceil} or,
16.616 + * equivalently, a fixed point of the method {@link #floor
16.617 + * floor}. A value is a fixed point of a one-argument
16.618 + * method if and only if the result of applying the method to the
16.619 + * value is equal to the value.)
16.620 + *
16.621 + * <p>The computed result must be within 1 ulp of the exact result.
16.622 + * Results must be semi-monotonic.
16.623 + *
16.624 + * @param a the base.
16.625 + * @param b the exponent.
16.626 + * @return the value {@code a}<sup>{@code b}</sup>.
16.627 + */
16.628 + public static double pow(double a, double b) {
16.629 + return StrictMath.pow(a, b); // default impl. delegates to StrictMath
16.630 + }
16.631 +
16.632 + /**
16.633 + * Returns the closest {@code int} to the argument, with ties
16.634 + * rounding up.
16.635 + *
16.636 + * <p>
16.637 + * Special cases:
16.638 + * <ul><li>If the argument is NaN, the result is 0.
16.639 + * <li>If the argument is negative infinity or any value less than or
16.640 + * equal to the value of {@code Integer.MIN_VALUE}, the result is
16.641 + * equal to the value of {@code Integer.MIN_VALUE}.
16.642 + * <li>If the argument is positive infinity or any value greater than or
16.643 + * equal to the value of {@code Integer.MAX_VALUE}, the result is
16.644 + * equal to the value of {@code Integer.MAX_VALUE}.</ul>
16.645 + *
16.646 + * @param a a floating-point value to be rounded to an integer.
16.647 + * @return the value of the argument rounded to the nearest
16.648 + * {@code int} value.
16.649 + * @see java.lang.Integer#MAX_VALUE
16.650 + * @see java.lang.Integer#MIN_VALUE
16.651 + */
16.652 + public static int round(float a) {
16.653 + if (a != 0x1.fffffep-2f) // greatest float value less than 0.5
16.654 + return (int)floor(a + 0.5f);
16.655 + else
16.656 + return 0;
16.657 + }
16.658 +
16.659 + /**
16.660 + * Returns the closest {@code long} to the argument, with ties
16.661 + * rounding up.
16.662 + *
16.663 + * <p>Special cases:
16.664 + * <ul><li>If the argument is NaN, the result is 0.
16.665 + * <li>If the argument is negative infinity or any value less than or
16.666 + * equal to the value of {@code Long.MIN_VALUE}, the result is
16.667 + * equal to the value of {@code Long.MIN_VALUE}.
16.668 + * <li>If the argument is positive infinity or any value greater than or
16.669 + * equal to the value of {@code Long.MAX_VALUE}, the result is
16.670 + * equal to the value of {@code Long.MAX_VALUE}.</ul>
16.671 + *
16.672 + * @param a a floating-point value to be rounded to a
16.673 + * {@code long}.
16.674 + * @return the value of the argument rounded to the nearest
16.675 + * {@code long} value.
16.676 + * @see java.lang.Long#MAX_VALUE
16.677 + * @see java.lang.Long#MIN_VALUE
16.678 + */
16.679 + public static long round(double a) {
16.680 + if (a != 0x1.fffffffffffffp-2) // greatest double value less than 0.5
16.681 + return (long)floor(a + 0.5d);
16.682 + else
16.683 + return 0;
16.684 + }
16.685 +
16.686 + private static Random randomNumberGenerator;
16.687 +
16.688 + private static synchronized Random initRNG() {
16.689 + Random rnd = randomNumberGenerator;
16.690 + return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
16.691 + }
16.692 +
16.693 + /**
16.694 + * Returns a {@code double} value with a positive sign, greater
16.695 + * than or equal to {@code 0.0} and less than {@code 1.0}.
16.696 + * Returned values are chosen pseudorandomly with (approximately)
16.697 + * uniform distribution from that range.
16.698 + *
16.699 + * <p>When this method is first called, it creates a single new
16.700 + * pseudorandom-number generator, exactly as if by the expression
16.701 + *
16.702 + * <blockquote>{@code new java.util.Random()}</blockquote>
16.703 + *
16.704 + * This new pseudorandom-number generator is used thereafter for
16.705 + * all calls to this method and is used nowhere else.
16.706 + *
16.707 + * <p>This method is properly synchronized to allow correct use by
16.708 + * more than one thread. However, if many threads need to generate
16.709 + * pseudorandom numbers at a great rate, it may reduce contention
16.710 + * for each thread to have its own pseudorandom-number generator.
16.711 + *
16.712 + * @return a pseudorandom {@code double} greater than or equal
16.713 + * to {@code 0.0} and less than {@code 1.0}.
16.714 + * @see Random#nextDouble()
16.715 + */
16.716 + public static double random() {
16.717 + Random rnd = randomNumberGenerator;
16.718 + if (rnd == null) rnd = initRNG();
16.719 + return rnd.nextDouble();
16.720 + }
16.721 +
16.722 + /**
16.723 + * Returns the absolute value of an {@code int} value.
16.724 + * If the argument is not negative, the argument is returned.
16.725 + * If the argument is negative, the negation of the argument is returned.
16.726 + *
16.727 + * <p>Note that if the argument is equal to the value of
16.728 + * {@link Integer#MIN_VALUE}, the most negative representable
16.729 + * {@code int} value, the result is that same value, which is
16.730 + * negative.
16.731 + *
16.732 + * @param a the argument whose absolute value is to be determined
16.733 + * @return the absolute value of the argument.
16.734 + */
16.735 + public static int abs(int a) {
16.736 + return (a < 0) ? -a : a;
16.737 + }
16.738 +
16.739 + /**
16.740 + * Returns the absolute value of a {@code long} value.
16.741 + * If the argument is not negative, the argument is returned.
16.742 + * If the argument is negative, the negation of the argument is returned.
16.743 + *
16.744 + * <p>Note that if the argument is equal to the value of
16.745 + * {@link Long#MIN_VALUE}, the most negative representable
16.746 + * {@code long} value, the result is that same value, which
16.747 + * is negative.
16.748 + *
16.749 + * @param a the argument whose absolute value is to be determined
16.750 + * @return the absolute value of the argument.
16.751 + */
16.752 + public static long abs(long a) {
16.753 + return (a < 0) ? -a : a;
16.754 + }
16.755 +
16.756 + /**
16.757 + * Returns the absolute value of a {@code float} value.
16.758 + * If the argument is not negative, the argument is returned.
16.759 + * If the argument is negative, the negation of the argument is returned.
16.760 + * Special cases:
16.761 + * <ul><li>If the argument is positive zero or negative zero, the
16.762 + * result is positive zero.
16.763 + * <li>If the argument is infinite, the result is positive infinity.
16.764 + * <li>If the argument is NaN, the result is NaN.</ul>
16.765 + * In other words, the result is the same as the value of the expression:
16.766 + * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
16.767 + *
16.768 + * @param a the argument whose absolute value is to be determined
16.769 + * @return the absolute value of the argument.
16.770 + */
16.771 + public static float abs(float a) {
16.772 + return (a <= 0.0F) ? 0.0F - a : a;
16.773 + }
16.774 +
16.775 + /**
16.776 + * Returns the absolute value of a {@code double} value.
16.777 + * If the argument is not negative, the argument is returned.
16.778 + * If the argument is negative, the negation of the argument is returned.
16.779 + * Special cases:
16.780 + * <ul><li>If the argument is positive zero or negative zero, the result
16.781 + * is positive zero.
16.782 + * <li>If the argument is infinite, the result is positive infinity.
16.783 + * <li>If the argument is NaN, the result is NaN.</ul>
16.784 + * In other words, the result is the same as the value of the expression:
16.785 + * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
16.786 + *
16.787 + * @param a the argument whose absolute value is to be determined
16.788 + * @return the absolute value of the argument.
16.789 + */
16.790 + public static double abs(double a) {
16.791 + return (a <= 0.0D) ? 0.0D - a : a;
16.792 + }
16.793 +
16.794 + /**
16.795 + * Returns the greater of two {@code int} values. That is, the
16.796 + * result is the argument closer to the value of
16.797 + * {@link Integer#MAX_VALUE}. If the arguments have the same value,
16.798 + * the result is that same value.
16.799 + *
16.800 + * @param a an argument.
16.801 + * @param b another argument.
16.802 + * @return the larger of {@code a} and {@code b}.
16.803 + */
16.804 + public static int max(int a, int b) {
16.805 + return (a >= b) ? a : b;
16.806 + }
16.807 +
16.808 + /**
16.809 + * Returns the greater of two {@code long} values. That is, the
16.810 + * result is the argument closer to the value of
16.811 + * {@link Long#MAX_VALUE}. If the arguments have the same value,
16.812 + * the result is that same value.
16.813 + *
16.814 + * @param a an argument.
16.815 + * @param b another argument.
16.816 + * @return the larger of {@code a} and {@code b}.
16.817 + */
16.818 + public static long max(long a, long b) {
16.819 + return (a >= b) ? a : b;
16.820 + }
16.821 +
16.822 + private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f);
16.823 + private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d);
16.824 +
16.825 + /**
16.826 + * Returns the greater of two {@code float} values. That is,
16.827 + * the result is the argument closer to positive infinity. If the
16.828 + * arguments have the same value, the result is that same
16.829 + * value. If either value is NaN, then the result is NaN. Unlike
16.830 + * the numerical comparison operators, this method considers
16.831 + * negative zero to be strictly smaller than positive zero. If one
16.832 + * argument is positive zero and the other negative zero, the
16.833 + * result is positive zero.
16.834 + *
16.835 + * @param a an argument.
16.836 + * @param b another argument.
16.837 + * @return the larger of {@code a} and {@code b}.
16.838 + */
16.839 + public static float max(float a, float b) {
16.840 + if (a != a) return a; // a is NaN
16.841 + if ((a == 0.0f) && (b == 0.0f)
16.842 + && (Float.floatToIntBits(a) == negativeZeroFloatBits)) {
16.843 + return b;
16.844 + }
16.845 + return (a >= b) ? a : b;
16.846 + }
16.847 +
16.848 + /**
16.849 + * Returns the greater of two {@code double} values. That
16.850 + * is, the result is the argument closer to positive infinity. If
16.851 + * the arguments have the same value, the result is that same
16.852 + * value. If either value is NaN, then the result is NaN. Unlike
16.853 + * the numerical comparison operators, this method considers
16.854 + * negative zero to be strictly smaller than positive zero. If one
16.855 + * argument is positive zero and the other negative zero, the
16.856 + * result is positive zero.
16.857 + *
16.858 + * @param a an argument.
16.859 + * @param b another argument.
16.860 + * @return the larger of {@code a} and {@code b}.
16.861 + */
16.862 + public static double max(double a, double b) {
16.863 + if (a != a) return a; // a is NaN
16.864 + if ((a == 0.0d) && (b == 0.0d)
16.865 + && (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) {
16.866 + return b;
16.867 + }
16.868 + return (a >= b) ? a : b;
16.869 + }
16.870 +
16.871 + /**
16.872 + * Returns the smaller of two {@code int} values. That is,
16.873 + * the result the argument closer to the value of
16.874 + * {@link Integer#MIN_VALUE}. If the arguments have the same
16.875 + * value, the result is that same value.
16.876 + *
16.877 + * @param a an argument.
16.878 + * @param b another argument.
16.879 + * @return the smaller of {@code a} and {@code b}.
16.880 + */
16.881 + public static int min(int a, int b) {
16.882 + return (a <= b) ? a : b;
16.883 + }
16.884 +
16.885 + /**
16.886 + * Returns the smaller of two {@code long} values. That is,
16.887 + * the result is the argument closer to the value of
16.888 + * {@link Long#MIN_VALUE}. If the arguments have the same
16.889 + * value, the result is that same value.
16.890 + *
16.891 + * @param a an argument.
16.892 + * @param b another argument.
16.893 + * @return the smaller of {@code a} and {@code b}.
16.894 + */
16.895 + public static long min(long a, long b) {
16.896 + return (a <= b) ? a : b;
16.897 + }
16.898 +
16.899 + /**
16.900 + * Returns the smaller of two {@code float} values. That is,
16.901 + * the result is the value closer to negative infinity. If the
16.902 + * arguments have the same value, the result is that same
16.903 + * value. If either value is NaN, then the result is NaN. Unlike
16.904 + * the numerical comparison operators, this method considers
16.905 + * negative zero to be strictly smaller than positive zero. If
16.906 + * one argument is positive zero and the other is negative zero,
16.907 + * the result is negative zero.
16.908 + *
16.909 + * @param a an argument.
16.910 + * @param b another argument.
16.911 + * @return the smaller of {@code a} and {@code b}.
16.912 + */
16.913 + public static float min(float a, float b) {
16.914 + if (a != a) return a; // a is NaN
16.915 + if ((a == 0.0f) && (b == 0.0f)
16.916 + && (Float.floatToIntBits(b) == negativeZeroFloatBits)) {
16.917 + return b;
16.918 + }
16.919 + return (a <= b) ? a : b;
16.920 + }
16.921 +
16.922 + /**
16.923 + * Returns the smaller of two {@code double} values. That
16.924 + * is, the result is the value closer to negative infinity. If the
16.925 + * arguments have the same value, the result is that same
16.926 + * value. If either value is NaN, then the result is NaN. Unlike
16.927 + * the numerical comparison operators, this method considers
16.928 + * negative zero to be strictly smaller than positive zero. If one
16.929 + * argument is positive zero and the other is negative zero, the
16.930 + * result is negative zero.
16.931 + *
16.932 + * @param a an argument.
16.933 + * @param b another argument.
16.934 + * @return the smaller of {@code a} and {@code b}.
16.935 + */
16.936 + public static double min(double a, double b) {
16.937 + if (a != a) return a; // a is NaN
16.938 + if ((a == 0.0d) && (b == 0.0d)
16.939 + && (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) {
16.940 + return b;
16.941 + }
16.942 + return (a <= b) ? a : b;
16.943 + }
16.944 +
16.945 + /**
16.946 + * Returns the size of an ulp of the argument. An ulp of a
16.947 + * {@code double} value is the positive distance between this
16.948 + * floating-point value and the {@code double} value next
16.949 + * larger in magnitude. Note that for non-NaN <i>x</i>,
16.950 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
16.951 + *
16.952 + * <p>Special Cases:
16.953 + * <ul>
16.954 + * <li> If the argument is NaN, then the result is NaN.
16.955 + * <li> If the argument is positive or negative infinity, then the
16.956 + * result is positive infinity.
16.957 + * <li> If the argument is positive or negative zero, then the result is
16.958 + * {@code Double.MIN_VALUE}.
16.959 + * <li> If the argument is ±{@code Double.MAX_VALUE}, then
16.960 + * the result is equal to 2<sup>971</sup>.
16.961 + * </ul>
16.962 + *
16.963 + * @param d the floating-point value whose ulp is to be returned
16.964 + * @return the size of an ulp of the argument
16.965 + * @author Joseph D. Darcy
16.966 + * @since 1.5
16.967 + */
16.968 + public static double ulp(double d) {
16.969 + return sun.misc.FpUtils.ulp(d);
16.970 + }
16.971 +
16.972 + /**
16.973 + * Returns the size of an ulp of the argument. An ulp of a
16.974 + * {@code float} value is the positive distance between this
16.975 + * floating-point value and the {@code float} value next
16.976 + * larger in magnitude. Note that for non-NaN <i>x</i>,
16.977 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
16.978 + *
16.979 + * <p>Special Cases:
16.980 + * <ul>
16.981 + * <li> If the argument is NaN, then the result is NaN.
16.982 + * <li> If the argument is positive or negative infinity, then the
16.983 + * result is positive infinity.
16.984 + * <li> If the argument is positive or negative zero, then the result is
16.985 + * {@code Float.MIN_VALUE}.
16.986 + * <li> If the argument is ±{@code Float.MAX_VALUE}, then
16.987 + * the result is equal to 2<sup>104</sup>.
16.988 + * </ul>
16.989 + *
16.990 + * @param f the floating-point value whose ulp is to be returned
16.991 + * @return the size of an ulp of the argument
16.992 + * @author Joseph D. Darcy
16.993 + * @since 1.5
16.994 + */
16.995 + public static float ulp(float f) {
16.996 + return sun.misc.FpUtils.ulp(f);
16.997 + }
16.998 +
16.999 + /**
16.1000 + * Returns the signum function of the argument; zero if the argument
16.1001 + * is zero, 1.0 if the argument is greater than zero, -1.0 if the
16.1002 + * argument is less than zero.
16.1003 + *
16.1004 + * <p>Special Cases:
16.1005 + * <ul>
16.1006 + * <li> If the argument is NaN, then the result is NaN.
16.1007 + * <li> If the argument is positive zero or negative zero, then the
16.1008 + * result is the same as the argument.
16.1009 + * </ul>
16.1010 + *
16.1011 + * @param d the floating-point value whose signum is to be returned
16.1012 + * @return the signum function of the argument
16.1013 + * @author Joseph D. Darcy
16.1014 + * @since 1.5
16.1015 + */
16.1016 + public static double signum(double d) {
16.1017 + return sun.misc.FpUtils.signum(d);
16.1018 + }
16.1019 +
16.1020 + /**
16.1021 + * Returns the signum function of the argument; zero if the argument
16.1022 + * is zero, 1.0f if the argument is greater than zero, -1.0f if the
16.1023 + * argument is less than zero.
16.1024 + *
16.1025 + * <p>Special Cases:
16.1026 + * <ul>
16.1027 + * <li> If the argument is NaN, then the result is NaN.
16.1028 + * <li> If the argument is positive zero or negative zero, then the
16.1029 + * result is the same as the argument.
16.1030 + * </ul>
16.1031 + *
16.1032 + * @param f the floating-point value whose signum is to be returned
16.1033 + * @return the signum function of the argument
16.1034 + * @author Joseph D. Darcy
16.1035 + * @since 1.5
16.1036 + */
16.1037 + public static float signum(float f) {
16.1038 + return sun.misc.FpUtils.signum(f);
16.1039 + }
16.1040 +
16.1041 + /**
16.1042 + * Returns the hyperbolic sine of a {@code double} value.
16.1043 + * The hyperbolic sine of <i>x</i> is defined to be
16.1044 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/2
16.1045 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
16.1046 + *
16.1047 + * <p>Special cases:
16.1048 + * <ul>
16.1049 + *
16.1050 + * <li>If the argument is NaN, then the result is NaN.
16.1051 + *
16.1052 + * <li>If the argument is infinite, then the result is an infinity
16.1053 + * with the same sign as the argument.
16.1054 + *
16.1055 + * <li>If the argument is zero, then the result is a zero with the
16.1056 + * same sign as the argument.
16.1057 + *
16.1058 + * </ul>
16.1059 + *
16.1060 + * <p>The computed result must be within 2.5 ulps of the exact result.
16.1061 + *
16.1062 + * @param x The number whose hyperbolic sine is to be returned.
16.1063 + * @return The hyperbolic sine of {@code x}.
16.1064 + * @since 1.5
16.1065 + */
16.1066 + public static double sinh(double x) {
16.1067 + return StrictMath.sinh(x);
16.1068 + }
16.1069 +
16.1070 + /**
16.1071 + * Returns the hyperbolic cosine of a {@code double} value.
16.1072 + * The hyperbolic cosine of <i>x</i> is defined to be
16.1073 + * (<i>e<sup>x</sup> + e<sup>-x</sup></i>)/2
16.1074 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
16.1075 + *
16.1076 + * <p>Special cases:
16.1077 + * <ul>
16.1078 + *
16.1079 + * <li>If the argument is NaN, then the result is NaN.
16.1080 + *
16.1081 + * <li>If the argument is infinite, then the result is positive
16.1082 + * infinity.
16.1083 + *
16.1084 + * <li>If the argument is zero, then the result is {@code 1.0}.
16.1085 + *
16.1086 + * </ul>
16.1087 + *
16.1088 + * <p>The computed result must be within 2.5 ulps of the exact result.
16.1089 + *
16.1090 + * @param x The number whose hyperbolic cosine is to be returned.
16.1091 + * @return The hyperbolic cosine of {@code x}.
16.1092 + * @since 1.5
16.1093 + */
16.1094 + public static double cosh(double x) {
16.1095 + return StrictMath.cosh(x);
16.1096 + }
16.1097 +
16.1098 + /**
16.1099 + * Returns the hyperbolic tangent of a {@code double} value.
16.1100 + * The hyperbolic tangent of <i>x</i> is defined to be
16.1101 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/(<i>e<sup>x</sup> + e<sup>-x</sup></i>),
16.1102 + * in other words, {@linkplain Math#sinh
16.1103 + * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
16.1104 + * that the absolute value of the exact tanh is always less than
16.1105 + * 1.
16.1106 + *
16.1107 + * <p>Special cases:
16.1108 + * <ul>
16.1109 + *
16.1110 + * <li>If the argument is NaN, then the result is NaN.
16.1111 + *
16.1112 + * <li>If the argument is zero, then the result is a zero with the
16.1113 + * same sign as the argument.
16.1114 + *
16.1115 + * <li>If the argument is positive infinity, then the result is
16.1116 + * {@code +1.0}.
16.1117 + *
16.1118 + * <li>If the argument is negative infinity, then the result is
16.1119 + * {@code -1.0}.
16.1120 + *
16.1121 + * </ul>
16.1122 + *
16.1123 + * <p>The computed result must be within 2.5 ulps of the exact result.
16.1124 + * The result of {@code tanh} for any finite input must have
16.1125 + * an absolute value less than or equal to 1. Note that once the
16.1126 + * exact result of tanh is within 1/2 of an ulp of the limit value
16.1127 + * of ±1, correctly signed ±{@code 1.0} should
16.1128 + * be returned.
16.1129 + *
16.1130 + * @param x The number whose hyperbolic tangent is to be returned.
16.1131 + * @return The hyperbolic tangent of {@code x}.
16.1132 + * @since 1.5
16.1133 + */
16.1134 + public static double tanh(double x) {
16.1135 + return StrictMath.tanh(x);
16.1136 + }
16.1137 +
16.1138 + /**
16.1139 + * Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
16.1140 + * without intermediate overflow or underflow.
16.1141 + *
16.1142 + * <p>Special cases:
16.1143 + * <ul>
16.1144 + *
16.1145 + * <li> If either argument is infinite, then the result
16.1146 + * is positive infinity.
16.1147 + *
16.1148 + * <li> If either argument is NaN and neither argument is infinite,
16.1149 + * then the result is NaN.
16.1150 + *
16.1151 + * </ul>
16.1152 + *
16.1153 + * <p>The computed result must be within 1 ulp of the exact
16.1154 + * result. If one parameter is held constant, the results must be
16.1155 + * semi-monotonic in the other parameter.
16.1156 + *
16.1157 + * @param x a value
16.1158 + * @param y a value
16.1159 + * @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
16.1160 + * without intermediate overflow or underflow
16.1161 + * @since 1.5
16.1162 + */
16.1163 + public static double hypot(double x, double y) {
16.1164 + return StrictMath.hypot(x, y);
16.1165 + }
16.1166 +
16.1167 + /**
16.1168 + * Returns <i>e</i><sup>x</sup> -1. Note that for values of
16.1169 + * <i>x</i> near 0, the exact sum of
16.1170 + * {@code expm1(x)} + 1 is much closer to the true
16.1171 + * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
16.1172 + *
16.1173 + * <p>Special cases:
16.1174 + * <ul>
16.1175 + * <li>If the argument is NaN, the result is NaN.
16.1176 + *
16.1177 + * <li>If the argument is positive infinity, then the result is
16.1178 + * positive infinity.
16.1179 + *
16.1180 + * <li>If the argument is negative infinity, then the result is
16.1181 + * -1.0.
16.1182 + *
16.1183 + * <li>If the argument is zero, then the result is a zero with the
16.1184 + * same sign as the argument.
16.1185 + *
16.1186 + * </ul>
16.1187 + *
16.1188 + * <p>The computed result must be within 1 ulp of the exact result.
16.1189 + * Results must be semi-monotonic. The result of
16.1190 + * {@code expm1} for any finite input must be greater than or
16.1191 + * equal to {@code -1.0}. Note that once the exact result of
16.1192 + * <i>e</i><sup>{@code x}</sup> - 1 is within 1/2
16.1193 + * ulp of the limit value -1, {@code -1.0} should be
16.1194 + * returned.
16.1195 + *
16.1196 + * @param x the exponent to raise <i>e</i> to in the computation of
16.1197 + * <i>e</i><sup>{@code x}</sup> -1.
16.1198 + * @return the value <i>e</i><sup>{@code x}</sup> - 1.
16.1199 + * @since 1.5
16.1200 + */
16.1201 + public static double expm1(double x) {
16.1202 + return StrictMath.expm1(x);
16.1203 + }
16.1204 +
16.1205 + /**
16.1206 + * Returns the natural logarithm of the sum of the argument and 1.
16.1207 + * Note that for small values {@code x}, the result of
16.1208 + * {@code log1p(x)} is much closer to the true result of ln(1
16.1209 + * + {@code x}) than the floating-point evaluation of
16.1210 + * {@code log(1.0+x)}.
16.1211 + *
16.1212 + * <p>Special cases:
16.1213 + *
16.1214 + * <ul>
16.1215 + *
16.1216 + * <li>If the argument is NaN or less than -1, then the result is
16.1217 + * NaN.
16.1218 + *
16.1219 + * <li>If the argument is positive infinity, then the result is
16.1220 + * positive infinity.
16.1221 + *
16.1222 + * <li>If the argument is negative one, then the result is
16.1223 + * negative infinity.
16.1224 + *
16.1225 + * <li>If the argument is zero, then the result is a zero with the
16.1226 + * same sign as the argument.
16.1227 + *
16.1228 + * </ul>
16.1229 + *
16.1230 + * <p>The computed result must be within 1 ulp of the exact result.
16.1231 + * Results must be semi-monotonic.
16.1232 + *
16.1233 + * @param x a value
16.1234 + * @return the value ln({@code x} + 1), the natural
16.1235 + * log of {@code x} + 1
16.1236 + * @since 1.5
16.1237 + */
16.1238 + public static double log1p(double x) {
16.1239 + return StrictMath.log1p(x);
16.1240 + }
16.1241 +
16.1242 + /**
16.1243 + * Returns the first floating-point argument with the sign of the
16.1244 + * second floating-point argument. Note that unlike the {@link
16.1245 + * StrictMath#copySign(double, double) StrictMath.copySign}
16.1246 + * method, this method does not require NaN {@code sign}
16.1247 + * arguments to be treated as positive values; implementations are
16.1248 + * permitted to treat some NaN arguments as positive and other NaN
16.1249 + * arguments as negative to allow greater performance.
16.1250 + *
16.1251 + * @param magnitude the parameter providing the magnitude of the result
16.1252 + * @param sign the parameter providing the sign of the result
16.1253 + * @return a value with the magnitude of {@code magnitude}
16.1254 + * and the sign of {@code sign}.
16.1255 + * @since 1.6
16.1256 + */
16.1257 + public static double copySign(double magnitude, double sign) {
16.1258 + return sun.misc.FpUtils.rawCopySign(magnitude, sign);
16.1259 + }
16.1260 +
16.1261 + /**
16.1262 + * Returns the first floating-point argument with the sign of the
16.1263 + * second floating-point argument. Note that unlike the {@link
16.1264 + * StrictMath#copySign(float, float) StrictMath.copySign}
16.1265 + * method, this method does not require NaN {@code sign}
16.1266 + * arguments to be treated as positive values; implementations are
16.1267 + * permitted to treat some NaN arguments as positive and other NaN
16.1268 + * arguments as negative to allow greater performance.
16.1269 + *
16.1270 + * @param magnitude the parameter providing the magnitude of the result
16.1271 + * @param sign the parameter providing the sign of the result
16.1272 + * @return a value with the magnitude of {@code magnitude}
16.1273 + * and the sign of {@code sign}.
16.1274 + * @since 1.6
16.1275 + */
16.1276 + public static float copySign(float magnitude, float sign) {
16.1277 + return sun.misc.FpUtils.rawCopySign(magnitude, sign);
16.1278 + }
16.1279 +
16.1280 + /**
16.1281 + * Returns the unbiased exponent used in the representation of a
16.1282 + * {@code float}. Special cases:
16.1283 + *
16.1284 + * <ul>
16.1285 + * <li>If the argument is NaN or infinite, then the result is
16.1286 + * {@link Float#MAX_EXPONENT} + 1.
16.1287 + * <li>If the argument is zero or subnormal, then the result is
16.1288 + * {@link Float#MIN_EXPONENT} -1.
16.1289 + * </ul>
16.1290 + * @param f a {@code float} value
16.1291 + * @return the unbiased exponent of the argument
16.1292 + * @since 1.6
16.1293 + */
16.1294 + public static int getExponent(float f) {
16.1295 + return sun.misc.FpUtils.getExponent(f);
16.1296 + }
16.1297 +
16.1298 + /**
16.1299 + * Returns the unbiased exponent used in the representation of a
16.1300 + * {@code double}. Special cases:
16.1301 + *
16.1302 + * <ul>
16.1303 + * <li>If the argument is NaN or infinite, then the result is
16.1304 + * {@link Double#MAX_EXPONENT} + 1.
16.1305 + * <li>If the argument is zero or subnormal, then the result is
16.1306 + * {@link Double#MIN_EXPONENT} -1.
16.1307 + * </ul>
16.1308 + * @param d a {@code double} value
16.1309 + * @return the unbiased exponent of the argument
16.1310 + * @since 1.6
16.1311 + */
16.1312 + public static int getExponent(double d) {
16.1313 + return sun.misc.FpUtils.getExponent(d);
16.1314 + }
16.1315 +
16.1316 + /**
16.1317 + * Returns the floating-point number adjacent to the first
16.1318 + * argument in the direction of the second argument. If both
16.1319 + * arguments compare as equal the second argument is returned.
16.1320 + *
16.1321 + * <p>
16.1322 + * Special cases:
16.1323 + * <ul>
16.1324 + * <li> If either argument is a NaN, then NaN is returned.
16.1325 + *
16.1326 + * <li> If both arguments are signed zeros, {@code direction}
16.1327 + * is returned unchanged (as implied by the requirement of
16.1328 + * returning the second argument if the arguments compare as
16.1329 + * equal).
16.1330 + *
16.1331 + * <li> If {@code start} is
16.1332 + * ±{@link Double#MIN_VALUE} and {@code direction}
16.1333 + * has a value such that the result should have a smaller
16.1334 + * magnitude, then a zero with the same sign as {@code start}
16.1335 + * is returned.
16.1336 + *
16.1337 + * <li> If {@code start} is infinite and
16.1338 + * {@code direction} has a value such that the result should
16.1339 + * have a smaller magnitude, {@link Double#MAX_VALUE} with the
16.1340 + * same sign as {@code start} is returned.
16.1341 + *
16.1342 + * <li> If {@code start} is equal to ±
16.1343 + * {@link Double#MAX_VALUE} and {@code direction} has a
16.1344 + * value such that the result should have a larger magnitude, an
16.1345 + * infinity with same sign as {@code start} is returned.
16.1346 + * </ul>
16.1347 + *
16.1348 + * @param start starting floating-point value
16.1349 + * @param direction value indicating which of
16.1350 + * {@code start}'s neighbors or {@code start} should
16.1351 + * be returned
16.1352 + * @return The floating-point number adjacent to {@code start} in the
16.1353 + * direction of {@code direction}.
16.1354 + * @since 1.6
16.1355 + */
16.1356 + public static double nextAfter(double start, double direction) {
16.1357 + return sun.misc.FpUtils.nextAfter(start, direction);
16.1358 + }
16.1359 +
16.1360 + /**
16.1361 + * Returns the floating-point number adjacent to the first
16.1362 + * argument in the direction of the second argument. If both
16.1363 + * arguments compare as equal a value equivalent to the second argument
16.1364 + * is returned.
16.1365 + *
16.1366 + * <p>
16.1367 + * Special cases:
16.1368 + * <ul>
16.1369 + * <li> If either argument is a NaN, then NaN is returned.
16.1370 + *
16.1371 + * <li> If both arguments are signed zeros, a value equivalent
16.1372 + * to {@code direction} is returned.
16.1373 + *
16.1374 + * <li> If {@code start} is
16.1375 + * ±{@link Float#MIN_VALUE} and {@code direction}
16.1376 + * has a value such that the result should have a smaller
16.1377 + * magnitude, then a zero with the same sign as {@code start}
16.1378 + * is returned.
16.1379 + *
16.1380 + * <li> If {@code start} is infinite and
16.1381 + * {@code direction} has a value such that the result should
16.1382 + * have a smaller magnitude, {@link Float#MAX_VALUE} with the
16.1383 + * same sign as {@code start} is returned.
16.1384 + *
16.1385 + * <li> If {@code start} is equal to ±
16.1386 + * {@link Float#MAX_VALUE} and {@code direction} has a
16.1387 + * value such that the result should have a larger magnitude, an
16.1388 + * infinity with same sign as {@code start} is returned.
16.1389 + * </ul>
16.1390 + *
16.1391 + * @param start starting floating-point value
16.1392 + * @param direction value indicating which of
16.1393 + * {@code start}'s neighbors or {@code start} should
16.1394 + * be returned
16.1395 + * @return The floating-point number adjacent to {@code start} in the
16.1396 + * direction of {@code direction}.
16.1397 + * @since 1.6
16.1398 + */
16.1399 + public static float nextAfter(float start, double direction) {
16.1400 + return sun.misc.FpUtils.nextAfter(start, direction);
16.1401 + }
16.1402 +
16.1403 + /**
16.1404 + * Returns the floating-point value adjacent to {@code d} in
16.1405 + * the direction of positive infinity. This method is
16.1406 + * semantically equivalent to {@code nextAfter(d,
16.1407 + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
16.1408 + * implementation may run faster than its equivalent
16.1409 + * {@code nextAfter} call.
16.1410 + *
16.1411 + * <p>Special Cases:
16.1412 + * <ul>
16.1413 + * <li> If the argument is NaN, the result is NaN.
16.1414 + *
16.1415 + * <li> If the argument is positive infinity, the result is
16.1416 + * positive infinity.
16.1417 + *
16.1418 + * <li> If the argument is zero, the result is
16.1419 + * {@link Double#MIN_VALUE}
16.1420 + *
16.1421 + * </ul>
16.1422 + *
16.1423 + * @param d starting floating-point value
16.1424 + * @return The adjacent floating-point value closer to positive
16.1425 + * infinity.
16.1426 + * @since 1.6
16.1427 + */
16.1428 + public static double nextUp(double d) {
16.1429 + return sun.misc.FpUtils.nextUp(d);
16.1430 + }
16.1431 +
16.1432 + /**
16.1433 + * Returns the floating-point value adjacent to {@code f} in
16.1434 + * the direction of positive infinity. This method is
16.1435 + * semantically equivalent to {@code nextAfter(f,
16.1436 + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
16.1437 + * implementation may run faster than its equivalent
16.1438 + * {@code nextAfter} call.
16.1439 + *
16.1440 + * <p>Special Cases:
16.1441 + * <ul>
16.1442 + * <li> If the argument is NaN, the result is NaN.
16.1443 + *
16.1444 + * <li> If the argument is positive infinity, the result is
16.1445 + * positive infinity.
16.1446 + *
16.1447 + * <li> If the argument is zero, the result is
16.1448 + * {@link Float#MIN_VALUE}
16.1449 + *
16.1450 + * </ul>
16.1451 + *
16.1452 + * @param f starting floating-point value
16.1453 + * @return The adjacent floating-point value closer to positive
16.1454 + * infinity.
16.1455 + * @since 1.6
16.1456 + */
16.1457 + public static float nextUp(float f) {
16.1458 + return sun.misc.FpUtils.nextUp(f);
16.1459 + }
16.1460 +
16.1461 +
16.1462 + /**
16.1463 + * Return {@code d} ×
16.1464 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
16.1465 + * by a single correctly rounded floating-point multiply to a
16.1466 + * member of the double value set. See the Java
16.1467 + * Language Specification for a discussion of floating-point
16.1468 + * value sets. If the exponent of the result is between {@link
16.1469 + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
16.1470 + * answer is calculated exactly. If the exponent of the result
16.1471 + * would be larger than {@code Double.MAX_EXPONENT}, an
16.1472 + * infinity is returned. Note that if the result is subnormal,
16.1473 + * precision may be lost; that is, when {@code scalb(x, n)}
16.1474 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
16.1475 + * <i>x</i>. When the result is non-NaN, the result has the same
16.1476 + * sign as {@code d}.
16.1477 + *
16.1478 + * <p>Special cases:
16.1479 + * <ul>
16.1480 + * <li> If the first argument is NaN, NaN is returned.
16.1481 + * <li> If the first argument is infinite, then an infinity of the
16.1482 + * same sign is returned.
16.1483 + * <li> If the first argument is zero, then a zero of the same
16.1484 + * sign is returned.
16.1485 + * </ul>
16.1486 + *
16.1487 + * @param d number to be scaled by a power of two.
16.1488 + * @param scaleFactor power of 2 used to scale {@code d}
16.1489 + * @return {@code d} × 2<sup>{@code scaleFactor}</sup>
16.1490 + * @since 1.6
16.1491 + */
16.1492 + public static double scalb(double d, int scaleFactor) {
16.1493 + return sun.misc.FpUtils.scalb(d, scaleFactor);
16.1494 + }
16.1495 +
16.1496 + /**
16.1497 + * Return {@code f} ×
16.1498 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
16.1499 + * by a single correctly rounded floating-point multiply to a
16.1500 + * member of the float value set. See the Java
16.1501 + * Language Specification for a discussion of floating-point
16.1502 + * value sets. If the exponent of the result is between {@link
16.1503 + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
16.1504 + * answer is calculated exactly. If the exponent of the result
16.1505 + * would be larger than {@code Float.MAX_EXPONENT}, an
16.1506 + * infinity is returned. Note that if the result is subnormal,
16.1507 + * precision may be lost; that is, when {@code scalb(x, n)}
16.1508 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
16.1509 + * <i>x</i>. When the result is non-NaN, the result has the same
16.1510 + * sign as {@code f}.
16.1511 + *
16.1512 + * <p>Special cases:
16.1513 + * <ul>
16.1514 + * <li> If the first argument is NaN, NaN is returned.
16.1515 + * <li> If the first argument is infinite, then an infinity of the
16.1516 + * same sign is returned.
16.1517 + * <li> If the first argument is zero, then a zero of the same
16.1518 + * sign is returned.
16.1519 + * </ul>
16.1520 + *
16.1521 + * @param f number to be scaled by a power of two.
16.1522 + * @param scaleFactor power of 2 used to scale {@code f}
16.1523 + * @return {@code f} × 2<sup>{@code scaleFactor}</sup>
16.1524 + * @since 1.6
16.1525 + */
16.1526 + public static float scalb(float f, int scaleFactor) {
16.1527 + return sun.misc.FpUtils.scalb(f, scaleFactor);
16.1528 + }
16.1529 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/emul/src/main/java/java/lang/NullPointerException.java Sun Sep 30 14:37:39 2012 -0700
17.3 @@ -0,0 +1,72 @@
17.4 +/*
17.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
17.7 + *
17.8 + * This code is free software; you can redistribute it and/or modify it
17.9 + * under the terms of the GNU General Public License version 2 only, as
17.10 + * published by the Free Software Foundation. Oracle designates this
17.11 + * particular file as subject to the "Classpath" exception as provided
17.12 + * by Oracle in the LICENSE file that accompanied this code.
17.13 + *
17.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
17.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17.17 + * version 2 for more details (a copy is included in the LICENSE file that
17.18 + * accompanied this code).
17.19 + *
17.20 + * You should have received a copy of the GNU General Public License version
17.21 + * 2 along with this work; if not, write to the Free Software Foundation,
17.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17.23 + *
17.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17.25 + * or visit www.oracle.com if you need additional information or have any
17.26 + * questions.
17.27 + */
17.28 +
17.29 +package java.lang;
17.30 +
17.31 +/**
17.32 + * Thrown when an application attempts to use {@code null} in a
17.33 + * case where an object is required. These include:
17.34 + * <ul>
17.35 + * <li>Calling the instance method of a {@code null} object.
17.36 + * <li>Accessing or modifying the field of a {@code null} object.
17.37 + * <li>Taking the length of {@code null} as if it were an array.
17.38 + * <li>Accessing or modifying the slots of {@code null} as if it
17.39 + * were an array.
17.40 + * <li>Throwing {@code null} as if it were a {@code Throwable}
17.41 + * value.
17.42 + * </ul>
17.43 + * <p>
17.44 + * Applications should throw instances of this class to indicate
17.45 + * other illegal uses of the {@code null} object.
17.46 + *
17.47 + * {@code NullPointerException} objects may be constructed by the
17.48 + * virtual machine as if {@linkplain Throwable#Throwable(String,
17.49 + * Throwable, boolean, boolean) suppression were disabled and/or the
17.50 + * stack trace was not writable}.
17.51 + *
17.52 + * @author unascribed
17.53 + * @since JDK1.0
17.54 + */
17.55 +public
17.56 +class NullPointerException extends RuntimeException {
17.57 + private static final long serialVersionUID = 5162710183389028792L;
17.58 +
17.59 + /**
17.60 + * Constructs a {@code NullPointerException} with no detail message.
17.61 + */
17.62 + public NullPointerException() {
17.63 + super();
17.64 + }
17.65 +
17.66 + /**
17.67 + * Constructs a {@code NullPointerException} with the specified
17.68 + * detail message.
17.69 + *
17.70 + * @param s the detail message.
17.71 + */
17.72 + public NullPointerException(String s) {
17.73 + super(s);
17.74 + }
17.75 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/emul/src/main/java/java/lang/NumberFormatException.java Sun Sep 30 14:37:39 2012 -0700
18.3 @@ -0,0 +1,67 @@
18.4 +/*
18.5 + * Copyright (c) 1994, 2001, Oracle and/or its affiliates. All rights reserved.
18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
18.7 + *
18.8 + * This code is free software; you can redistribute it and/or modify it
18.9 + * under the terms of the GNU General Public License version 2 only, as
18.10 + * published by the Free Software Foundation. Oracle designates this
18.11 + * particular file as subject to the "Classpath" exception as provided
18.12 + * by Oracle in the LICENSE file that accompanied this code.
18.13 + *
18.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
18.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18.17 + * version 2 for more details (a copy is included in the LICENSE file that
18.18 + * accompanied this code).
18.19 + *
18.20 + * You should have received a copy of the GNU General Public License version
18.21 + * 2 along with this work; if not, write to the Free Software Foundation,
18.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18.23 + *
18.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18.25 + * or visit www.oracle.com if you need additional information or have any
18.26 + * questions.
18.27 + */
18.28 +
18.29 +package java.lang;
18.30 +
18.31 +/**
18.32 + * Thrown to indicate that the application has attempted to convert
18.33 + * a string to one of the numeric types, but that the string does not
18.34 + * have the appropriate format.
18.35 + *
18.36 + * @author unascribed
18.37 + * @see java.lang.Integer#toString()
18.38 + * @since JDK1.0
18.39 + */
18.40 +public
18.41 +class NumberFormatException extends IllegalArgumentException {
18.42 + static final long serialVersionUID = -2848938806368998894L;
18.43 +
18.44 + /**
18.45 + * Constructs a <code>NumberFormatException</code> with no detail message.
18.46 + */
18.47 + public NumberFormatException () {
18.48 + super();
18.49 + }
18.50 +
18.51 + /**
18.52 + * Constructs a <code>NumberFormatException</code> with the
18.53 + * specified detail message.
18.54 + *
18.55 + * @param s the detail message.
18.56 + */
18.57 + public NumberFormatException (String s) {
18.58 + super (s);
18.59 + }
18.60 +
18.61 + /**
18.62 + * Factory method for making a <code>NumberFormatException</code>
18.63 + * given the specified input which caused the error.
18.64 + *
18.65 + * @param s the input causing the error
18.66 + */
18.67 + static NumberFormatException forInputString(String s) {
18.68 + return new NumberFormatException("For input string: \"" + s + "\"");
18.69 + }
18.70 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/emul/src/main/java/java/lang/ReflectiveOperationException.java Sun Sep 30 14:37:39 2012 -0700
19.3 @@ -0,0 +1,91 @@
19.4 +/*
19.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19.7 + *
19.8 + * This code is free software; you can redistribute it and/or modify it
19.9 + * under the terms of the GNU General Public License version 2 only, as
19.10 + * published by the Free Software Foundation. Oracle designates this
19.11 + * particular file as subject to the "Classpath" exception as provided
19.12 + * by Oracle in the LICENSE file that accompanied this code.
19.13 + *
19.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
19.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19.17 + * version 2 for more details (a copy is included in the LICENSE file that
19.18 + * accompanied this code).
19.19 + *
19.20 + * You should have received a copy of the GNU General Public License version
19.21 + * 2 along with this work; if not, write to the Free Software Foundation,
19.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19.23 + *
19.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19.25 + * or visit www.oracle.com if you need additional information or have any
19.26 + * questions.
19.27 + */
19.28 +
19.29 +package java.lang;
19.30 +
19.31 +/**
19.32 + * Common superclass of exceptions thrown by reflective operations in
19.33 + * core reflection.
19.34 + *
19.35 + * @see LinkageError
19.36 + * @since 1.7
19.37 + */
19.38 +public class ReflectiveOperationException extends Exception {
19.39 + static final long serialVersionUID = 123456789L;
19.40 +
19.41 + /**
19.42 + * Constructs a new exception with {@code null} as its detail
19.43 + * message. The cause is not initialized, and may subsequently be
19.44 + * initialized by a call to {@link #initCause}.
19.45 + */
19.46 + public ReflectiveOperationException() {
19.47 + super();
19.48 + }
19.49 +
19.50 + /**
19.51 + * Constructs a new exception with the specified detail message.
19.52 + * The cause is not initialized, and may subsequently be
19.53 + * initialized by a call to {@link #initCause}.
19.54 + *
19.55 + * @param message the detail message. The detail message is saved for
19.56 + * later retrieval by the {@link #getMessage()} method.
19.57 + */
19.58 + public ReflectiveOperationException(String message) {
19.59 + super(message);
19.60 + }
19.61 +
19.62 + /**
19.63 + * Constructs a new exception with the specified detail message
19.64 + * and cause.
19.65 + *
19.66 + * <p>Note that the detail message associated with
19.67 + * {@code cause} is <em>not</em> automatically incorporated in
19.68 + * this exception's detail message.
19.69 + *
19.70 + * @param message the detail message (which is saved for later retrieval
19.71 + * by the {@link #getMessage()} method).
19.72 + * @param cause the cause (which is saved for later retrieval by the
19.73 + * {@link #getCause()} method). (A {@code null} value is
19.74 + * permitted, and indicates that the cause is nonexistent or
19.75 + * unknown.)
19.76 + */
19.77 + public ReflectiveOperationException(String message, Throwable cause) {
19.78 + super(message, cause);
19.79 + }
19.80 +
19.81 + /**
19.82 + * Constructs a new exception with the specified cause and a detail
19.83 + * message of {@code (cause==null ? null : cause.toString())} (which
19.84 + * typically contains the class and detail message of {@code cause}).
19.85 + *
19.86 + * @param cause the cause (which is saved for later retrieval by the
19.87 + * {@link #getCause()} method). (A {@code null} value is
19.88 + * permitted, and indicates that the cause is nonexistent or
19.89 + * unknown.)
19.90 + */
19.91 + public ReflectiveOperationException(Throwable cause) {
19.92 + super(cause);
19.93 + }
19.94 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/emul/src/main/java/java/lang/Short.java Sun Sep 30 14:37:39 2012 -0700
20.3 @@ -0,0 +1,468 @@
20.4 +/*
20.5 + * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20.7 + *
20.8 + * This code is free software; you can redistribute it and/or modify it
20.9 + * under the terms of the GNU General Public License version 2 only, as
20.10 + * published by the Free Software Foundation. Oracle designates this
20.11 + * particular file as subject to the "Classpath" exception as provided
20.12 + * by Oracle in the LICENSE file that accompanied this code.
20.13 + *
20.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
20.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20.17 + * version 2 for more details (a copy is included in the LICENSE file that
20.18 + * accompanied this code).
20.19 + *
20.20 + * You should have received a copy of the GNU General Public License version
20.21 + * 2 along with this work; if not, write to the Free Software Foundation,
20.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20.23 + *
20.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20.25 + * or visit www.oracle.com if you need additional information or have any
20.26 + * questions.
20.27 + */
20.28 +
20.29 +package java.lang;
20.30 +
20.31 +/**
20.32 + * The {@code Short} class wraps a value of primitive type {@code
20.33 + * short} in an object. An object of type {@code Short} contains a
20.34 + * single field whose type is {@code short}.
20.35 + *
20.36 + * <p>In addition, this class provides several methods for converting
20.37 + * a {@code short} to a {@code String} and a {@code String} to a
20.38 + * {@code short}, as well as other constants and methods useful when
20.39 + * dealing with a {@code short}.
20.40 + *
20.41 + * @author Nakul Saraiya
20.42 + * @author Joseph D. Darcy
20.43 + * @see java.lang.Number
20.44 + * @since JDK1.1
20.45 + */
20.46 +public final class Short extends Number implements Comparable<Short> {
20.47 +
20.48 + /**
20.49 + * A constant holding the minimum value a {@code short} can
20.50 + * have, -2<sup>15</sup>.
20.51 + */
20.52 + public static final short MIN_VALUE = -32768;
20.53 +
20.54 + /**
20.55 + * A constant holding the maximum value a {@code short} can
20.56 + * have, 2<sup>15</sup>-1.
20.57 + */
20.58 + public static final short MAX_VALUE = 32767;
20.59 +
20.60 + /**
20.61 + * The {@code Class} instance representing the primitive type
20.62 + * {@code short}.
20.63 + */
20.64 + public static final Class<Short> TYPE = (Class<Short>) Class.getPrimitiveClass("short");
20.65 +
20.66 + /**
20.67 + * Returns a new {@code String} object representing the
20.68 + * specified {@code short}. The radix is assumed to be 10.
20.69 + *
20.70 + * @param s the {@code short} to be converted
20.71 + * @return the string representation of the specified {@code short}
20.72 + * @see java.lang.Integer#toString(int)
20.73 + */
20.74 + public static String toString(short s) {
20.75 + return Integer.toString((int)s, 10);
20.76 + }
20.77 +
20.78 + /**
20.79 + * Parses the string argument as a signed {@code short} in the
20.80 + * radix specified by the second argument. The characters in the
20.81 + * string must all be digits, of the specified radix (as
20.82 + * determined by whether {@link java.lang.Character#digit(char,
20.83 + * int)} returns a nonnegative value) except that the first
20.84 + * character may be an ASCII minus sign {@code '-'}
20.85 + * (<code>'\u002D'</code>) to indicate a negative value or an
20.86 + * ASCII plus sign {@code '+'} (<code>'\u002B'</code>) to
20.87 + * indicate a positive value. The resulting {@code short} value
20.88 + * is returned.
20.89 + *
20.90 + * <p>An exception of type {@code NumberFormatException} is
20.91 + * thrown if any of the following situations occurs:
20.92 + * <ul>
20.93 + * <li> The first argument is {@code null} or is a string of
20.94 + * length zero.
20.95 + *
20.96 + * <li> The radix is either smaller than {@link
20.97 + * java.lang.Character#MIN_RADIX} or larger than {@link
20.98 + * java.lang.Character#MAX_RADIX}.
20.99 + *
20.100 + * <li> Any character of the string is not a digit of the
20.101 + * specified radix, except that the first character may be a minus
20.102 + * sign {@code '-'} (<code>'\u002D'</code>) or plus sign
20.103 + * {@code '+'} (<code>'\u002B'</code>) provided that the
20.104 + * string is longer than length 1.
20.105 + *
20.106 + * <li> The value represented by the string is not a value of type
20.107 + * {@code short}.
20.108 + * </ul>
20.109 + *
20.110 + * @param s the {@code String} containing the
20.111 + * {@code short} representation to be parsed
20.112 + * @param radix the radix to be used while parsing {@code s}
20.113 + * @return the {@code short} represented by the string
20.114 + * argument in the specified radix.
20.115 + * @throws NumberFormatException If the {@code String}
20.116 + * does not contain a parsable {@code short}.
20.117 + */
20.118 + public static short parseShort(String s, int radix)
20.119 + throws NumberFormatException {
20.120 + int i = Integer.parseInt(s, radix);
20.121 + if (i < MIN_VALUE || i > MAX_VALUE)
20.122 + throw new NumberFormatException(
20.123 + "Value out of range. Value:\"" + s + "\" Radix:" + radix);
20.124 + return (short)i;
20.125 + }
20.126 +
20.127 + /**
20.128 + * Parses the string argument as a signed decimal {@code
20.129 + * short}. The characters in the string must all be decimal
20.130 + * digits, except that the first character may be an ASCII minus
20.131 + * sign {@code '-'} (<code>'\u002D'</code>) to indicate a
20.132 + * negative value or an ASCII plus sign {@code '+'}
20.133 + * (<code>'\u002B'</code>) to indicate a positive value. The
20.134 + * resulting {@code short} value is returned, exactly as if the
20.135 + * argument and the radix 10 were given as arguments to the {@link
20.136 + * #parseShort(java.lang.String, int)} method.
20.137 + *
20.138 + * @param s a {@code String} containing the {@code short}
20.139 + * representation to be parsed
20.140 + * @return the {@code short} value represented by the
20.141 + * argument in decimal.
20.142 + * @throws NumberFormatException If the string does not
20.143 + * contain a parsable {@code short}.
20.144 + */
20.145 + public static short parseShort(String s) throws NumberFormatException {
20.146 + return parseShort(s, 10);
20.147 + }
20.148 +
20.149 + /**
20.150 + * Returns a {@code Short} object holding the value
20.151 + * extracted from the specified {@code String} when parsed
20.152 + * with the radix given by the second argument. The first argument
20.153 + * is interpreted as representing a signed {@code short} in
20.154 + * the radix specified by the second argument, exactly as if the
20.155 + * argument were given to the {@link #parseShort(java.lang.String,
20.156 + * int)} method. The result is a {@code Short} object that
20.157 + * represents the {@code short} value specified by the string.
20.158 + *
20.159 + * <p>In other words, this method returns a {@code Short} object
20.160 + * equal to the value of:
20.161 + *
20.162 + * <blockquote>
20.163 + * {@code new Short(Short.parseShort(s, radix))}
20.164 + * </blockquote>
20.165 + *
20.166 + * @param s the string to be parsed
20.167 + * @param radix the radix to be used in interpreting {@code s}
20.168 + * @return a {@code Short} object holding the value
20.169 + * represented by the string argument in the
20.170 + * specified radix.
20.171 + * @throws NumberFormatException If the {@code String} does
20.172 + * not contain a parsable {@code short}.
20.173 + */
20.174 + public static Short valueOf(String s, int radix)
20.175 + throws NumberFormatException {
20.176 + return valueOf(parseShort(s, radix));
20.177 + }
20.178 +
20.179 + /**
20.180 + * Returns a {@code Short} object holding the
20.181 + * value given by the specified {@code String}. The argument
20.182 + * is interpreted as representing a signed decimal
20.183 + * {@code short}, exactly as if the argument were given to
20.184 + * the {@link #parseShort(java.lang.String)} method. The result is
20.185 + * a {@code Short} object that represents the
20.186 + * {@code short} value specified by the string.
20.187 + *
20.188 + * <p>In other words, this method returns a {@code Short} object
20.189 + * equal to the value of:
20.190 + *
20.191 + * <blockquote>
20.192 + * {@code new Short(Short.parseShort(s))}
20.193 + * </blockquote>
20.194 + *
20.195 + * @param s the string to be parsed
20.196 + * @return a {@code Short} object holding the value
20.197 + * represented by the string argument
20.198 + * @throws NumberFormatException If the {@code String} does
20.199 + * not contain a parsable {@code short}.
20.200 + */
20.201 + public static Short valueOf(String s) throws NumberFormatException {
20.202 + return valueOf(s, 10);
20.203 + }
20.204 +
20.205 + private static class ShortCache {
20.206 + private ShortCache(){}
20.207 +
20.208 + static final Short cache[] = new Short[-(-128) + 127 + 1];
20.209 +
20.210 + static {
20.211 + for(int i = 0; i < cache.length; i++)
20.212 + cache[i] = new Short((short)(i - 128));
20.213 + }
20.214 + }
20.215 +
20.216 + /**
20.217 + * Returns a {@code Short} instance representing the specified
20.218 + * {@code short} value.
20.219 + * If a new {@code Short} instance is not required, this method
20.220 + * should generally be used in preference to the constructor
20.221 + * {@link #Short(short)}, as this method is likely to yield
20.222 + * significantly better space and time performance by caching
20.223 + * frequently requested values.
20.224 + *
20.225 + * This method will always cache values in the range -128 to 127,
20.226 + * inclusive, and may cache other values outside of this range.
20.227 + *
20.228 + * @param s a short value.
20.229 + * @return a {@code Short} instance representing {@code s}.
20.230 + * @since 1.5
20.231 + */
20.232 + public static Short valueOf(short s) {
20.233 + final int offset = 128;
20.234 + int sAsInt = s;
20.235 + if (sAsInt >= -128 && sAsInt <= 127) { // must cache
20.236 + return ShortCache.cache[sAsInt + offset];
20.237 + }
20.238 + return new Short(s);
20.239 + }
20.240 +
20.241 + /**
20.242 + * Decodes a {@code String} into a {@code Short}.
20.243 + * Accepts decimal, hexadecimal, and octal numbers given by
20.244 + * the following grammar:
20.245 + *
20.246 + * <blockquote>
20.247 + * <dl>
20.248 + * <dt><i>DecodableString:</i>
20.249 + * <dd><i>Sign<sub>opt</sub> DecimalNumeral</i>
20.250 + * <dd><i>Sign<sub>opt</sub></i> {@code 0x} <i>HexDigits</i>
20.251 + * <dd><i>Sign<sub>opt</sub></i> {@code 0X} <i>HexDigits</i>
20.252 + * <dd><i>Sign<sub>opt</sub></i> {@code #} <i>HexDigits</i>
20.253 + * <dd><i>Sign<sub>opt</sub></i> {@code 0} <i>OctalDigits</i>
20.254 + * <p>
20.255 + * <dt><i>Sign:</i>
20.256 + * <dd>{@code -}
20.257 + * <dd>{@code +}
20.258 + * </dl>
20.259 + * </blockquote>
20.260 + *
20.261 + * <i>DecimalNumeral</i>, <i>HexDigits</i>, and <i>OctalDigits</i>
20.262 + * are as defined in section 3.10.1 of
20.263 + * <cite>The Java™ Language Specification</cite>,
20.264 + * except that underscores are not accepted between digits.
20.265 + *
20.266 + * <p>The sequence of characters following an optional
20.267 + * sign and/or radix specifier ("{@code 0x}", "{@code 0X}",
20.268 + * "{@code #}", or leading zero) is parsed as by the {@code
20.269 + * Short.parseShort} method with the indicated radix (10, 16, or
20.270 + * 8). This sequence of characters must represent a positive
20.271 + * value or a {@link NumberFormatException} will be thrown. The
20.272 + * result is negated if first character of the specified {@code
20.273 + * String} is the minus sign. No whitespace characters are
20.274 + * permitted in the {@code String}.
20.275 + *
20.276 + * @param nm the {@code String} to decode.
20.277 + * @return a {@code Short} object holding the {@code short}
20.278 + * value represented by {@code nm}
20.279 + * @throws NumberFormatException if the {@code String} does not
20.280 + * contain a parsable {@code short}.
20.281 + * @see java.lang.Short#parseShort(java.lang.String, int)
20.282 + */
20.283 + public static Short decode(String nm) throws NumberFormatException {
20.284 + int i = Integer.decode(nm);
20.285 + if (i < MIN_VALUE || i > MAX_VALUE)
20.286 + throw new NumberFormatException(
20.287 + "Value " + i + " out of range from input " + nm);
20.288 + return valueOf((short)i);
20.289 + }
20.290 +
20.291 + /**
20.292 + * The value of the {@code Short}.
20.293 + *
20.294 + * @serial
20.295 + */
20.296 + private final short value;
20.297 +
20.298 + /**
20.299 + * Constructs a newly allocated {@code Short} object that
20.300 + * represents the specified {@code short} value.
20.301 + *
20.302 + * @param value the value to be represented by the
20.303 + * {@code Short}.
20.304 + */
20.305 + public Short(short value) {
20.306 + this.value = value;
20.307 + }
20.308 +
20.309 + /**
20.310 + * Constructs a newly allocated {@code Short} object that
20.311 + * represents the {@code short} value indicated by the
20.312 + * {@code String} parameter. The string is converted to a
20.313 + * {@code short} value in exactly the manner used by the
20.314 + * {@code parseShort} method for radix 10.
20.315 + *
20.316 + * @param s the {@code String} to be converted to a
20.317 + * {@code Short}
20.318 + * @throws NumberFormatException If the {@code String}
20.319 + * does not contain a parsable {@code short}.
20.320 + * @see java.lang.Short#parseShort(java.lang.String, int)
20.321 + */
20.322 + public Short(String s) throws NumberFormatException {
20.323 + this.value = parseShort(s, 10);
20.324 + }
20.325 +
20.326 + /**
20.327 + * Returns the value of this {@code Short} as a
20.328 + * {@code byte}.
20.329 + */
20.330 + public byte byteValue() {
20.331 + return (byte)value;
20.332 + }
20.333 +
20.334 + /**
20.335 + * Returns the value of this {@code Short} as a
20.336 + * {@code short}.
20.337 + */
20.338 + public short shortValue() {
20.339 + return value;
20.340 + }
20.341 +
20.342 + /**
20.343 + * Returns the value of this {@code Short} as an
20.344 + * {@code int}.
20.345 + */
20.346 + public int intValue() {
20.347 + return (int)value;
20.348 + }
20.349 +
20.350 + /**
20.351 + * Returns the value of this {@code Short} as a
20.352 + * {@code long}.
20.353 + */
20.354 + public long longValue() {
20.355 + return (long)value;
20.356 + }
20.357 +
20.358 + /**
20.359 + * Returns the value of this {@code Short} as a
20.360 + * {@code float}.
20.361 + */
20.362 + public float floatValue() {
20.363 + return (float)value;
20.364 + }
20.365 +
20.366 + /**
20.367 + * Returns the value of this {@code Short} as a
20.368 + * {@code double}.
20.369 + */
20.370 + public double doubleValue() {
20.371 + return (double)value;
20.372 + }
20.373 +
20.374 + /**
20.375 + * Returns a {@code String} object representing this
20.376 + * {@code Short}'s value. The value is converted to signed
20.377 + * decimal representation and returned as a string, exactly as if
20.378 + * the {@code short} value were given as an argument to the
20.379 + * {@link java.lang.Short#toString(short)} method.
20.380 + *
20.381 + * @return a string representation of the value of this object in
20.382 + * base 10.
20.383 + */
20.384 + public String toString() {
20.385 + return Integer.toString((int)value);
20.386 + }
20.387 +
20.388 + /**
20.389 + * Returns a hash code for this {@code Short}; equal to the result
20.390 + * of invoking {@code intValue()}.
20.391 + *
20.392 + * @return a hash code value for this {@code Short}
20.393 + */
20.394 + public int hashCode() {
20.395 + return (int)value;
20.396 + }
20.397 +
20.398 + /**
20.399 + * Compares this object to the specified object. The result is
20.400 + * {@code true} if and only if the argument is not
20.401 + * {@code null} and is a {@code Short} object that
20.402 + * contains the same {@code short} value as this object.
20.403 + *
20.404 + * @param obj the object to compare with
20.405 + * @return {@code true} if the objects are the same;
20.406 + * {@code false} otherwise.
20.407 + */
20.408 + public boolean equals(Object obj) {
20.409 + if (obj instanceof Short) {
20.410 + return value == ((Short)obj).shortValue();
20.411 + }
20.412 + return false;
20.413 + }
20.414 +
20.415 + /**
20.416 + * Compares two {@code Short} objects numerically.
20.417 + *
20.418 + * @param anotherShort the {@code Short} to be compared.
20.419 + * @return the value {@code 0} if this {@code Short} is
20.420 + * equal to the argument {@code Short}; a value less than
20.421 + * {@code 0} if this {@code Short} is numerically less
20.422 + * than the argument {@code Short}; and a value greater than
20.423 + * {@code 0} if this {@code Short} is numerically
20.424 + * greater than the argument {@code Short} (signed
20.425 + * comparison).
20.426 + * @since 1.2
20.427 + */
20.428 + public int compareTo(Short anotherShort) {
20.429 + return compare(this.value, anotherShort.value);
20.430 + }
20.431 +
20.432 + /**
20.433 + * Compares two {@code short} values numerically.
20.434 + * The value returned is identical to what would be returned by:
20.435 + * <pre>
20.436 + * Short.valueOf(x).compareTo(Short.valueOf(y))
20.437 + * </pre>
20.438 + *
20.439 + * @param x the first {@code short} to compare
20.440 + * @param y the second {@code short} to compare
20.441 + * @return the value {@code 0} if {@code x == y};
20.442 + * a value less than {@code 0} if {@code x < y}; and
20.443 + * a value greater than {@code 0} if {@code x > y}
20.444 + * @since 1.7
20.445 + */
20.446 + public static int compare(short x, short y) {
20.447 + return x - y;
20.448 + }
20.449 +
20.450 + /**
20.451 + * The number of bits used to represent a {@code short} value in two's
20.452 + * complement binary form.
20.453 + * @since 1.5
20.454 + */
20.455 + public static final int SIZE = 16;
20.456 +
20.457 + /**
20.458 + * Returns the value obtained by reversing the order of the bytes in the
20.459 + * two's complement representation of the specified {@code short} value.
20.460 + *
20.461 + * @return the value obtained by reversing (or, equivalently, swapping)
20.462 + * the bytes in the specified {@code short} value.
20.463 + * @since 1.5
20.464 + */
20.465 + public static short reverseBytes(short i) {
20.466 + return (short) (((i & 0xFF00) >> 8) | (i << 8));
20.467 + }
20.468 +
20.469 + /** use serialVersionUID from JDK 1.1. for interoperability */
20.470 + private static final long serialVersionUID = 7515723908773894738L;
20.471 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/emul/src/main/java/java/lang/StrictMath.java Sun Sep 30 14:37:39 2012 -0700
21.3 @@ -0,0 +1,1468 @@
21.4 +/*
21.5 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21.7 + *
21.8 + * This code is free software; you can redistribute it and/or modify it
21.9 + * under the terms of the GNU General Public License version 2 only, as
21.10 + * published by the Free Software Foundation. Oracle designates this
21.11 + * particular file as subject to the "Classpath" exception as provided
21.12 + * by Oracle in the LICENSE file that accompanied this code.
21.13 + *
21.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
21.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21.17 + * version 2 for more details (a copy is included in the LICENSE file that
21.18 + * accompanied this code).
21.19 + *
21.20 + * You should have received a copy of the GNU General Public License version
21.21 + * 2 along with this work; if not, write to the Free Software Foundation,
21.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21.23 + *
21.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21.25 + * or visit www.oracle.com if you need additional information or have any
21.26 + * questions.
21.27 + */
21.28 +
21.29 +package java.lang;
21.30 +import java.util.Random;
21.31 +import sun.misc.FpUtils;
21.32 +import sun.misc.DoubleConsts;
21.33 +
21.34 +/**
21.35 + * The class {@code StrictMath} contains methods for performing basic
21.36 + * numeric operations such as the elementary exponential, logarithm,
21.37 + * square root, and trigonometric functions.
21.38 + *
21.39 + * <p>To help ensure portability of Java programs, the definitions of
21.40 + * some of the numeric functions in this package require that they
21.41 + * produce the same results as certain published algorithms. These
21.42 + * algorithms are available from the well-known network library
21.43 + * {@code netlib} as the package "Freely Distributable Math
21.44 + * Library," <a
21.45 + * href="ftp://ftp.netlib.org/fdlibm.tar">{@code fdlibm}</a>. These
21.46 + * algorithms, which are written in the C programming language, are
21.47 + * then to be understood as executed with all floating-point
21.48 + * operations following the rules of Java floating-point arithmetic.
21.49 + *
21.50 + * <p>The Java math library is defined with respect to
21.51 + * {@code fdlibm} version 5.3. Where {@code fdlibm} provides
21.52 + * more than one definition for a function (such as
21.53 + * {@code acos}), use the "IEEE 754 core function" version
21.54 + * (residing in a file whose name begins with the letter
21.55 + * {@code e}). The methods which require {@code fdlibm}
21.56 + * semantics are {@code sin}, {@code cos}, {@code tan},
21.57 + * {@code asin}, {@code acos}, {@code atan},
21.58 + * {@code exp}, {@code log}, {@code log10},
21.59 + * {@code cbrt}, {@code atan2}, {@code pow},
21.60 + * {@code sinh}, {@code cosh}, {@code tanh},
21.61 + * {@code hypot}, {@code expm1}, and {@code log1p}.
21.62 + *
21.63 + * @author unascribed
21.64 + * @author Joseph D. Darcy
21.65 + * @since 1.3
21.66 + */
21.67 +
21.68 +public final class StrictMath {
21.69 +
21.70 + /**
21.71 + * Don't let anyone instantiate this class.
21.72 + */
21.73 + private StrictMath() {}
21.74 +
21.75 + /**
21.76 + * The {@code double} value that is closer than any other to
21.77 + * <i>e</i>, the base of the natural logarithms.
21.78 + */
21.79 + public static final double E = 2.7182818284590452354;
21.80 +
21.81 + /**
21.82 + * The {@code double} value that is closer than any other to
21.83 + * <i>pi</i>, the ratio of the circumference of a circle to its
21.84 + * diameter.
21.85 + */
21.86 + public static final double PI = 3.14159265358979323846;
21.87 +
21.88 + /**
21.89 + * Returns the trigonometric sine of an angle. Special cases:
21.90 + * <ul><li>If the argument is NaN or an infinity, then the
21.91 + * result is NaN.
21.92 + * <li>If the argument is zero, then the result is a zero with the
21.93 + * same sign as the argument.</ul>
21.94 + *
21.95 + * @param a an angle, in radians.
21.96 + * @return the sine of the argument.
21.97 + */
21.98 + public static native double sin(double a);
21.99 +
21.100 + /**
21.101 + * Returns the trigonometric cosine of an angle. Special cases:
21.102 + * <ul><li>If the argument is NaN or an infinity, then the
21.103 + * result is NaN.</ul>
21.104 + *
21.105 + * @param a an angle, in radians.
21.106 + * @return the cosine of the argument.
21.107 + */
21.108 + public static native double cos(double a);
21.109 +
21.110 + /**
21.111 + * Returns the trigonometric tangent of an angle. Special cases:
21.112 + * <ul><li>If the argument is NaN or an infinity, then the result
21.113 + * is NaN.
21.114 + * <li>If the argument is zero, then the result is a zero with the
21.115 + * same sign as the argument.</ul>
21.116 + *
21.117 + * @param a an angle, in radians.
21.118 + * @return the tangent of the argument.
21.119 + */
21.120 + public static native double tan(double a);
21.121 +
21.122 + /**
21.123 + * Returns the arc sine of a value; the returned angle is in the
21.124 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
21.125 + * <ul><li>If the argument is NaN or its absolute value is greater
21.126 + * than 1, then the result is NaN.
21.127 + * <li>If the argument is zero, then the result is a zero with the
21.128 + * same sign as the argument.</ul>
21.129 + *
21.130 + * @param a the value whose arc sine is to be returned.
21.131 + * @return the arc sine of the argument.
21.132 + */
21.133 + public static native double asin(double a);
21.134 +
21.135 + /**
21.136 + * Returns the arc cosine of a value; the returned angle is in the
21.137 + * range 0.0 through <i>pi</i>. Special case:
21.138 + * <ul><li>If the argument is NaN or its absolute value is greater
21.139 + * than 1, then the result is NaN.</ul>
21.140 + *
21.141 + * @param a the value whose arc cosine is to be returned.
21.142 + * @return the arc cosine of the argument.
21.143 + */
21.144 + public static native double acos(double a);
21.145 +
21.146 + /**
21.147 + * Returns the arc tangent of a value; the returned angle is in the
21.148 + * range -<i>pi</i>/2 through <i>pi</i>/2. Special cases:
21.149 + * <ul><li>If the argument is NaN, then the result is NaN.
21.150 + * <li>If the argument is zero, then the result is a zero with the
21.151 + * same sign as the argument.</ul>
21.152 + *
21.153 + * @param a the value whose arc tangent is to be returned.
21.154 + * @return the arc tangent of the argument.
21.155 + */
21.156 + public static native double atan(double a);
21.157 +
21.158 + /**
21.159 + * Converts an angle measured in degrees to an approximately
21.160 + * equivalent angle measured in radians. The conversion from
21.161 + * degrees to radians is generally inexact.
21.162 + *
21.163 + * @param angdeg an angle, in degrees
21.164 + * @return the measurement of the angle {@code angdeg}
21.165 + * in radians.
21.166 + */
21.167 + public static strictfp double toRadians(double angdeg) {
21.168 + return angdeg / 180.0 * PI;
21.169 + }
21.170 +
21.171 + /**
21.172 + * Converts an angle measured in radians to an approximately
21.173 + * equivalent angle measured in degrees. The conversion from
21.174 + * radians to degrees is generally inexact; users should
21.175 + * <i>not</i> expect {@code cos(toRadians(90.0))} to exactly
21.176 + * equal {@code 0.0}.
21.177 + *
21.178 + * @param angrad an angle, in radians
21.179 + * @return the measurement of the angle {@code angrad}
21.180 + * in degrees.
21.181 + */
21.182 + public static strictfp double toDegrees(double angrad) {
21.183 + return angrad * 180.0 / PI;
21.184 + }
21.185 +
21.186 + /**
21.187 + * Returns Euler's number <i>e</i> raised to the power of a
21.188 + * {@code double} value. Special cases:
21.189 + * <ul><li>If the argument is NaN, the result is NaN.
21.190 + * <li>If the argument is positive infinity, then the result is
21.191 + * positive infinity.
21.192 + * <li>If the argument is negative infinity, then the result is
21.193 + * positive zero.</ul>
21.194 + *
21.195 + * @param a the exponent to raise <i>e</i> to.
21.196 + * @return the value <i>e</i><sup>{@code a}</sup>,
21.197 + * where <i>e</i> is the base of the natural logarithms.
21.198 + */
21.199 + public static native double exp(double a);
21.200 +
21.201 + /**
21.202 + * Returns the natural logarithm (base <i>e</i>) of a {@code double}
21.203 + * value. Special cases:
21.204 + * <ul><li>If the argument is NaN or less than zero, then the result
21.205 + * is NaN.
21.206 + * <li>If the argument is positive infinity, then the result is
21.207 + * positive infinity.
21.208 + * <li>If the argument is positive zero or negative zero, then the
21.209 + * result is negative infinity.</ul>
21.210 + *
21.211 + * @param a a value
21.212 + * @return the value ln {@code a}, the natural logarithm of
21.213 + * {@code a}.
21.214 + */
21.215 + public static native double log(double a);
21.216 +
21.217 +
21.218 + /**
21.219 + * Returns the base 10 logarithm of a {@code double} value.
21.220 + * Special cases:
21.221 + *
21.222 + * <ul><li>If the argument is NaN or less than zero, then the result
21.223 + * is NaN.
21.224 + * <li>If the argument is positive infinity, then the result is
21.225 + * positive infinity.
21.226 + * <li>If the argument is positive zero or negative zero, then the
21.227 + * result is negative infinity.
21.228 + * <li> If the argument is equal to 10<sup><i>n</i></sup> for
21.229 + * integer <i>n</i>, then the result is <i>n</i>.
21.230 + * </ul>
21.231 + *
21.232 + * @param a a value
21.233 + * @return the base 10 logarithm of {@code a}.
21.234 + * @since 1.5
21.235 + */
21.236 + public static native double log10(double a);
21.237 +
21.238 + /**
21.239 + * Returns the correctly rounded positive square root of a
21.240 + * {@code double} value.
21.241 + * Special cases:
21.242 + * <ul><li>If the argument is NaN or less than zero, then the result
21.243 + * is NaN.
21.244 + * <li>If the argument is positive infinity, then the result is positive
21.245 + * infinity.
21.246 + * <li>If the argument is positive zero or negative zero, then the
21.247 + * result is the same as the argument.</ul>
21.248 + * Otherwise, the result is the {@code double} value closest to
21.249 + * the true mathematical square root of the argument value.
21.250 + *
21.251 + * @param a a value.
21.252 + * @return the positive square root of {@code a}.
21.253 + */
21.254 + public static native double sqrt(double a);
21.255 +
21.256 + /**
21.257 + * Returns the cube root of a {@code double} value. For
21.258 + * positive finite {@code x}, {@code cbrt(-x) ==
21.259 + * -cbrt(x)}; that is, the cube root of a negative value is
21.260 + * the negative of the cube root of that value's magnitude.
21.261 + * Special cases:
21.262 + *
21.263 + * <ul>
21.264 + *
21.265 + * <li>If the argument is NaN, then the result is NaN.
21.266 + *
21.267 + * <li>If the argument is infinite, then the result is an infinity
21.268 + * with the same sign as the argument.
21.269 + *
21.270 + * <li>If the argument is zero, then the result is a zero with the
21.271 + * same sign as the argument.
21.272 + *
21.273 + * </ul>
21.274 + *
21.275 + * @param a a value.
21.276 + * @return the cube root of {@code a}.
21.277 + * @since 1.5
21.278 + */
21.279 + public static native double cbrt(double a);
21.280 +
21.281 + /**
21.282 + * Computes the remainder operation on two arguments as prescribed
21.283 + * by the IEEE 754 standard.
21.284 + * The remainder value is mathematically equal to
21.285 + * <code>f1 - f2</code> × <i>n</i>,
21.286 + * where <i>n</i> is the mathematical integer closest to the exact
21.287 + * mathematical value of the quotient {@code f1/f2}, and if two
21.288 + * mathematical integers are equally close to {@code f1/f2},
21.289 + * then <i>n</i> is the integer that is even. If the remainder is
21.290 + * zero, its sign is the same as the sign of the first argument.
21.291 + * Special cases:
21.292 + * <ul><li>If either argument is NaN, or the first argument is infinite,
21.293 + * or the second argument is positive zero or negative zero, then the
21.294 + * result is NaN.
21.295 + * <li>If the first argument is finite and the second argument is
21.296 + * infinite, then the result is the same as the first argument.</ul>
21.297 + *
21.298 + * @param f1 the dividend.
21.299 + * @param f2 the divisor.
21.300 + * @return the remainder when {@code f1} is divided by
21.301 + * {@code f2}.
21.302 + */
21.303 + public static native double IEEEremainder(double f1, double f2);
21.304 +
21.305 + /**
21.306 + * Returns the smallest (closest to negative infinity)
21.307 + * {@code double} value that is greater than or equal to the
21.308 + * argument and is equal to a mathematical integer. Special cases:
21.309 + * <ul><li>If the argument value is already equal to a
21.310 + * mathematical integer, then the result is the same as the
21.311 + * argument. <li>If the argument is NaN or an infinity or
21.312 + * positive zero or negative zero, then the result is the same as
21.313 + * the argument. <li>If the argument value is less than zero but
21.314 + * greater than -1.0, then the result is negative zero.</ul> Note
21.315 + * that the value of {@code StrictMath.ceil(x)} is exactly the
21.316 + * value of {@code -StrictMath.floor(-x)}.
21.317 + *
21.318 + * @param a a value.
21.319 + * @return the smallest (closest to negative infinity)
21.320 + * floating-point value that is greater than or equal to
21.321 + * the argument and is equal to a mathematical integer.
21.322 + */
21.323 + public static double ceil(double a) {
21.324 + return floorOrCeil(a, -0.0, 1.0, 1.0);
21.325 + }
21.326 +
21.327 + /**
21.328 + * Returns the largest (closest to positive infinity)
21.329 + * {@code double} value that is less than or equal to the
21.330 + * argument and is equal to a mathematical integer. Special cases:
21.331 + * <ul><li>If the argument value is already equal to a
21.332 + * mathematical integer, then the result is the same as the
21.333 + * argument. <li>If the argument is NaN or an infinity or
21.334 + * positive zero or negative zero, then the result is the same as
21.335 + * the argument.</ul>
21.336 + *
21.337 + * @param a a value.
21.338 + * @return the largest (closest to positive infinity)
21.339 + * floating-point value that less than or equal to the argument
21.340 + * and is equal to a mathematical integer.
21.341 + */
21.342 + public static double floor(double a) {
21.343 + return floorOrCeil(a, -1.0, 0.0, -1.0);
21.344 + }
21.345 +
21.346 + /**
21.347 + * Internal method to share logic between floor and ceil.
21.348 + *
21.349 + * @param a the value to be floored or ceiled
21.350 + * @param negativeBoundary result for values in (-1, 0)
21.351 + * @param positiveBoundary result for values in (0, 1)
21.352 + * @param increment value to add when the argument is non-integral
21.353 + */
21.354 + private static double floorOrCeil(double a,
21.355 + double negativeBoundary,
21.356 + double positiveBoundary,
21.357 + double sign) {
21.358 + int exponent = Math.getExponent(a);
21.359 +
21.360 + if (exponent < 0) {
21.361 + /*
21.362 + * Absolute value of argument is less than 1.
21.363 + * floorOrceil(-0.0) => -0.0
21.364 + * floorOrceil(+0.0) => +0.0
21.365 + */
21.366 + return ((a == 0.0) ? a :
21.367 + ( (a < 0.0) ? negativeBoundary : positiveBoundary) );
21.368 + } else if (exponent >= 52) {
21.369 + /*
21.370 + * Infinity, NaN, or a value so large it must be integral.
21.371 + */
21.372 + return a;
21.373 + }
21.374 + // Else the argument is either an integral value already XOR it
21.375 + // has to be rounded to one.
21.376 + assert exponent >= 0 && exponent <= 51;
21.377 +
21.378 + long doppel = Double.doubleToRawLongBits(a);
21.379 + long mask = DoubleConsts.SIGNIF_BIT_MASK >> exponent;
21.380 +
21.381 + if ( (mask & doppel) == 0L )
21.382 + return a; // integral value
21.383 + else {
21.384 + double result = Double.longBitsToDouble(doppel & (~mask));
21.385 + if (sign*a > 0.0)
21.386 + result = result + sign;
21.387 + return result;
21.388 + }
21.389 + }
21.390 +
21.391 + /**
21.392 + * Returns the {@code double} value that is closest in value
21.393 + * to the argument and is equal to a mathematical integer. If two
21.394 + * {@code double} values that are mathematical integers are
21.395 + * equally close to the value of the argument, the result is the
21.396 + * integer value that is even. Special cases:
21.397 + * <ul><li>If the argument value is already equal to a mathematical
21.398 + * integer, then the result is the same as the argument.
21.399 + * <li>If the argument is NaN or an infinity or positive zero or negative
21.400 + * zero, then the result is the same as the argument.</ul>
21.401 + *
21.402 + * @param a a value.
21.403 + * @return the closest floating-point value to {@code a} that is
21.404 + * equal to a mathematical integer.
21.405 + * @author Joseph D. Darcy
21.406 + */
21.407 + public static double rint(double a) {
21.408 + /*
21.409 + * If the absolute value of a is not less than 2^52, it
21.410 + * is either a finite integer (the double format does not have
21.411 + * enough significand bits for a number that large to have any
21.412 + * fractional portion), an infinity, or a NaN. In any of
21.413 + * these cases, rint of the argument is the argument.
21.414 + *
21.415 + * Otherwise, the sum (twoToThe52 + a ) will properly round
21.416 + * away any fractional portion of a since ulp(twoToThe52) ==
21.417 + * 1.0; subtracting out twoToThe52 from this sum will then be
21.418 + * exact and leave the rounded integer portion of a.
21.419 + *
21.420 + * This method does *not* need to be declared strictfp to get
21.421 + * fully reproducible results. Whether or not a method is
21.422 + * declared strictfp can only make a difference in the
21.423 + * returned result if some operation would overflow or
21.424 + * underflow with strictfp semantics. The operation
21.425 + * (twoToThe52 + a ) cannot overflow since large values of a
21.426 + * are screened out; the add cannot underflow since twoToThe52
21.427 + * is too large. The subtraction ((twoToThe52 + a ) -
21.428 + * twoToThe52) will be exact as discussed above and thus
21.429 + * cannot overflow or meaningfully underflow. Finally, the
21.430 + * last multiply in the return statement is by plus or minus
21.431 + * 1.0, which is exact too.
21.432 + */
21.433 + double twoToThe52 = (double)(1L << 52); // 2^52
21.434 + double sign = FpUtils.rawCopySign(1.0, a); // preserve sign info
21.435 + a = Math.abs(a);
21.436 +
21.437 + if (a < twoToThe52) { // E_min <= ilogb(a) <= 51
21.438 + a = ((twoToThe52 + a ) - twoToThe52);
21.439 + }
21.440 +
21.441 + return sign * a; // restore original sign
21.442 + }
21.443 +
21.444 + /**
21.445 + * Returns the angle <i>theta</i> from the conversion of rectangular
21.446 + * coordinates ({@code x}, {@code y}) to polar
21.447 + * coordinates (r, <i>theta</i>).
21.448 + * This method computes the phase <i>theta</i> by computing an arc tangent
21.449 + * of {@code y/x} in the range of -<i>pi</i> to <i>pi</i>. Special
21.450 + * cases:
21.451 + * <ul><li>If either argument is NaN, then the result is NaN.
21.452 + * <li>If the first argument is positive zero and the second argument
21.453 + * is positive, or the first argument is positive and finite and the
21.454 + * second argument is positive infinity, then the result is positive
21.455 + * zero.
21.456 + * <li>If the first argument is negative zero and the second argument
21.457 + * is positive, or the first argument is negative and finite and the
21.458 + * second argument is positive infinity, then the result is negative zero.
21.459 + * <li>If the first argument is positive zero and the second argument
21.460 + * is negative, or the first argument is positive and finite and the
21.461 + * second argument is negative infinity, then the result is the
21.462 + * {@code double} value closest to <i>pi</i>.
21.463 + * <li>If the first argument is negative zero and the second argument
21.464 + * is negative, or the first argument is negative and finite and the
21.465 + * second argument is negative infinity, then the result is the
21.466 + * {@code double} value closest to -<i>pi</i>.
21.467 + * <li>If the first argument is positive and the second argument is
21.468 + * positive zero or negative zero, or the first argument is positive
21.469 + * infinity and the second argument is finite, then the result is the
21.470 + * {@code double} value closest to <i>pi</i>/2.
21.471 + * <li>If the first argument is negative and the second argument is
21.472 + * positive zero or negative zero, or the first argument is negative
21.473 + * infinity and the second argument is finite, then the result is the
21.474 + * {@code double} value closest to -<i>pi</i>/2.
21.475 + * <li>If both arguments are positive infinity, then the result is the
21.476 + * {@code double} value closest to <i>pi</i>/4.
21.477 + * <li>If the first argument is positive infinity and the second argument
21.478 + * is negative infinity, then the result is the {@code double}
21.479 + * value closest to 3*<i>pi</i>/4.
21.480 + * <li>If the first argument is negative infinity and the second argument
21.481 + * is positive infinity, then the result is the {@code double} value
21.482 + * closest to -<i>pi</i>/4.
21.483 + * <li>If both arguments are negative infinity, then the result is the
21.484 + * {@code double} value closest to -3*<i>pi</i>/4.</ul>
21.485 + *
21.486 + * @param y the ordinate coordinate
21.487 + * @param x the abscissa coordinate
21.488 + * @return the <i>theta</i> component of the point
21.489 + * (<i>r</i>, <i>theta</i>)
21.490 + * in polar coordinates that corresponds to the point
21.491 + * (<i>x</i>, <i>y</i>) in Cartesian coordinates.
21.492 + */
21.493 + public static native double atan2(double y, double x);
21.494 +
21.495 +
21.496 + /**
21.497 + * Returns the value of the first argument raised to the power of the
21.498 + * second argument. Special cases:
21.499 + *
21.500 + * <ul><li>If the second argument is positive or negative zero, then the
21.501 + * result is 1.0.
21.502 + * <li>If the second argument is 1.0, then the result is the same as the
21.503 + * first argument.
21.504 + * <li>If the second argument is NaN, then the result is NaN.
21.505 + * <li>If the first argument is NaN and the second argument is nonzero,
21.506 + * then the result is NaN.
21.507 + *
21.508 + * <li>If
21.509 + * <ul>
21.510 + * <li>the absolute value of the first argument is greater than 1
21.511 + * and the second argument is positive infinity, or
21.512 + * <li>the absolute value of the first argument is less than 1 and
21.513 + * the second argument is negative infinity,
21.514 + * </ul>
21.515 + * then the result is positive infinity.
21.516 + *
21.517 + * <li>If
21.518 + * <ul>
21.519 + * <li>the absolute value of the first argument is greater than 1 and
21.520 + * the second argument is negative infinity, or
21.521 + * <li>the absolute value of the
21.522 + * first argument is less than 1 and the second argument is positive
21.523 + * infinity,
21.524 + * </ul>
21.525 + * then the result is positive zero.
21.526 + *
21.527 + * <li>If the absolute value of the first argument equals 1 and the
21.528 + * second argument is infinite, then the result is NaN.
21.529 + *
21.530 + * <li>If
21.531 + * <ul>
21.532 + * <li>the first argument is positive zero and the second argument
21.533 + * is greater than zero, or
21.534 + * <li>the first argument is positive infinity and the second
21.535 + * argument is less than zero,
21.536 + * </ul>
21.537 + * then the result is positive zero.
21.538 + *
21.539 + * <li>If
21.540 + * <ul>
21.541 + * <li>the first argument is positive zero and the second argument
21.542 + * is less than zero, or
21.543 + * <li>the first argument is positive infinity and the second
21.544 + * argument is greater than zero,
21.545 + * </ul>
21.546 + * then the result is positive infinity.
21.547 + *
21.548 + * <li>If
21.549 + * <ul>
21.550 + * <li>the first argument is negative zero and the second argument
21.551 + * is greater than zero but not a finite odd integer, or
21.552 + * <li>the first argument is negative infinity and the second
21.553 + * argument is less than zero but not a finite odd integer,
21.554 + * </ul>
21.555 + * then the result is positive zero.
21.556 + *
21.557 + * <li>If
21.558 + * <ul>
21.559 + * <li>the first argument is negative zero and the second argument
21.560 + * is a positive finite odd integer, or
21.561 + * <li>the first argument is negative infinity and the second
21.562 + * argument is a negative finite odd integer,
21.563 + * </ul>
21.564 + * then the result is negative zero.
21.565 + *
21.566 + * <li>If
21.567 + * <ul>
21.568 + * <li>the first argument is negative zero and the second argument
21.569 + * is less than zero but not a finite odd integer, or
21.570 + * <li>the first argument is negative infinity and the second
21.571 + * argument is greater than zero but not a finite odd integer,
21.572 + * </ul>
21.573 + * then the result is positive infinity.
21.574 + *
21.575 + * <li>If
21.576 + * <ul>
21.577 + * <li>the first argument is negative zero and the second argument
21.578 + * is a negative finite odd integer, or
21.579 + * <li>the first argument is negative infinity and the second
21.580 + * argument is a positive finite odd integer,
21.581 + * </ul>
21.582 + * then the result is negative infinity.
21.583 + *
21.584 + * <li>If the first argument is finite and less than zero
21.585 + * <ul>
21.586 + * <li> if the second argument is a finite even integer, the
21.587 + * result is equal to the result of raising the absolute value of
21.588 + * the first argument to the power of the second argument
21.589 + *
21.590 + * <li>if the second argument is a finite odd integer, the result
21.591 + * is equal to the negative of the result of raising the absolute
21.592 + * value of the first argument to the power of the second
21.593 + * argument
21.594 + *
21.595 + * <li>if the second argument is finite and not an integer, then
21.596 + * the result is NaN.
21.597 + * </ul>
21.598 + *
21.599 + * <li>If both arguments are integers, then the result is exactly equal
21.600 + * to the mathematical result of raising the first argument to the power
21.601 + * of the second argument if that result can in fact be represented
21.602 + * exactly as a {@code double} value.</ul>
21.603 + *
21.604 + * <p>(In the foregoing descriptions, a floating-point value is
21.605 + * considered to be an integer if and only if it is finite and a
21.606 + * fixed point of the method {@link #ceil ceil} or,
21.607 + * equivalently, a fixed point of the method {@link #floor
21.608 + * floor}. A value is a fixed point of a one-argument
21.609 + * method if and only if the result of applying the method to the
21.610 + * value is equal to the value.)
21.611 + *
21.612 + * @param a base.
21.613 + * @param b the exponent.
21.614 + * @return the value {@code a}<sup>{@code b}</sup>.
21.615 + */
21.616 + public static native double pow(double a, double b);
21.617 +
21.618 + /**
21.619 + * Returns the closest {@code int} to the argument, with ties
21.620 + * rounding up.
21.621 + *
21.622 + * <p>Special cases:
21.623 + * <ul><li>If the argument is NaN, the result is 0.
21.624 + * <li>If the argument is negative infinity or any value less than or
21.625 + * equal to the value of {@code Integer.MIN_VALUE}, the result is
21.626 + * equal to the value of {@code Integer.MIN_VALUE}.
21.627 + * <li>If the argument is positive infinity or any value greater than or
21.628 + * equal to the value of {@code Integer.MAX_VALUE}, the result is
21.629 + * equal to the value of {@code Integer.MAX_VALUE}.</ul>
21.630 + *
21.631 + * @param a a floating-point value to be rounded to an integer.
21.632 + * @return the value of the argument rounded to the nearest
21.633 + * {@code int} value.
21.634 + * @see java.lang.Integer#MAX_VALUE
21.635 + * @see java.lang.Integer#MIN_VALUE
21.636 + */
21.637 + public static int round(float a) {
21.638 + return Math.round(a);
21.639 + }
21.640 +
21.641 + /**
21.642 + * Returns the closest {@code long} to the argument, with ties
21.643 + * rounding up.
21.644 + *
21.645 + * <p>Special cases:
21.646 + * <ul><li>If the argument is NaN, the result is 0.
21.647 + * <li>If the argument is negative infinity or any value less than or
21.648 + * equal to the value of {@code Long.MIN_VALUE}, the result is
21.649 + * equal to the value of {@code Long.MIN_VALUE}.
21.650 + * <li>If the argument is positive infinity or any value greater than or
21.651 + * equal to the value of {@code Long.MAX_VALUE}, the result is
21.652 + * equal to the value of {@code Long.MAX_VALUE}.</ul>
21.653 + *
21.654 + * @param a a floating-point value to be rounded to a
21.655 + * {@code long}.
21.656 + * @return the value of the argument rounded to the nearest
21.657 + * {@code long} value.
21.658 + * @see java.lang.Long#MAX_VALUE
21.659 + * @see java.lang.Long#MIN_VALUE
21.660 + */
21.661 + public static long round(double a) {
21.662 + return Math.round(a);
21.663 + }
21.664 +
21.665 + private static Random randomNumberGenerator;
21.666 +
21.667 + private static synchronized Random initRNG() {
21.668 + Random rnd = randomNumberGenerator;
21.669 + return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;
21.670 + }
21.671 +
21.672 + /**
21.673 + * Returns a {@code double} value with a positive sign, greater
21.674 + * than or equal to {@code 0.0} and less than {@code 1.0}.
21.675 + * Returned values are chosen pseudorandomly with (approximately)
21.676 + * uniform distribution from that range.
21.677 + *
21.678 + * <p>When this method is first called, it creates a single new
21.679 + * pseudorandom-number generator, exactly as if by the expression
21.680 + *
21.681 + * <blockquote>{@code new java.util.Random()}</blockquote>
21.682 + *
21.683 + * This new pseudorandom-number generator is used thereafter for
21.684 + * all calls to this method and is used nowhere else.
21.685 + *
21.686 + * <p>This method is properly synchronized to allow correct use by
21.687 + * more than one thread. However, if many threads need to generate
21.688 + * pseudorandom numbers at a great rate, it may reduce contention
21.689 + * for each thread to have its own pseudorandom number generator.
21.690 + *
21.691 + * @return a pseudorandom {@code double} greater than or equal
21.692 + * to {@code 0.0} and less than {@code 1.0}.
21.693 + * @see Random#nextDouble()
21.694 + */
21.695 + public static double random() {
21.696 + Random rnd = randomNumberGenerator;
21.697 + if (rnd == null) rnd = initRNG();
21.698 + return rnd.nextDouble();
21.699 + }
21.700 +
21.701 + /**
21.702 + * Returns the absolute value of an {@code int} value..
21.703 + * If the argument is not negative, the argument is returned.
21.704 + * If the argument is negative, the negation of the argument is returned.
21.705 + *
21.706 + * <p>Note that if the argument is equal to the value of
21.707 + * {@link Integer#MIN_VALUE}, the most negative representable
21.708 + * {@code int} value, the result is that same value, which is
21.709 + * negative.
21.710 + *
21.711 + * @param a the argument whose absolute value is to be determined.
21.712 + * @return the absolute value of the argument.
21.713 + */
21.714 + public static int abs(int a) {
21.715 + return (a < 0) ? -a : a;
21.716 + }
21.717 +
21.718 + /**
21.719 + * Returns the absolute value of a {@code long} value.
21.720 + * If the argument is not negative, the argument is returned.
21.721 + * If the argument is negative, the negation of the argument is returned.
21.722 + *
21.723 + * <p>Note that if the argument is equal to the value of
21.724 + * {@link Long#MIN_VALUE}, the most negative representable
21.725 + * {@code long} value, the result is that same value, which
21.726 + * is negative.
21.727 + *
21.728 + * @param a the argument whose absolute value is to be determined.
21.729 + * @return the absolute value of the argument.
21.730 + */
21.731 + public static long abs(long a) {
21.732 + return (a < 0) ? -a : a;
21.733 + }
21.734 +
21.735 + /**
21.736 + * Returns the absolute value of a {@code float} value.
21.737 + * If the argument is not negative, the argument is returned.
21.738 + * If the argument is negative, the negation of the argument is returned.
21.739 + * Special cases:
21.740 + * <ul><li>If the argument is positive zero or negative zero, the
21.741 + * result is positive zero.
21.742 + * <li>If the argument is infinite, the result is positive infinity.
21.743 + * <li>If the argument is NaN, the result is NaN.</ul>
21.744 + * In other words, the result is the same as the value of the expression:
21.745 + * <p>{@code Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))}
21.746 + *
21.747 + * @param a the argument whose absolute value is to be determined
21.748 + * @return the absolute value of the argument.
21.749 + */
21.750 + public static float abs(float a) {
21.751 + return (a <= 0.0F) ? 0.0F - a : a;
21.752 + }
21.753 +
21.754 + /**
21.755 + * Returns the absolute value of a {@code double} value.
21.756 + * If the argument is not negative, the argument is returned.
21.757 + * If the argument is negative, the negation of the argument is returned.
21.758 + * Special cases:
21.759 + * <ul><li>If the argument is positive zero or negative zero, the result
21.760 + * is positive zero.
21.761 + * <li>If the argument is infinite, the result is positive infinity.
21.762 + * <li>If the argument is NaN, the result is NaN.</ul>
21.763 + * In other words, the result is the same as the value of the expression:
21.764 + * <p>{@code Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1)}
21.765 + *
21.766 + * @param a the argument whose absolute value is to be determined
21.767 + * @return the absolute value of the argument.
21.768 + */
21.769 + public static double abs(double a) {
21.770 + return (a <= 0.0D) ? 0.0D - a : a;
21.771 + }
21.772 +
21.773 + /**
21.774 + * Returns the greater of two {@code int} values. That is, the
21.775 + * result is the argument closer to the value of
21.776 + * {@link Integer#MAX_VALUE}. If the arguments have the same value,
21.777 + * the result is that same value.
21.778 + *
21.779 + * @param a an argument.
21.780 + * @param b another argument.
21.781 + * @return the larger of {@code a} and {@code b}.
21.782 + */
21.783 + public static int max(int a, int b) {
21.784 + return (a >= b) ? a : b;
21.785 + }
21.786 +
21.787 + /**
21.788 + * Returns the greater of two {@code long} values. That is, the
21.789 + * result is the argument closer to the value of
21.790 + * {@link Long#MAX_VALUE}. If the arguments have the same value,
21.791 + * the result is that same value.
21.792 + *
21.793 + * @param a an argument.
21.794 + * @param b another argument.
21.795 + * @return the larger of {@code a} and {@code b}.
21.796 + */
21.797 + public static long max(long a, long b) {
21.798 + return (a >= b) ? a : b;
21.799 + }
21.800 +
21.801 + // Use raw bit-wise conversions on guaranteed non-NaN arguments.
21.802 + private static long negativeZeroFloatBits = Float.floatToRawIntBits(-0.0f);
21.803 + private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
21.804 +
21.805 + /**
21.806 + * Returns the greater of two {@code float} values. That is,
21.807 + * the result is the argument closer to positive infinity. If the
21.808 + * arguments have the same value, the result is that same
21.809 + * value. If either value is NaN, then the result is NaN. Unlike
21.810 + * the numerical comparison operators, this method considers
21.811 + * negative zero to be strictly smaller than positive zero. If one
21.812 + * argument is positive zero and the other negative zero, the
21.813 + * result is positive zero.
21.814 + *
21.815 + * @param a an argument.
21.816 + * @param b another argument.
21.817 + * @return the larger of {@code a} and {@code b}.
21.818 + */
21.819 + public static float max(float a, float b) {
21.820 + if (a != a)
21.821 + return a; // a is NaN
21.822 + if ((a == 0.0f) &&
21.823 + (b == 0.0f) &&
21.824 + (Float.floatToRawIntBits(a) == negativeZeroFloatBits)) {
21.825 + // Raw conversion ok since NaN can't map to -0.0.
21.826 + return b;
21.827 + }
21.828 + return (a >= b) ? a : b;
21.829 + }
21.830 +
21.831 + /**
21.832 + * Returns the greater of two {@code double} values. That
21.833 + * is, the result is the argument closer to positive infinity. If
21.834 + * the arguments have the same value, the result is that same
21.835 + * value. If either value is NaN, then the result is NaN. Unlike
21.836 + * the numerical comparison operators, this method considers
21.837 + * negative zero to be strictly smaller than positive zero. If one
21.838 + * argument is positive zero and the other negative zero, the
21.839 + * result is positive zero.
21.840 + *
21.841 + * @param a an argument.
21.842 + * @param b another argument.
21.843 + * @return the larger of {@code a} and {@code b}.
21.844 + */
21.845 + public static double max(double a, double b) {
21.846 + if (a != a)
21.847 + return a; // a is NaN
21.848 + if ((a == 0.0d) &&
21.849 + (b == 0.0d) &&
21.850 + (Double.doubleToRawLongBits(a) == negativeZeroDoubleBits)) {
21.851 + // Raw conversion ok since NaN can't map to -0.0.
21.852 + return b;
21.853 + }
21.854 + return (a >= b) ? a : b;
21.855 + }
21.856 +
21.857 + /**
21.858 + * Returns the smaller of two {@code int} values. That is,
21.859 + * the result the argument closer to the value of
21.860 + * {@link Integer#MIN_VALUE}. If the arguments have the same
21.861 + * value, the result is that same value.
21.862 + *
21.863 + * @param a an argument.
21.864 + * @param b another argument.
21.865 + * @return the smaller of {@code a} and {@code b}.
21.866 + */
21.867 + public static int min(int a, int b) {
21.868 + return (a <= b) ? a : b;
21.869 + }
21.870 +
21.871 + /**
21.872 + * Returns the smaller of two {@code long} values. That is,
21.873 + * the result is the argument closer to the value of
21.874 + * {@link Long#MIN_VALUE}. If the arguments have the same
21.875 + * value, the result is that same value.
21.876 + *
21.877 + * @param a an argument.
21.878 + * @param b another argument.
21.879 + * @return the smaller of {@code a} and {@code b}.
21.880 + */
21.881 + public static long min(long a, long b) {
21.882 + return (a <= b) ? a : b;
21.883 + }
21.884 +
21.885 + /**
21.886 + * Returns the smaller of two {@code float} values. That is,
21.887 + * the result is the value closer to negative infinity. If the
21.888 + * arguments have the same value, the result is that same
21.889 + * value. If either value is NaN, then the result is NaN. Unlike
21.890 + * the numerical comparison operators, this method considers
21.891 + * negative zero to be strictly smaller than positive zero. If
21.892 + * one argument is positive zero and the other is negative zero,
21.893 + * the result is negative zero.
21.894 + *
21.895 + * @param a an argument.
21.896 + * @param b another argument.
21.897 + * @return the smaller of {@code a} and {@code b.}
21.898 + */
21.899 + public static float min(float a, float b) {
21.900 + if (a != a)
21.901 + return a; // a is NaN
21.902 + if ((a == 0.0f) &&
21.903 + (b == 0.0f) &&
21.904 + (Float.floatToRawIntBits(b) == negativeZeroFloatBits)) {
21.905 + // Raw conversion ok since NaN can't map to -0.0.
21.906 + return b;
21.907 + }
21.908 + return (a <= b) ? a : b;
21.909 + }
21.910 +
21.911 + /**
21.912 + * Returns the smaller of two {@code double} values. That
21.913 + * is, the result is the value closer to negative infinity. If the
21.914 + * arguments have the same value, the result is that same
21.915 + * value. If either value is NaN, then the result is NaN. Unlike
21.916 + * the numerical comparison operators, this method considers
21.917 + * negative zero to be strictly smaller than positive zero. If one
21.918 + * argument is positive zero and the other is negative zero, the
21.919 + * result is negative zero.
21.920 + *
21.921 + * @param a an argument.
21.922 + * @param b another argument.
21.923 + * @return the smaller of {@code a} and {@code b}.
21.924 + */
21.925 + public static double min(double a, double b) {
21.926 + if (a != a)
21.927 + return a; // a is NaN
21.928 + if ((a == 0.0d) &&
21.929 + (b == 0.0d) &&
21.930 + (Double.doubleToRawLongBits(b) == negativeZeroDoubleBits)) {
21.931 + // Raw conversion ok since NaN can't map to -0.0.
21.932 + return b;
21.933 + }
21.934 + return (a <= b) ? a : b;
21.935 + }
21.936 +
21.937 + /**
21.938 + * Returns the size of an ulp of the argument. An ulp of a
21.939 + * {@code double} value is the positive distance between this
21.940 + * floating-point value and the {@code double} value next
21.941 + * larger in magnitude. Note that for non-NaN <i>x</i>,
21.942 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
21.943 + *
21.944 + * <p>Special Cases:
21.945 + * <ul>
21.946 + * <li> If the argument is NaN, then the result is NaN.
21.947 + * <li> If the argument is positive or negative infinity, then the
21.948 + * result is positive infinity.
21.949 + * <li> If the argument is positive or negative zero, then the result is
21.950 + * {@code Double.MIN_VALUE}.
21.951 + * <li> If the argument is ±{@code Double.MAX_VALUE}, then
21.952 + * the result is equal to 2<sup>971</sup>.
21.953 + * </ul>
21.954 + *
21.955 + * @param d the floating-point value whose ulp is to be returned
21.956 + * @return the size of an ulp of the argument
21.957 + * @author Joseph D. Darcy
21.958 + * @since 1.5
21.959 + */
21.960 + public static double ulp(double d) {
21.961 + return sun.misc.FpUtils.ulp(d);
21.962 + }
21.963 +
21.964 + /**
21.965 + * Returns the size of an ulp of the argument. An ulp of a
21.966 + * {@code float} value is the positive distance between this
21.967 + * floating-point value and the {@code float} value next
21.968 + * larger in magnitude. Note that for non-NaN <i>x</i>,
21.969 + * <code>ulp(-<i>x</i>) == ulp(<i>x</i>)</code>.
21.970 + *
21.971 + * <p>Special Cases:
21.972 + * <ul>
21.973 + * <li> If the argument is NaN, then the result is NaN.
21.974 + * <li> If the argument is positive or negative infinity, then the
21.975 + * result is positive infinity.
21.976 + * <li> If the argument is positive or negative zero, then the result is
21.977 + * {@code Float.MIN_VALUE}.
21.978 + * <li> If the argument is ±{@code Float.MAX_VALUE}, then
21.979 + * the result is equal to 2<sup>104</sup>.
21.980 + * </ul>
21.981 + *
21.982 + * @param f the floating-point value whose ulp is to be returned
21.983 + * @return the size of an ulp of the argument
21.984 + * @author Joseph D. Darcy
21.985 + * @since 1.5
21.986 + */
21.987 + public static float ulp(float f) {
21.988 + return sun.misc.FpUtils.ulp(f);
21.989 + }
21.990 +
21.991 + /**
21.992 + * Returns the signum function of the argument; zero if the argument
21.993 + * is zero, 1.0 if the argument is greater than zero, -1.0 if the
21.994 + * argument is less than zero.
21.995 + *
21.996 + * <p>Special Cases:
21.997 + * <ul>
21.998 + * <li> If the argument is NaN, then the result is NaN.
21.999 + * <li> If the argument is positive zero or negative zero, then the
21.1000 + * result is the same as the argument.
21.1001 + * </ul>
21.1002 + *
21.1003 + * @param d the floating-point value whose signum is to be returned
21.1004 + * @return the signum function of the argument
21.1005 + * @author Joseph D. Darcy
21.1006 + * @since 1.5
21.1007 + */
21.1008 + public static double signum(double d) {
21.1009 + return sun.misc.FpUtils.signum(d);
21.1010 + }
21.1011 +
21.1012 + /**
21.1013 + * Returns the signum function of the argument; zero if the argument
21.1014 + * is zero, 1.0f if the argument is greater than zero, -1.0f if the
21.1015 + * argument is less than zero.
21.1016 + *
21.1017 + * <p>Special Cases:
21.1018 + * <ul>
21.1019 + * <li> If the argument is NaN, then the result is NaN.
21.1020 + * <li> If the argument is positive zero or negative zero, then the
21.1021 + * result is the same as the argument.
21.1022 + * </ul>
21.1023 + *
21.1024 + * @param f the floating-point value whose signum is to be returned
21.1025 + * @return the signum function of the argument
21.1026 + * @author Joseph D. Darcy
21.1027 + * @since 1.5
21.1028 + */
21.1029 + public static float signum(float f) {
21.1030 + return sun.misc.FpUtils.signum(f);
21.1031 + }
21.1032 +
21.1033 + /**
21.1034 + * Returns the hyperbolic sine of a {@code double} value.
21.1035 + * The hyperbolic sine of <i>x</i> is defined to be
21.1036 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/2
21.1037 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
21.1038 + *
21.1039 + * <p>Special cases:
21.1040 + * <ul>
21.1041 + *
21.1042 + * <li>If the argument is NaN, then the result is NaN.
21.1043 + *
21.1044 + * <li>If the argument is infinite, then the result is an infinity
21.1045 + * with the same sign as the argument.
21.1046 + *
21.1047 + * <li>If the argument is zero, then the result is a zero with the
21.1048 + * same sign as the argument.
21.1049 + *
21.1050 + * </ul>
21.1051 + *
21.1052 + * @param x The number whose hyperbolic sine is to be returned.
21.1053 + * @return The hyperbolic sine of {@code x}.
21.1054 + * @since 1.5
21.1055 + */
21.1056 + public static native double sinh(double x);
21.1057 +
21.1058 + /**
21.1059 + * Returns the hyperbolic cosine of a {@code double} value.
21.1060 + * The hyperbolic cosine of <i>x</i> is defined to be
21.1061 + * (<i>e<sup>x</sup> + e<sup>-x</sup></i>)/2
21.1062 + * where <i>e</i> is {@linkplain Math#E Euler's number}.
21.1063 + *
21.1064 + * <p>Special cases:
21.1065 + * <ul>
21.1066 + *
21.1067 + * <li>If the argument is NaN, then the result is NaN.
21.1068 + *
21.1069 + * <li>If the argument is infinite, then the result is positive
21.1070 + * infinity.
21.1071 + *
21.1072 + * <li>If the argument is zero, then the result is {@code 1.0}.
21.1073 + *
21.1074 + * </ul>
21.1075 + *
21.1076 + * @param x The number whose hyperbolic cosine is to be returned.
21.1077 + * @return The hyperbolic cosine of {@code x}.
21.1078 + * @since 1.5
21.1079 + */
21.1080 + public static native double cosh(double x);
21.1081 +
21.1082 + /**
21.1083 + * Returns the hyperbolic tangent of a {@code double} value.
21.1084 + * The hyperbolic tangent of <i>x</i> is defined to be
21.1085 + * (<i>e<sup>x</sup> - e<sup>-x</sup></i>)/(<i>e<sup>x</sup> + e<sup>-x</sup></i>),
21.1086 + * in other words, {@linkplain Math#sinh
21.1087 + * sinh(<i>x</i>)}/{@linkplain Math#cosh cosh(<i>x</i>)}. Note
21.1088 + * that the absolute value of the exact tanh is always less than
21.1089 + * 1.
21.1090 + *
21.1091 + * <p>Special cases:
21.1092 + * <ul>
21.1093 + *
21.1094 + * <li>If the argument is NaN, then the result is NaN.
21.1095 + *
21.1096 + * <li>If the argument is zero, then the result is a zero with the
21.1097 + * same sign as the argument.
21.1098 + *
21.1099 + * <li>If the argument is positive infinity, then the result is
21.1100 + * {@code +1.0}.
21.1101 + *
21.1102 + * <li>If the argument is negative infinity, then the result is
21.1103 + * {@code -1.0}.
21.1104 + *
21.1105 + * </ul>
21.1106 + *
21.1107 + * @param x The number whose hyperbolic tangent is to be returned.
21.1108 + * @return The hyperbolic tangent of {@code x}.
21.1109 + * @since 1.5
21.1110 + */
21.1111 + public static native double tanh(double x);
21.1112 +
21.1113 + /**
21.1114 + * Returns sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
21.1115 + * without intermediate overflow or underflow.
21.1116 + *
21.1117 + * <p>Special cases:
21.1118 + * <ul>
21.1119 + *
21.1120 + * <li> If either argument is infinite, then the result
21.1121 + * is positive infinity.
21.1122 + *
21.1123 + * <li> If either argument is NaN and neither argument is infinite,
21.1124 + * then the result is NaN.
21.1125 + *
21.1126 + * </ul>
21.1127 + *
21.1128 + * @param x a value
21.1129 + * @param y a value
21.1130 + * @return sqrt(<i>x</i><sup>2</sup> +<i>y</i><sup>2</sup>)
21.1131 + * without intermediate overflow or underflow
21.1132 + * @since 1.5
21.1133 + */
21.1134 + public static native double hypot(double x, double y);
21.1135 +
21.1136 + /**
21.1137 + * Returns <i>e</i><sup>x</sup> -1. Note that for values of
21.1138 + * <i>x</i> near 0, the exact sum of
21.1139 + * {@code expm1(x)} + 1 is much closer to the true
21.1140 + * result of <i>e</i><sup>x</sup> than {@code exp(x)}.
21.1141 + *
21.1142 + * <p>Special cases:
21.1143 + * <ul>
21.1144 + * <li>If the argument is NaN, the result is NaN.
21.1145 + *
21.1146 + * <li>If the argument is positive infinity, then the result is
21.1147 + * positive infinity.
21.1148 + *
21.1149 + * <li>If the argument is negative infinity, then the result is
21.1150 + * -1.0.
21.1151 + *
21.1152 + * <li>If the argument is zero, then the result is a zero with the
21.1153 + * same sign as the argument.
21.1154 + *
21.1155 + * </ul>
21.1156 + *
21.1157 + * @param x the exponent to raise <i>e</i> to in the computation of
21.1158 + * <i>e</i><sup>{@code x}</sup> -1.
21.1159 + * @return the value <i>e</i><sup>{@code x}</sup> - 1.
21.1160 + * @since 1.5
21.1161 + */
21.1162 + public static native double expm1(double x);
21.1163 +
21.1164 + /**
21.1165 + * Returns the natural logarithm of the sum of the argument and 1.
21.1166 + * Note that for small values {@code x}, the result of
21.1167 + * {@code log1p(x)} is much closer to the true result of ln(1
21.1168 + * + {@code x}) than the floating-point evaluation of
21.1169 + * {@code log(1.0+x)}.
21.1170 + *
21.1171 + * <p>Special cases:
21.1172 + * <ul>
21.1173 + *
21.1174 + * <li>If the argument is NaN or less than -1, then the result is
21.1175 + * NaN.
21.1176 + *
21.1177 + * <li>If the argument is positive infinity, then the result is
21.1178 + * positive infinity.
21.1179 + *
21.1180 + * <li>If the argument is negative one, then the result is
21.1181 + * negative infinity.
21.1182 + *
21.1183 + * <li>If the argument is zero, then the result is a zero with the
21.1184 + * same sign as the argument.
21.1185 + *
21.1186 + * </ul>
21.1187 + *
21.1188 + * @param x a value
21.1189 + * @return the value ln({@code x} + 1), the natural
21.1190 + * log of {@code x} + 1
21.1191 + * @since 1.5
21.1192 + */
21.1193 + public static native double log1p(double x);
21.1194 +
21.1195 + /**
21.1196 + * Returns the first floating-point argument with the sign of the
21.1197 + * second floating-point argument. For this method, a NaN
21.1198 + * {@code sign} argument is always treated as if it were
21.1199 + * positive.
21.1200 + *
21.1201 + * @param magnitude the parameter providing the magnitude of the result
21.1202 + * @param sign the parameter providing the sign of the result
21.1203 + * @return a value with the magnitude of {@code magnitude}
21.1204 + * and the sign of {@code sign}.
21.1205 + * @since 1.6
21.1206 + */
21.1207 + public static double copySign(double magnitude, double sign) {
21.1208 + return sun.misc.FpUtils.copySign(magnitude, sign);
21.1209 + }
21.1210 +
21.1211 + /**
21.1212 + * Returns the first floating-point argument with the sign of the
21.1213 + * second floating-point argument. For this method, a NaN
21.1214 + * {@code sign} argument is always treated as if it were
21.1215 + * positive.
21.1216 + *
21.1217 + * @param magnitude the parameter providing the magnitude of the result
21.1218 + * @param sign the parameter providing the sign of the result
21.1219 + * @return a value with the magnitude of {@code magnitude}
21.1220 + * and the sign of {@code sign}.
21.1221 + * @since 1.6
21.1222 + */
21.1223 + public static float copySign(float magnitude, float sign) {
21.1224 + return sun.misc.FpUtils.copySign(magnitude, sign);
21.1225 + }
21.1226 + /**
21.1227 + * Returns the unbiased exponent used in the representation of a
21.1228 + * {@code float}. Special cases:
21.1229 + *
21.1230 + * <ul>
21.1231 + * <li>If the argument is NaN or infinite, then the result is
21.1232 + * {@link Float#MAX_EXPONENT} + 1.
21.1233 + * <li>If the argument is zero or subnormal, then the result is
21.1234 + * {@link Float#MIN_EXPONENT} -1.
21.1235 + * </ul>
21.1236 + * @param f a {@code float} value
21.1237 + * @since 1.6
21.1238 + */
21.1239 + public static int getExponent(float f) {
21.1240 + return sun.misc.FpUtils.getExponent(f);
21.1241 + }
21.1242 +
21.1243 + /**
21.1244 + * Returns the unbiased exponent used in the representation of a
21.1245 + * {@code double}. Special cases:
21.1246 + *
21.1247 + * <ul>
21.1248 + * <li>If the argument is NaN or infinite, then the result is
21.1249 + * {@link Double#MAX_EXPONENT} + 1.
21.1250 + * <li>If the argument is zero or subnormal, then the result is
21.1251 + * {@link Double#MIN_EXPONENT} -1.
21.1252 + * </ul>
21.1253 + * @param d a {@code double} value
21.1254 + * @since 1.6
21.1255 + */
21.1256 + public static int getExponent(double d) {
21.1257 + return sun.misc.FpUtils.getExponent(d);
21.1258 + }
21.1259 +
21.1260 + /**
21.1261 + * Returns the floating-point number adjacent to the first
21.1262 + * argument in the direction of the second argument. If both
21.1263 + * arguments compare as equal the second argument is returned.
21.1264 + *
21.1265 + * <p>Special cases:
21.1266 + * <ul>
21.1267 + * <li> If either argument is a NaN, then NaN is returned.
21.1268 + *
21.1269 + * <li> If both arguments are signed zeros, {@code direction}
21.1270 + * is returned unchanged (as implied by the requirement of
21.1271 + * returning the second argument if the arguments compare as
21.1272 + * equal).
21.1273 + *
21.1274 + * <li> If {@code start} is
21.1275 + * ±{@link Double#MIN_VALUE} and {@code direction}
21.1276 + * has a value such that the result should have a smaller
21.1277 + * magnitude, then a zero with the same sign as {@code start}
21.1278 + * is returned.
21.1279 + *
21.1280 + * <li> If {@code start} is infinite and
21.1281 + * {@code direction} has a value such that the result should
21.1282 + * have a smaller magnitude, {@link Double#MAX_VALUE} with the
21.1283 + * same sign as {@code start} is returned.
21.1284 + *
21.1285 + * <li> If {@code start} is equal to ±
21.1286 + * {@link Double#MAX_VALUE} and {@code direction} has a
21.1287 + * value such that the result should have a larger magnitude, an
21.1288 + * infinity with same sign as {@code start} is returned.
21.1289 + * </ul>
21.1290 + *
21.1291 + * @param start starting floating-point value
21.1292 + * @param direction value indicating which of
21.1293 + * {@code start}'s neighbors or {@code start} should
21.1294 + * be returned
21.1295 + * @return The floating-point number adjacent to {@code start} in the
21.1296 + * direction of {@code direction}.
21.1297 + * @since 1.6
21.1298 + */
21.1299 + public static double nextAfter(double start, double direction) {
21.1300 + return sun.misc.FpUtils.nextAfter(start, direction);
21.1301 + }
21.1302 +
21.1303 + /**
21.1304 + * Returns the floating-point number adjacent to the first
21.1305 + * argument in the direction of the second argument. If both
21.1306 + * arguments compare as equal a value equivalent to the second argument
21.1307 + * is returned.
21.1308 + *
21.1309 + * <p>Special cases:
21.1310 + * <ul>
21.1311 + * <li> If either argument is a NaN, then NaN is returned.
21.1312 + *
21.1313 + * <li> If both arguments are signed zeros, a value equivalent
21.1314 + * to {@code direction} is returned.
21.1315 + *
21.1316 + * <li> If {@code start} is
21.1317 + * ±{@link Float#MIN_VALUE} and {@code direction}
21.1318 + * has a value such that the result should have a smaller
21.1319 + * magnitude, then a zero with the same sign as {@code start}
21.1320 + * is returned.
21.1321 + *
21.1322 + * <li> If {@code start} is infinite and
21.1323 + * {@code direction} has a value such that the result should
21.1324 + * have a smaller magnitude, {@link Float#MAX_VALUE} with the
21.1325 + * same sign as {@code start} is returned.
21.1326 + *
21.1327 + * <li> If {@code start} is equal to ±
21.1328 + * {@link Float#MAX_VALUE} and {@code direction} has a
21.1329 + * value such that the result should have a larger magnitude, an
21.1330 + * infinity with same sign as {@code start} is returned.
21.1331 + * </ul>
21.1332 + *
21.1333 + * @param start starting floating-point value
21.1334 + * @param direction value indicating which of
21.1335 + * {@code start}'s neighbors or {@code start} should
21.1336 + * be returned
21.1337 + * @return The floating-point number adjacent to {@code start} in the
21.1338 + * direction of {@code direction}.
21.1339 + * @since 1.6
21.1340 + */
21.1341 + public static float nextAfter(float start, double direction) {
21.1342 + return sun.misc.FpUtils.nextAfter(start, direction);
21.1343 + }
21.1344 +
21.1345 + /**
21.1346 + * Returns the floating-point value adjacent to {@code d} in
21.1347 + * the direction of positive infinity. This method is
21.1348 + * semantically equivalent to {@code nextAfter(d,
21.1349 + * Double.POSITIVE_INFINITY)}; however, a {@code nextUp}
21.1350 + * implementation may run faster than its equivalent
21.1351 + * {@code nextAfter} call.
21.1352 + *
21.1353 + * <p>Special Cases:
21.1354 + * <ul>
21.1355 + * <li> If the argument is NaN, the result is NaN.
21.1356 + *
21.1357 + * <li> If the argument is positive infinity, the result is
21.1358 + * positive infinity.
21.1359 + *
21.1360 + * <li> If the argument is zero, the result is
21.1361 + * {@link Double#MIN_VALUE}
21.1362 + *
21.1363 + * </ul>
21.1364 + *
21.1365 + * @param d starting floating-point value
21.1366 + * @return The adjacent floating-point value closer to positive
21.1367 + * infinity.
21.1368 + * @since 1.6
21.1369 + */
21.1370 + public static double nextUp(double d) {
21.1371 + return sun.misc.FpUtils.nextUp(d);
21.1372 + }
21.1373 +
21.1374 + /**
21.1375 + * Returns the floating-point value adjacent to {@code f} in
21.1376 + * the direction of positive infinity. This method is
21.1377 + * semantically equivalent to {@code nextAfter(f,
21.1378 + * Float.POSITIVE_INFINITY)}; however, a {@code nextUp}
21.1379 + * implementation may run faster than its equivalent
21.1380 + * {@code nextAfter} call.
21.1381 + *
21.1382 + * <p>Special Cases:
21.1383 + * <ul>
21.1384 + * <li> If the argument is NaN, the result is NaN.
21.1385 + *
21.1386 + * <li> If the argument is positive infinity, the result is
21.1387 + * positive infinity.
21.1388 + *
21.1389 + * <li> If the argument is zero, the result is
21.1390 + * {@link Float#MIN_VALUE}
21.1391 + *
21.1392 + * </ul>
21.1393 + *
21.1394 + * @param f starting floating-point value
21.1395 + * @return The adjacent floating-point value closer to positive
21.1396 + * infinity.
21.1397 + * @since 1.6
21.1398 + */
21.1399 + public static float nextUp(float f) {
21.1400 + return sun.misc.FpUtils.nextUp(f);
21.1401 + }
21.1402 +
21.1403 +
21.1404 + /**
21.1405 + * Return {@code d} ×
21.1406 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
21.1407 + * by a single correctly rounded floating-point multiply to a
21.1408 + * member of the double value set. See the Java
21.1409 + * Language Specification for a discussion of floating-point
21.1410 + * value sets. If the exponent of the result is between {@link
21.1411 + * Double#MIN_EXPONENT} and {@link Double#MAX_EXPONENT}, the
21.1412 + * answer is calculated exactly. If the exponent of the result
21.1413 + * would be larger than {@code Double.MAX_EXPONENT}, an
21.1414 + * infinity is returned. Note that if the result is subnormal,
21.1415 + * precision may be lost; that is, when {@code scalb(x, n)}
21.1416 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
21.1417 + * <i>x</i>. When the result is non-NaN, the result has the same
21.1418 + * sign as {@code d}.
21.1419 + *
21.1420 + * <p>Special cases:
21.1421 + * <ul>
21.1422 + * <li> If the first argument is NaN, NaN is returned.
21.1423 + * <li> If the first argument is infinite, then an infinity of the
21.1424 + * same sign is returned.
21.1425 + * <li> If the first argument is zero, then a zero of the same
21.1426 + * sign is returned.
21.1427 + * </ul>
21.1428 + *
21.1429 + * @param d number to be scaled by a power of two.
21.1430 + * @param scaleFactor power of 2 used to scale {@code d}
21.1431 + * @return {@code d} × 2<sup>{@code scaleFactor}</sup>
21.1432 + * @since 1.6
21.1433 + */
21.1434 + public static double scalb(double d, int scaleFactor) {
21.1435 + return sun.misc.FpUtils.scalb(d, scaleFactor);
21.1436 + }
21.1437 +
21.1438 + /**
21.1439 + * Return {@code f} ×
21.1440 + * 2<sup>{@code scaleFactor}</sup> rounded as if performed
21.1441 + * by a single correctly rounded floating-point multiply to a
21.1442 + * member of the float value set. See the Java
21.1443 + * Language Specification for a discussion of floating-point
21.1444 + * value sets. If the exponent of the result is between {@link
21.1445 + * Float#MIN_EXPONENT} and {@link Float#MAX_EXPONENT}, the
21.1446 + * answer is calculated exactly. If the exponent of the result
21.1447 + * would be larger than {@code Float.MAX_EXPONENT}, an
21.1448 + * infinity is returned. Note that if the result is subnormal,
21.1449 + * precision may be lost; that is, when {@code scalb(x, n)}
21.1450 + * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal
21.1451 + * <i>x</i>. When the result is non-NaN, the result has the same
21.1452 + * sign as {@code f}.
21.1453 + *
21.1454 + * <p>Special cases:
21.1455 + * <ul>
21.1456 + * <li> If the first argument is NaN, NaN is returned.
21.1457 + * <li> If the first argument is infinite, then an infinity of the
21.1458 + * same sign is returned.
21.1459 + * <li> If the first argument is zero, then a zero of the same
21.1460 + * sign is returned.
21.1461 + * </ul>
21.1462 + *
21.1463 + * @param f number to be scaled by a power of two.
21.1464 + * @param scaleFactor power of 2 used to scale {@code f}
21.1465 + * @return {@code f} × 2<sup>{@code scaleFactor}</sup>
21.1466 + * @since 1.6
21.1467 + */
21.1468 + public static float scalb(float f, int scaleFactor) {
21.1469 + return sun.misc.FpUtils.scalb(f, scaleFactor);
21.1470 + }
21.1471 +}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/emul/src/main/java/java/lang/StringIndexOutOfBoundsException.java Sun Sep 30 14:37:39 2012 -0700
22.3 @@ -0,0 +1,71 @@
22.4 +/*
22.5 + * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
22.7 + *
22.8 + * This code is free software; you can redistribute it and/or modify it
22.9 + * under the terms of the GNU General Public License version 2 only, as
22.10 + * published by the Free Software Foundation. Oracle designates this
22.11 + * particular file as subject to the "Classpath" exception as provided
22.12 + * by Oracle in the LICENSE file that accompanied this code.
22.13 + *
22.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
22.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22.17 + * version 2 for more details (a copy is included in the LICENSE file that
22.18 + * accompanied this code).
22.19 + *
22.20 + * You should have received a copy of the GNU General Public License version
22.21 + * 2 along with this work; if not, write to the Free Software Foundation,
22.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22.23 + *
22.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22.25 + * or visit www.oracle.com if you need additional information or have any
22.26 + * questions.
22.27 + */
22.28 +
22.29 +package java.lang;
22.30 +
22.31 +/**
22.32 + * Thrown by <code>String</code> methods to indicate that an index
22.33 + * is either negative or greater than the size of the string. For
22.34 + * some methods such as the charAt method, this exception also is
22.35 + * thrown when the index is equal to the size of the string.
22.36 + *
22.37 + * @author unascribed
22.38 + * @see java.lang.String#charAt(int)
22.39 + * @since JDK1.0
22.40 + */
22.41 +public
22.42 +class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
22.43 + private static final long serialVersionUID = -6762910422159637258L;
22.44 +
22.45 + /**
22.46 + * Constructs a <code>StringIndexOutOfBoundsException</code> with no
22.47 + * detail message.
22.48 + *
22.49 + * @since JDK1.0.
22.50 + */
22.51 + public StringIndexOutOfBoundsException() {
22.52 + super();
22.53 + }
22.54 +
22.55 + /**
22.56 + * Constructs a <code>StringIndexOutOfBoundsException</code> with
22.57 + * the specified detail message.
22.58 + *
22.59 + * @param s the detail message.
22.60 + */
22.61 + public StringIndexOutOfBoundsException(String s) {
22.62 + super(s);
22.63 + }
22.64 +
22.65 + /**
22.66 + * Constructs a new <code>StringIndexOutOfBoundsException</code>
22.67 + * class with an argument indicating the illegal index.
22.68 + *
22.69 + * @param index the illegal index.
22.70 + */
22.71 + public StringIndexOutOfBoundsException(int index) {
22.72 + super("String index out of range: " + index);
22.73 + }
22.74 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/emul/src/main/java/java/lang/annotation/Annotation.java Sun Sep 30 14:37:39 2012 -0700
23.3 @@ -0,0 +1,131 @@
23.4 +/*
23.5 + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
23.7 + *
23.8 + * This code is free software; you can redistribute it and/or modify it
23.9 + * under the terms of the GNU General Public License version 2 only, as
23.10 + * published by the Free Software Foundation. Oracle designates this
23.11 + * particular file as subject to the "Classpath" exception as provided
23.12 + * by Oracle in the LICENSE file that accompanied this code.
23.13 + *
23.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
23.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23.17 + * version 2 for more details (a copy is included in the LICENSE file that
23.18 + * accompanied this code).
23.19 + *
23.20 + * You should have received a copy of the GNU General Public License version
23.21 + * 2 along with this work; if not, write to the Free Software Foundation,
23.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23.23 + *
23.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23.25 + * or visit www.oracle.com if you need additional information or have any
23.26 + * questions.
23.27 + */
23.28 +
23.29 +package java.lang.annotation;
23.30 +
23.31 +/**
23.32 + * The common interface extended by all annotation types. Note that an
23.33 + * interface that manually extends this one does <i>not</i> define
23.34 + * an annotation type. Also note that this interface does not itself
23.35 + * define an annotation type.
23.36 + *
23.37 + * More information about annotation types can be found in section 9.6 of
23.38 + * <cite>The Java™ Language Specification</cite>.
23.39 + *
23.40 + * @author Josh Bloch
23.41 + * @since 1.5
23.42 + */
23.43 +public interface Annotation {
23.44 + /**
23.45 + * Returns true if the specified object represents an annotation
23.46 + * that is logically equivalent to this one. In other words,
23.47 + * returns true if the specified object is an instance of the same
23.48 + * annotation type as this instance, all of whose members are equal
23.49 + * to the corresponding member of this annotation, as defined below:
23.50 + * <ul>
23.51 + * <li>Two corresponding primitive typed members whose values are
23.52 + * <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>,
23.53 + * unless their type is <tt>float</tt> or <tt>double</tt>.
23.54 + *
23.55 + * <li>Two corresponding <tt>float</tt> members whose values
23.56 + * are <tt>x</tt> and <tt>y</tt> are considered equal if
23.57 + * <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>.
23.58 + * (Unlike the <tt>==</tt> operator, NaN is considered equal
23.59 + * to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.)
23.60 + *
23.61 + * <li>Two corresponding <tt>double</tt> members whose values
23.62 + * are <tt>x</tt> and <tt>y</tt> are considered equal if
23.63 + * <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>.
23.64 + * (Unlike the <tt>==</tt> operator, NaN is considered equal
23.65 + * to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.)
23.66 + *
23.67 + * <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or
23.68 + * annotation typed members whose values are <tt>x</tt> and <tt>y</tt>
23.69 + * are considered equal if <tt>x.equals(y)</tt>. (Note that this
23.70 + * definition is recursive for annotation typed members.)
23.71 + *
23.72 + * <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt>
23.73 + * are considered equal if <tt>Arrays.equals(x, y)</tt>, for the
23.74 + * appropriate overloading of {@link java.util.Arrays#equals}.
23.75 + * </ul>
23.76 + *
23.77 + * @return true if the specified object represents an annotation
23.78 + * that is logically equivalent to this one, otherwise false
23.79 + */
23.80 + boolean equals(Object obj);
23.81 +
23.82 + /**
23.83 + * Returns the hash code of this annotation, as defined below:
23.84 + *
23.85 + * <p>The hash code of an annotation is the sum of the hash codes
23.86 + * of its members (including those with default values), as defined
23.87 + * below:
23.88 + *
23.89 + * The hash code of an annotation member is (127 times the hash code
23.90 + * of the member-name as computed by {@link String#hashCode()}) XOR
23.91 + * the hash code of the member-value, as defined below:
23.92 + *
23.93 + * <p>The hash code of a member-value depends on its type:
23.94 + * <ul>
23.95 + * <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to
23.96 + * <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where
23.97 + * <tt><i>WrapperType</i></tt> is the wrapper type corresponding
23.98 + * to the primitive type of <tt><i>v</i></tt> ({@link Byte},
23.99 + * {@link Character}, {@link Double}, {@link Float}, {@link Integer},
23.100 + * {@link Long}, {@link Short}, or {@link Boolean}).
23.101 + *
23.102 + * <li>The hash code of a string, enum, class, or annotation member-value
23.103 + I <tt><i>v</i></tt> is computed as by calling
23.104 + * <tt><i>v</i>.hashCode()</tt>. (In the case of annotation
23.105 + * member values, this is a recursive definition.)
23.106 + *
23.107 + * <li>The hash code of an array member-value is computed by calling
23.108 + * the appropriate overloading of
23.109 + * {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode}
23.110 + * on the value. (There is one overloading for each primitive
23.111 + * type, and one for object reference types.)
23.112 + * </ul>
23.113 + *
23.114 + * @return the hash code of this annotation
23.115 + */
23.116 + int hashCode();
23.117 +
23.118 + /**
23.119 + * Returns a string representation of this annotation. The details
23.120 + * of the representation are implementation-dependent, but the following
23.121 + * may be regarded as typical:
23.122 + * <pre>
23.123 + * @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
23.124 + * </pre>
23.125 + *
23.126 + * @return a string representation of this annotation
23.127 + */
23.128 + String toString();
23.129 +
23.130 + /**
23.131 + * Returns the annotation type of this annotation.
23.132 + */
23.133 + Class<? extends Annotation> annotationType();
23.134 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/emul/src/main/java/java/lang/annotation/Documented.java Sun Sep 30 14:37:39 2012 -0700
24.3 @@ -0,0 +1,43 @@
24.4 +/*
24.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24.7 + *
24.8 + * This code is free software; you can redistribute it and/or modify it
24.9 + * under the terms of the GNU General Public License version 2 only, as
24.10 + * published by the Free Software Foundation. Oracle designates this
24.11 + * particular file as subject to the "Classpath" exception as provided
24.12 + * by Oracle in the LICENSE file that accompanied this code.
24.13 + *
24.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
24.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
24.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24.17 + * version 2 for more details (a copy is included in the LICENSE file that
24.18 + * accompanied this code).
24.19 + *
24.20 + * You should have received a copy of the GNU General Public License version
24.21 + * 2 along with this work; if not, write to the Free Software Foundation,
24.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24.23 + *
24.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24.25 + * or visit www.oracle.com if you need additional information or have any
24.26 + * questions.
24.27 + */
24.28 +
24.29 +package java.lang.annotation;
24.30 +
24.31 +/**
24.32 + * Indicates that annotations with a type are to be documented by javadoc
24.33 + * and similar tools by default. This type should be used to annotate the
24.34 + * declarations of types whose annotations affect the use of annotated
24.35 + * elements by their clients. If a type declaration is annotated with
24.36 + * Documented, its annotations become part of the public API
24.37 + * of the annotated elements.
24.38 + *
24.39 + * @author Joshua Bloch
24.40 + * @since 1.5
24.41 + */
24.42 +@Documented
24.43 +@Retention(RetentionPolicy.RUNTIME)
24.44 +@Target(ElementType.ANNOTATION_TYPE)
24.45 +public @interface Documented {
24.46 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/emul/src/main/java/java/lang/annotation/ElementType.java Sun Sep 30 14:37:39 2012 -0700
25.3 @@ -0,0 +1,63 @@
25.4 +/*
25.5 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
25.7 + *
25.8 + * This code is free software; you can redistribute it and/or modify it
25.9 + * under the terms of the GNU General Public License version 2 only, as
25.10 + * published by the Free Software Foundation. Oracle designates this
25.11 + * particular file as subject to the "Classpath" exception as provided
25.12 + * by Oracle in the LICENSE file that accompanied this code.
25.13 + *
25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25.17 + * version 2 for more details (a copy is included in the LICENSE file that
25.18 + * accompanied this code).
25.19 + *
25.20 + * You should have received a copy of the GNU General Public License version
25.21 + * 2 along with this work; if not, write to the Free Software Foundation,
25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25.23 + *
25.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25.25 + * or visit www.oracle.com if you need additional information or have any
25.26 + * questions.
25.27 + */
25.28 +
25.29 +package java.lang.annotation;
25.30 +
25.31 +/**
25.32 + * A program element type. The constants of this enumerated type
25.33 + * provide a simple classification of the declared elements in a
25.34 + * Java program.
25.35 + *
25.36 + * <p>These constants are used with the {@link Target} meta-annotation type
25.37 + * to specify where it is legal to use an annotation type.
25.38 + *
25.39 + * @author Joshua Bloch
25.40 + * @since 1.5
25.41 + */
25.42 +public enum ElementType {
25.43 + /** Class, interface (including annotation type), or enum declaration */
25.44 + TYPE,
25.45 +
25.46 + /** Field declaration (includes enum constants) */
25.47 + FIELD,
25.48 +
25.49 + /** Method declaration */
25.50 + METHOD,
25.51 +
25.52 + /** Parameter declaration */
25.53 + PARAMETER,
25.54 +
25.55 + /** Constructor declaration */
25.56 + CONSTRUCTOR,
25.57 +
25.58 + /** Local variable declaration */
25.59 + LOCAL_VARIABLE,
25.60 +
25.61 + /** Annotation type declaration */
25.62 + ANNOTATION_TYPE,
25.63 +
25.64 + /** Package declaration */
25.65 + PACKAGE
25.66 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/emul/src/main/java/java/lang/annotation/NullPointerException.java Sun Sep 30 14:37:39 2012 -0700
26.3 @@ -0,0 +1,72 @@
26.4 +/*
26.5 + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26.7 + *
26.8 + * This code is free software; you can redistribute it and/or modify it
26.9 + * under the terms of the GNU General Public License version 2 only, as
26.10 + * published by the Free Software Foundation. Oracle designates this
26.11 + * particular file as subject to the "Classpath" exception as provided
26.12 + * by Oracle in the LICENSE file that accompanied this code.
26.13 + *
26.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
26.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26.17 + * version 2 for more details (a copy is included in the LICENSE file that
26.18 + * accompanied this code).
26.19 + *
26.20 + * You should have received a copy of the GNU General Public License version
26.21 + * 2 along with this work; if not, write to the Free Software Foundation,
26.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26.23 + *
26.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
26.25 + * or visit www.oracle.com if you need additional information or have any
26.26 + * questions.
26.27 + */
26.28 +
26.29 +package java.lang;
26.30 +
26.31 +/**
26.32 + * Thrown when an application attempts to use {@code null} in a
26.33 + * case where an object is required. These include:
26.34 + * <ul>
26.35 + * <li>Calling the instance method of a {@code null} object.
26.36 + * <li>Accessing or modifying the field of a {@code null} object.
26.37 + * <li>Taking the length of {@code null} as if it were an array.
26.38 + * <li>Accessing or modifying the slots of {@code null} as if it
26.39 + * were an array.
26.40 + * <li>Throwing {@code null} as if it were a {@code Throwable}
26.41 + * value.
26.42 + * </ul>
26.43 + * <p>
26.44 + * Applications should throw instances of this class to indicate
26.45 + * other illegal uses of the {@code null} object.
26.46 + *
26.47 + * {@code NullPointerException} objects may be constructed by the
26.48 + * virtual machine as if {@linkplain Throwable#Throwable(String,
26.49 + * Throwable, boolean, boolean) suppression were disabled and/or the
26.50 + * stack trace was not writable}.
26.51 + *
26.52 + * @author unascribed
26.53 + * @since JDK1.0
26.54 + */
26.55 +public
26.56 +class NullPointerException extends RuntimeException {
26.57 + private static final long serialVersionUID = 5162710183389028792L;
26.58 +
26.59 + /**
26.60 + * Constructs a {@code NullPointerException} with no detail message.
26.61 + */
26.62 + public NullPointerException() {
26.63 + super();
26.64 + }
26.65 +
26.66 + /**
26.67 + * Constructs a {@code NullPointerException} with the specified
26.68 + * detail message.
26.69 + *
26.70 + * @param s the detail message.
26.71 + */
26.72 + public NullPointerException(String s) {
26.73 + super(s);
26.74 + }
26.75 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/emul/src/main/java/java/lang/annotation/Retention.java Sun Sep 30 14:37:39 2012 -0700
27.3 @@ -0,0 +1,47 @@
27.4 +/*
27.5 + * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
27.7 + *
27.8 + * This code is free software; you can redistribute it and/or modify it
27.9 + * under the terms of the GNU General Public License version 2 only, as
27.10 + * published by the Free Software Foundation. Oracle designates this
27.11 + * particular file as subject to the "Classpath" exception as provided
27.12 + * by Oracle in the LICENSE file that accompanied this code.
27.13 + *
27.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
27.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27.17 + * version 2 for more details (a copy is included in the LICENSE file that
27.18 + * accompanied this code).
27.19 + *
27.20 + * You should have received a copy of the GNU General Public License version
27.21 + * 2 along with this work; if not, write to the Free Software Foundation,
27.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27.23 + *
27.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
27.25 + * or visit www.oracle.com if you need additional information or have any
27.26 + * questions.
27.27 + */
27.28 +
27.29 +package java.lang.annotation;
27.30 +
27.31 +/**
27.32 + * Indicates how long annotations with the annotated type are to
27.33 + * be retained. If no Retention annotation is present on
27.34 + * an annotation type declaration, the retention policy defaults to
27.35 + * {@code RetentionPolicy.CLASS}.
27.36 + *
27.37 + * <p>A Retention meta-annotation has effect only if the
27.38 + * meta-annotated type is used directly for annotation. It has no
27.39 + * effect if the meta-annotated type is used as a member type in
27.40 + * another annotation type.
27.41 + *
27.42 + * @author Joshua Bloch
27.43 + * @since 1.5
27.44 + */
27.45 +@Documented
27.46 +@Retention(RetentionPolicy.RUNTIME)
27.47 +@Target(ElementType.ANNOTATION_TYPE)
27.48 +public @interface Retention {
27.49 + RetentionPolicy value();
27.50 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/emul/src/main/java/java/lang/annotation/RetentionPolicy.java Sun Sep 30 14:37:39 2012 -0700
28.3 @@ -0,0 +1,57 @@
28.4 +/*
28.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28.7 + *
28.8 + * This code is free software; you can redistribute it and/or modify it
28.9 + * under the terms of the GNU General Public License version 2 only, as
28.10 + * published by the Free Software Foundation. Oracle designates this
28.11 + * particular file as subject to the "Classpath" exception as provided
28.12 + * by Oracle in the LICENSE file that accompanied this code.
28.13 + *
28.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
28.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28.17 + * version 2 for more details (a copy is included in the LICENSE file that
28.18 + * accompanied this code).
28.19 + *
28.20 + * You should have received a copy of the GNU General Public License version
28.21 + * 2 along with this work; if not, write to the Free Software Foundation,
28.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28.23 + *
28.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28.25 + * or visit www.oracle.com if you need additional information or have any
28.26 + * questions.
28.27 + */
28.28 +
28.29 +package java.lang.annotation;
28.30 +
28.31 +/**
28.32 + * Annotation retention policy. The constants of this enumerated type
28.33 + * describe the various policies for retaining annotations. They are used
28.34 + * in conjunction with the {@link Retention} meta-annotation type to specify
28.35 + * how long annotations are to be retained.
28.36 + *
28.37 + * @author Joshua Bloch
28.38 + * @since 1.5
28.39 + */
28.40 +public enum RetentionPolicy {
28.41 + /**
28.42 + * Annotations are to be discarded by the compiler.
28.43 + */
28.44 + SOURCE,
28.45 +
28.46 + /**
28.47 + * Annotations are to be recorded in the class file by the compiler
28.48 + * but need not be retained by the VM at run time. This is the default
28.49 + * behavior.
28.50 + */
28.51 + CLASS,
28.52 +
28.53 + /**
28.54 + * Annotations are to be recorded in the class file by the compiler and
28.55 + * retained by the VM at run time, so they may be read reflectively.
28.56 + *
28.57 + * @see java.lang.reflect.AnnotatedElement
28.58 + */
28.59 + RUNTIME
28.60 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/emul/src/main/java/java/lang/annotation/Target.java Sun Sep 30 14:37:39 2012 -0700
29.3 @@ -0,0 +1,68 @@
29.4 +/*
29.5 + * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29.7 + *
29.8 + * This code is free software; you can redistribute it and/or modify it
29.9 + * under the terms of the GNU General Public License version 2 only, as
29.10 + * published by the Free Software Foundation. Oracle designates this
29.11 + * particular file as subject to the "Classpath" exception as provided
29.12 + * by Oracle in the LICENSE file that accompanied this code.
29.13 + *
29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29.17 + * version 2 for more details (a copy is included in the LICENSE file that
29.18 + * accompanied this code).
29.19 + *
29.20 + * You should have received a copy of the GNU General Public License version
29.21 + * 2 along with this work; if not, write to the Free Software Foundation,
29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29.23 + *
29.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29.25 + * or visit www.oracle.com if you need additional information or have any
29.26 + * questions.
29.27 + */
29.28 +
29.29 +package java.lang.annotation;
29.30 +
29.31 +/**
29.32 + * Indicates the kinds of program element to which an annotation type
29.33 + * is applicable. If a Target meta-annotation is not present on an
29.34 + * annotation type declaration, the declared type may be used on any
29.35 + * program element. If such a meta-annotation is present, the compiler
29.36 + * will enforce the specified usage restriction.
29.37 + *
29.38 + * For example, this meta-annotation indicates that the declared type is
29.39 + * itself a meta-annotation type. It can only be used on annotation type
29.40 + * declarations:
29.41 + * <pre>
29.42 + * @Target(ElementType.ANNOTATION_TYPE)
29.43 + * public @interface MetaAnnotationType {
29.44 + * ...
29.45 + * }
29.46 + * </pre>
29.47 + * This meta-annotation indicates that the declared type is intended solely
29.48 + * for use as a member type in complex annotation type declarations. It
29.49 + * cannot be used to annotate anything directly:
29.50 + * <pre>
29.51 + * @Target({})
29.52 + * public @interface MemberType {
29.53 + * ...
29.54 + * }
29.55 + * </pre>
29.56 + * It is a compile-time error for a single ElementType constant to
29.57 + * appear more than once in a Target annotation. For example, the
29.58 + * following meta-annotation is illegal:
29.59 + * <pre>
29.60 + * @Target({ElementType.FIELD, ElementType.METHOD, ElementType.FIELD})
29.61 + * public @interface Bogus {
29.62 + * ...
29.63 + * }
29.64 + * </pre>
29.65 + */
29.66 +@Documented
29.67 +@Retention(RetentionPolicy.RUNTIME)
29.68 +@Target(ElementType.ANNOTATION_TYPE)
29.69 +public @interface Target {
29.70 + ElementType[] value();
29.71 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/emul/src/main/java/java/lang/annotation/UnsupportedOperationException.java Sun Sep 30 14:37:39 2012 -0700
30.3 @@ -0,0 +1,94 @@
30.4 +/*
30.5 + * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30.7 + *
30.8 + * This code is free software; you can redistribute it and/or modify it
30.9 + * under the terms of the GNU General Public License version 2 only, as
30.10 + * published by the Free Software Foundation. Oracle designates this
30.11 + * particular file as subject to the "Classpath" exception as provided
30.12 + * by Oracle in the LICENSE file that accompanied this code.
30.13 + *
30.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
30.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30.17 + * version 2 for more details (a copy is included in the LICENSE file that
30.18 + * accompanied this code).
30.19 + *
30.20 + * You should have received a copy of the GNU General Public License version
30.21 + * 2 along with this work; if not, write to the Free Software Foundation,
30.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30.23 + *
30.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
30.25 + * or visit www.oracle.com if you need additional information or have any
30.26 + * questions.
30.27 + */
30.28 +
30.29 +package java.lang;
30.30 +
30.31 +/**
30.32 + * Thrown to indicate that the requested operation is not supported.<p>
30.33 + *
30.34 + * This class is a member of the
30.35 + * <a href="{@docRoot}/../technotes/guides/collections/index.html">
30.36 + * Java Collections Framework</a>.
30.37 + *
30.38 + * @author Josh Bloch
30.39 + * @since 1.2
30.40 + */
30.41 +public class UnsupportedOperationException extends RuntimeException {
30.42 + /**
30.43 + * Constructs an UnsupportedOperationException with no detail message.
30.44 + */
30.45 + public UnsupportedOperationException() {
30.46 + }
30.47 +
30.48 + /**
30.49 + * Constructs an UnsupportedOperationException with the specified
30.50 + * detail message.
30.51 + *
30.52 + * @param message the detail message
30.53 + */
30.54 + public UnsupportedOperationException(String message) {
30.55 + super(message);
30.56 + }
30.57 +
30.58 + /**
30.59 + * Constructs a new exception with the specified detail message and
30.60 + * cause.
30.61 + *
30.62 + * <p>Note that the detail message associated with <code>cause</code> is
30.63 + * <i>not</i> automatically incorporated in this exception's detail
30.64 + * message.
30.65 + *
30.66 + * @param message the detail message (which is saved for later retrieval
30.67 + * by the {@link Throwable#getMessage()} method).
30.68 + * @param cause the cause (which is saved for later retrieval by the
30.69 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value
30.70 + * is permitted, and indicates that the cause is nonexistent or
30.71 + * unknown.)
30.72 + * @since 1.5
30.73 + */
30.74 + public UnsupportedOperationException(String message, Throwable cause) {
30.75 + super(message, cause);
30.76 + }
30.77 +
30.78 + /**
30.79 + * Constructs a new exception with the specified cause and a detail
30.80 + * message of <tt>(cause==null ? null : cause.toString())</tt> (which
30.81 + * typically contains the class and detail message of <tt>cause</tt>).
30.82 + * This constructor is useful for exceptions that are little more than
30.83 + * wrappers for other throwables (for example, {@link
30.84 + * java.security.PrivilegedActionException}).
30.85 + *
30.86 + * @param cause the cause (which is saved for later retrieval by the
30.87 + * {@link Throwable#getCause()} method). (A <tt>null</tt> value is
30.88 + * permitted, and indicates that the cause is nonexistent or
30.89 + * unknown.)
30.90 + * @since 1.5
30.91 + */
30.92 + public UnsupportedOperationException(Throwable cause) {
30.93 + super(cause);
30.94 + }
30.95 +
30.96 + static final long serialVersionUID = -1242599979055084673L;
30.97 +}