home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- public final class Long extends Number {
- public static final long MIN_VALUE = -9223372036854775808L;
- public static final long MAX_VALUE = 9223372036854775807L;
- private long value;
-
- public static String toString(long i, int radix) {
- int digitCount = 0;
- boolean minval = false;
- boolean negative = false;
- if (i == MIN_VALUE) {
- switch (radix) {
- case 16:
- return "-8000000000000000";
- case 8:
- return "-1000000000000000000000";
- case 4:
- return "-20000000000000000000000000000000";
- case 2:
- return "-1000000000000000000000000000000000000000000000000000000000000000";
- default:
- negative = true;
- minval = true;
- i = MAX_VALUE;
- }
- } else if (i < 0L) {
- i = -i;
- negative = true;
- }
-
- StringBuffer buf;
- for(buf = new StringBuffer(45); i > 0L; ++digitCount) {
- if (i < (long)radix) {
- buf.append(Character.forDigit((int)i, radix));
- i = 0L;
- } else {
- int j = (int)(i % (long)radix);
- i /= (long)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 ii = 0; j-- > 0; tmp[j + k] = buf.charAt(ii++)) {
- }
-
- if (minval) {
- ++tmp[tmp.length - 1];
- }
-
- return String.valueOf(tmp);
- }
- }
-
- public static String toString(long i) {
- return toString(i, 10);
- }
-
- public static long parseLong(String s, int radix) throws NumberFormatException {
- if (s == null) {
- throw new NumberFormatException("null");
- } else {
- long result = 0L;
- 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 * (long)radix + (long)digit;
- }
-
- return negative ? -result : result;
- }
- }
- }
-
- public static long parseLong(String s) throws NumberFormatException {
- return parseLong(s, 10);
- }
-
- public static Long valueOf(String s, int radix) throws NumberFormatException {
- return new Long(parseLong(s, radix));
- }
-
- public static Long valueOf(String s) throws NumberFormatException {
- return new Long(parseLong(s, 10));
- }
-
- public Long(long value) {
- this.value = value;
- }
-
- public Long(String s) throws NumberFormatException {
- this.value = parseLong(s, 10);
- }
-
- public int intValue() {
- return (int)this.value;
- }
-
- public long longValue() {
- return 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 (int)this.value;
- }
-
- public boolean equals(Object obj) {
- if (obj != null && obj instanceof Long) {
- return this.value == (Long)obj;
- } else {
- return false;
- }
- }
-
- public static Long getLong(String nm) {
- return getLong(nm, (Long)null);
- }
-
- public static Long getLong(String nm, long val) {
- Long result = getLong(nm, (Long)null);
- return result == null ? new Long(val) : result;
- }
-
- public static Long getLong(String nm, Long 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;
- }
- }
-