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) {
- if (radix < 2 || radix > 36) {
- radix = 10;
- }
-
- StringBuffer buf = new StringBuffer(radix >= 8 ? 23 : 65);
- boolean negative = i < 0L;
- if (!negative) {
- i = -i;
- }
-
- while(i <= (long)(-radix)) {
- buf.append(Character.forDigit((int)(-(i % (long)radix)), radix));
- i /= (long)radix;
- }
-
- buf.append(Character.forDigit((int)(-i), radix));
- if (negative) {
- buf.append('-');
- }
-
- return buf.reverse().toString();
- }
-
- public static String toHexString(long i) {
- return toUnsignedString(i, 4);
- }
-
- public static String toOctalString(long i) {
- return toUnsignedString(i, 3);
- }
-
- public static String toBinaryString(long i) {
- return toUnsignedString(i, 1);
- }
-
- private static String toUnsignedString(long i, int shift) {
- StringBuffer buf = new StringBuffer(shift >= 3 ? 22 : 64);
- int radix = 1 << shift;
- long mask = (long)(radix - 1);
-
- do {
- buf.append(Character.forDigit((int)(i & mask), radix));
- i >>>= shift;
- } while(i != 0L);
-
- return buf.reverse().toString();
- }
-
- 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 ^ this.value >> 32);
- }
-
- 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) {
- SecurityManager.setScopePermission();
- String v = System.getProperty(nm);
- SecurityManager.resetScopePermission();
- 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") && v.length() > 1) {
- return valueOf(v.substring(1), 8);
- }
-
- return valueOf(v);
- } catch (NumberFormatException var3) {
- }
- }
-
- return val;
- }
- }
-