home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- public final class Integer extends Number {
- public static final int MIN_VALUE = -2147483648;
- public static final int MAX_VALUE = 2147483647;
- private int value;
-
- public static String toString(int i, int radix) {
- int digitCount = 0;
- boolean minval = false;
- boolean negative = false;
- if (i == MIN_VALUE) {
- switch (radix) {
- case 16:
- return "-80000000";
- case 8:
- return "-20000000000";
- case 4:
- return "-2000000000000000";
- case 2:
- return "-10000000000000000000000000000000";
- default:
- negative = true;
- minval = true;
- i = MAX_VALUE;
- }
- } else if (i < 0) {
- i = -i;
- negative = true;
- }
-
- StringBuffer buf;
- for(buf = new StringBuffer(32); i > 0; ++digitCount) {
- if (i < radix) {
- buf.append(Character.forDigit(i, radix));
- i = 0;
- } else {
- int j = i % radix;
- i /= radix;
- buf.append(Character.forDigit(j, radix));
- }
- }
-
- if (digitCount <= 0) {
- return "0";
- } else {
- int j = buf.length();
- int k = 0;
- char[] tmp;
- if (negative) {
- tmp = new char[j + 1];
- tmp[0] = '-';
- k = 1;
- } else {
- tmp = new char[j];
- }
-
- for(int var9 = 0; j-- > 0; tmp[j + k] = buf.charAt(var9++)) {
- }
-
- if (minval) {
- ++tmp[tmp.length - 1];
- }
-
- return String.valueOf(tmp);
- }
- }
-
- public static String toString(int i) {
- return toString(i, 10);
- }
-
- public static int parseInt(String s, int radix) throws NumberFormatException {
- if (s == null) {
- throw new NumberFormatException("null");
- } else {
- int result = 0;
- boolean negative = false;
- int i = 0;
- int max = s.length();
- if (max <= 0) {
- throw new NumberFormatException(s);
- } else {
- if (s.charAt(0) == '-') {
- negative = true;
- ++i;
- }
-
- while(i < max) {
- int digit = Character.digit(s.charAt(i++), radix);
- if (digit < 0) {
- throw new NumberFormatException(s);
- }
-
- result = result * radix + digit;
- }
-
- return negative ? -result : result;
- }
- }
- }
-
- public static int parseInt(String s) throws NumberFormatException {
- return parseInt(s, 10);
- }
-
- public static Integer valueOf(String s, int radix) throws NumberFormatException {
- return new Integer(parseInt(s, radix));
- }
-
- public static Integer valueOf(String s) throws NumberFormatException {
- return new Integer(parseInt(s, 10));
- }
-
- public Integer(int value) {
- this.value = value;
- }
-
- public Integer(String s) throws NumberFormatException {
- this.value = parseInt(s, 10);
- }
-
- public int intValue() {
- return this.value;
- }
-
- public long longValue() {
- return (long)this.value;
- }
-
- public float floatValue() {
- return (float)this.value;
- }
-
- public double doubleValue() {
- return (double)this.value;
- }
-
- public String toString() {
- return String.valueOf(this.value);
- }
-
- public int hashCode() {
- return this.value;
- }
-
- public boolean equals(Object obj) {
- if (obj != null && obj instanceof Integer) {
- return this.value == (Integer)obj;
- } else {
- return false;
- }
- }
-
- public static Integer getInteger(String nm) {
- return getInteger(nm, (Integer)null);
- }
-
- public static Integer getInteger(String nm, int val) {
- Integer result = getInteger(nm, (Integer)null);
- return result == null ? new Integer(val) : result;
- }
-
- public static Integer getInteger(String nm, Integer val) {
- String v = System.getProperty(nm);
- if (v != null) {
- try {
- if (v.startsWith("0x")) {
- return valueOf(v.substring(2), 16);
- }
-
- if (v.startsWith("#")) {
- return valueOf(v.substring(1), 16);
- }
-
- if (v.startsWith("0")) {
- return valueOf(v.substring(1), 8);
- }
-
- return valueOf(v);
- } catch (NumberFormatException var3) {
- }
- }
-
- return val;
- }
- }
-