Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package java.lang;
- import sun.misc.VM;
- public final class Integer extends Number implements Comparable<Integer>
- {
- public static final int MIN_VALUE = -2147483648;
- public static final int MAX_VALUE = 2147483647;
- public static final Class<Integer> TYPE;
- static final char[] digits;
- static final char[] DigitTens;
- static final char[] DigitOnes;
- static final int[] sizeTable;
- private final int value;
- public static final int SIZE = 32;
- private static final long serialVersionUID = 1360826667806852920L;
- public static String toString(int p0, int p1) {
- if (p1 < 2 || p1 > 36) {
- p1 = 10;
- }
- if (p1 == 10) {
- return toString(p0);
- }
- final char[] array = new char[33];
- final int num = (p0 >= 0) ? 0 : 1;
- int num2 = 32;
- if (num == 0) {
- p0 = -p0;
- }
- for (; p0 <= -p1; p0 = p0 / p1) {
- array[num2--] = Integer.digits[-(p0 % p1)];
- }
- array[num2] = Integer.digits[-p0];
- if (num != 0) {
- --num2;
- array[num2] = '-';
- }
- return new String(array, num2, 33 - num2);
- }
- public static String toHexString(int p0) {
- return toUnsignedString(p0, 4);
- }
- public static String toOctalString(int p0) {
- return toUnsignedString(p0, 3);
- }
- public static String toBinaryString(int p0) {
- return toUnsignedString(p0, 1);
- }
- private static String toUnsignedString(int p0, int p1) {
- final char[] array = new char[32];
- final int num = (1 << p1) - 1;
- int num2 = 0;
- do {
- --num2;
- array[num2] = Integer.digits[p0 & num];
- p0 = p0 >>> p1;
- }
- while (!(p0 == 0));
- return new String(array, num2, 32 - num2);
- }
- public static String toString(int p0) {
- if (p0 == -2147483648) {
- return "-2147483648";
- }
- final int num = (p0 >= 0) ? stringSize(p0) : (stringSize(-p0) + 1);
- final char[] array = new char[num];
- getChars(p0, num, array);
- return new String(0, num, array);
- }
- static void getChars(int p0, int p1, char[] p2) {
- int num = 0;
- if (p0 < 0) {
- num = 45;
- p0 = -p0;
- }
- int num2;
- int num3;
- int num4 = 0;
- for (; p0 >= 65536; p0 = num2, --num4, p2[num4] = Integer.DigitOnes[num3], --num4, p2[num4] = Integer.DigitTens[num3]) {
- num2 = p0 / 100;
- num3 = p0 - ((num2 << 6) + (num2 << 5) + (num2 << 2));
- }
- do {
- num2 = p0 * 52429 >>> 19;
- num3 = p0 - ((num2 << 3) + (num2 << 1));
- --num4;
- p2[num4] = Integer.digits[num3];
- p0 = num2;
- }
- while (!(p0 == 0));
- if (num != 0) {
- --num4;
- p2[num4] = num;
- }
- }
- static int stringSize(int p0) {
- int num = 0;
- while (p0 > Integer.sizeTable[num]) {
- ++num;
- }
- return num + 1;
- }
- public static int parseInt(String p0, int p1) throws NumberFormatException {
- if (p0 == null) {
- throw new NumberFormatException("null");
- }
- if (p1 < 2) {
- throw new NumberFormatException(new StringBuilder().append("radix ").append(p1).append(" less than Character.MIN_RADIX").toString());
- }
- if (p1 > 36) {
- throw new NumberFormatException(new StringBuilder().append("radix ").append(p1).append(" greater than Character.MAX_RADIX").toString());
- }
- int num = 0;
- int num2 = 0;
- int i = 0;
- final int length = p0.length();
- int num3 = -2147483647;
- if (length > 0) {
- final int char = p0.charAt(0);
- if (char < 48) {
- if (char == 45) {
- num2 = 1;
- num3 = -2147483648;
- }
- else {
- if (char != 43) {
- throw NumberFormatException.forInputString(p0);
- }
- }
- if (length == 1) {
- throw NumberFormatException.forInputString(p0);
- }
- ++i;
- }
- final int num4 = num3 / p1;
- while (i < length) {
- final int digit = Character.digit(p0.charAt(i++), p1);
- if (digit < 0) {
- throw NumberFormatException.forInputString(p0);
- }
- if (num < num4) {
- throw NumberFormatException.forInputString(p0);
- }
- num = num * p1;
- if (num < num3 + digit) {
- throw NumberFormatException.forInputString(p0);
- }
- num = num - digit;
- }
- return (num2 == 0) ? (-num) : num;
- }
- throw NumberFormatException.forInputString(p0);
- }
- public static int parseInt(String p0) throws NumberFormatException {
- return parseInt(p0, 10);
- }
- public static Integer valueOf(String p0, int p1) throws NumberFormatException {
- return valueOf(parseInt(p0, p1));
- }
- public static Integer valueOf(String p0) throws NumberFormatException {
- return valueOf(parseInt(p0, 10));
- }
- public static Integer valueOf(int p0) {
- if (!(Integer.$assertionsDisabled || IntegerCache.high >= 127)) {
- throw new AssertionError();
- }
- if (p0 >= -128 && p0 <= IntegerCache.high) {
- return IntegerCache.cache[p0 + 128];
- }
- return new Integer(p0);
- }
- public Integer(int p0) {
- super();
- this.value = p0;
- }
- public Integer(String p0) throws NumberFormatException {
- super();
- this.value = parseInt(p0, 10);
- }
- public byte byteValue() {
- return (byte)this.value;
- }
- public short shortValue() {
- return (short)this.value;
- }
- 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 toString(this.value);
- }
- public int hashCode() {
- return this.value;
- }
- public boolean equals(Object p0) {
- return p0 instanceof Integer && this.value == ((Integer)p0).intValue();
- }
- public static Integer getInteger(String p0) {
- return getInteger(p0, null);
- }
- public static Integer getInteger(String p0, int p1) {
- final Integer integer = getInteger(p0, null);
- return (integer != null) ? integer : valueOf(p1);
- }
- public static Integer getInteger(String p0, Integer p1) {
- String property = null;
- try {
- try {
- property = System.getProperty(p0);
- }
- catch (NullPointerException) {
- }
- }
- catch (IllegalArgumentException $3_10$_0A) {
- }
- if (property != null) {
- try {
- return decode(property);
- }
- catch (NumberFormatException $3_10$_0A) {
- }
- }
- return p1;
- }
- public static Integer decode(String p0) throws NumberFormatException {
- int num = 10;
- int num2 = 0;
- int num3 = 0;
- if (p0.length() == 0) {
- throw new NumberFormatException("Zero length string");
- }
- final int char = p0.charAt(0);
- if (char == 45) {
- num3 = 1;
- ++num2;
- }
- else {
- if (char == 43) {
- ++num2;
- }
- }
- if (p0.startsWith("0x", num2) || p0.startsWith("0X", num2)) {
- num2 += 2;
- num = 16;
- }
- else {
- if (p0.startsWith("#", num2)) {
- ++num2;
- num = 16;
- }
- else {
- if (p0.startsWith("0", num2) && p0.length() > 1 + num2) {
- ++num2;
- num = 8;
- }
- }
- }
- if (p0.startsWith("-", num2) || p0.startsWith("+", num2)) {
- throw new NumberFormatException("Sign character in wrong position");
- }
- Integer num4;
- try {
- num4 = valueOf(p0.substring(num2), num);
- num4 = ((num3 == 0) ? num4 : valueOf(-num4.intValue()));
- }
- catch (NumberFormatException $6_194$_C2) {
- num4 = valueOf((num3 == 0) ? p0.substring(num2) : new StringBuilder().append("-").append(p0.substring(num2)).toString(), num);
- }
- return num4;
- }
- public int compareTo(Integer p0) {
- return compare(this.value, p0.value);
- }
- public static int compare(int p0, int p1) {
- return (p0 >= p1) ? ((p0 != p1) ? 1 : 0) : -1;
- }
- public static int highestOneBit(int p0) {
- p0 = (p0 | p0 >> 1);
- p0 = (p0 | p0 >> 2);
- p0 = (p0 | p0 >> 4);
- p0 = (p0 | p0 >> 8);
- p0 = (p0 | p0 >> 16);
- return p0 - (p0 >>> 1);
- }
- public static int lowestOneBit(int p0) {
- return p0 & -p0;
- }
- public static int numberOfLeadingZeros(int p0) {
- if (p0 == 0) {
- return 32;
- }
- int num = 1;
- if (p0 >>> 16 == 0) {
- num += 16;
- p0 = p0 << 16;
- }
- if (p0 >>> 24 == 0) {
- num += 8;
- p0 = p0 << 8;
- }
- if (p0 >>> 28 == 0) {
- num += 4;
- p0 = p0 << 4;
- }
- if (p0 >>> 30 == 0) {
- num += 2;
- p0 = p0 << 2;
- }
- return num - (p0 >>> 31);
- }
- public static int numberOfTrailingZeros(int p0) {
- if (p0 == 0) {
- return 32;
- }
- int num = 31;
- int num2 = p0 << 16;
- if (num2 != 0) {
- num = num - 16;
- p0 = num2;
- }
- num2 = p0 << 8;
- if (num2 != 0) {
- num = num - 8;
- p0 = num2;
- }
- num2 = p0 << 4;
- if (num2 != 0) {
- num = num - 4;
- p0 = num2;
- }
- num2 = p0 << 2;
- if (num2 != 0) {
- num = num - 2;
- p0 = num2;
- }
- return num - (p0 << 1 >>> 31);
- }
- public static int bitCount(int p0) {
- p0 = p0 - (p0 >>> 1 & 1431655765);
- p0 = (p0 & 858993459) + (p0 >>> 2 & 858993459);
- p0 = (p0 + (p0 >>> 4) & 252645135);
- p0 = p0 + (p0 >>> 8);
- p0 = p0 + (p0 >>> 16);
- return p0 & 63;
- }
- public static int rotateLeft(int p0, int p1) {
- return p0 << p1 | p0 >>> -p1;
- }
- public static int rotateRight(int p0, int p1) {
- return p0 >>> p1 | p0 << -p1;
- }
- public static int reverse(int p0) {
- p0 = ((p0 & 1431655765) << 1 | (p0 >>> 1 & 1431655765));
- p0 = ((p0 & 858993459) << 2 | (p0 >>> 2 & 858993459));
- p0 = ((p0 & 252645135) << 4 | (p0 >>> 4 & 252645135));
- p0 = (p0 << 24 | (p0 & 65280) << 8 | (p0 >>> 8 & 65280) | p0 >>> 24);
- return p0;
- }
- public static int signum(int p0) {
- return p0 >> 31 | -p0 >>> 31;
- }
- public static int reverseBytes(int p0) {
- return p0 >>> 24 | (p0 >> 8 & 65280) | (p0 << 8 & 16711680) | p0 << 24;
- }
- static {
- final boolean b = Integer.$assertionsDisabled = !Integer.class.desiredAssertionStatus();
- Integer.TYPE = Class.getPrimitiveClass("int");
- Integer.digits = new char[] {
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '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'
- };
- Integer.DigitTens = new char[] {
- '0',
- '0',
- '0',
- '0',
- '0',
- '0',
- '0',
- '0',
- '0',
- '0',
- '1',
- '1',
- '1',
- '1',
- '1',
- '1',
- '1',
- '1',
- '1',
- '1',
- '2',
- '2',
- '2',
- '2',
- '2',
- '2',
- '2',
- '2',
- '2',
- '2',
- '3',
- '3',
- '3',
- '3',
- '3',
- '3',
- '3',
- '3',
- '3',
- '3',
- '4',
- '4',
- '4',
- '4',
- '4',
- '4',
- '4',
- '4',
- '4',
- '4',
- '5',
- '5',
- '5',
- '5',
- '5',
- '5',
- '5',
- '5',
- '5',
- '5',
- '6',
- '6',
- '6',
- '6',
- '6',
- '6',
- '6',
- '6',
- '6',
- '6',
- '7',
- '7',
- '7',
- '7',
- '7',
- '7',
- '7',
- '7',
- '7',
- '7',
- '8',
- '8',
- '8',
- '8',
- '8',
- '8',
- '8',
- '8',
- '8',
- '8',
- '9',
- '9',
- '9',
- '9',
- '9',
- '9',
- '9',
- '9',
- '9',
- '9'
- };
- Integer.DigitOnes = new char[] {
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9',
- '0',
- '1',
- '2',
- '3',
- '4',
- '5',
- '6',
- '7',
- '8',
- '9'
- };
- Integer.sizeTable = new int[] {
- 9,
- 99,
- 999,
- 9999,
- 99999,
- 999999,
- 9999999,
- 99999999,
- 999999999,
- 2147483647
- };
- }
- static class IntegerCache
- {
- static final int low = -128;
- static final int high;
- static final Integer[] cache;
- private IntegerCache() {
- super();
- }
- static {
- int min = 127;
- final String savedProperty = VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
- if (savedProperty != null) {
- min = Math.min(Math.max(Integer.parseInt(savedProperty), 127), 2147483519);
- }
- IntegerCache.high = min;
- IntegerCache.cache = new Integer[IntegerCache.high - -128 + 1];
- int num = -128;
- for (int i = 0; i < IntegerCache.cache.length; ++i) {
- IntegerCache.cache[i] = new Integer(num++);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement