Advertisement
Guest User

MyOutput

a guest
Apr 11th, 2013
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 17.37 KB | None | 0 0
  1. package java.lang;
  2.  
  3. import sun.misc.VM;
  4.  
  5. public final class Integer extends Number implements Comparable<Integer>
  6. {
  7.     public static final int MIN_VALUE = -2147483648;
  8.     public static final int MAX_VALUE = 2147483647;
  9.     public static final Class<Integer> TYPE;
  10.     static final char[] digits;
  11.     static final char[] DigitTens;
  12.     static final char[] DigitOnes;
  13.     static final int[] sizeTable;
  14.     private final int value;
  15.     public static final int SIZE = 32;
  16.     private static final long serialVersionUID = 1360826667806852920L;
  17.    
  18.     public static String toString(int p0, int p1) {
  19.         if (p1 < 2 || p1 > 36) {
  20.             p1 = 10;
  21.         }
  22.         if (p1 == 10) {
  23.             return toString(p0);
  24.         }
  25.         final char[] array = new char[33];
  26.         final int num = (p0 >= 0) ? 0 : 1;
  27.         int num2 = 32;
  28.         if (num == 0) {
  29.             p0 = -p0;
  30.         }
  31.         for (; p0 <= -p1; p0 = p0 / p1) {
  32.             array[num2--] = Integer.digits[-(p0 % p1)];
  33.         }
  34.         array[num2] = Integer.digits[-p0];
  35.         if (num != 0) {
  36.             --num2;
  37.             array[num2] = '-';
  38.         }
  39.         return new String(array, num2, 33 - num2);
  40.     }
  41.    
  42.     public static String toHexString(int p0) {
  43.         return toUnsignedString(p0, 4);
  44.     }
  45.    
  46.     public static String toOctalString(int p0) {
  47.         return toUnsignedString(p0, 3);
  48.     }
  49.    
  50.     public static String toBinaryString(int p0) {
  51.         return toUnsignedString(p0, 1);
  52.     }
  53.    
  54.     private static String toUnsignedString(int p0, int p1) {
  55.         final char[] array = new char[32];
  56.         final int num = (1 << p1) - 1;
  57.         int num2 = 0;
  58.         do {
  59.             --num2;
  60.             array[num2] = Integer.digits[p0 & num];
  61.             p0 = p0 >>> p1;
  62.         }
  63.         while (!(p0 == 0));
  64.         return new String(array, num2, 32 - num2);
  65.     }
  66.    
  67.     public static String toString(int p0) {
  68.         if (p0 == -2147483648) {
  69.             return "-2147483648";
  70.         }
  71.         final int num = (p0 >= 0) ? stringSize(p0) : (stringSize(-p0) + 1);
  72.         final char[] array = new char[num];
  73.         getChars(p0, num, array);
  74.         return new String(0, num, array);
  75.     }
  76.    
  77.     static void getChars(int p0, int p1, char[] p2) {
  78.         int num = 0;
  79.         if (p0 < 0) {
  80.             num = 45;
  81.             p0 = -p0;
  82.         }
  83.         int num2;
  84.         int num3;
  85.         int num4 = 0;
  86.         for (; p0 >= 65536; p0 = num2, --num4, p2[num4] = Integer.DigitOnes[num3], --num4, p2[num4] = Integer.DigitTens[num3]) {
  87.             num2 = p0 / 100;
  88.             num3 = p0 - ((num2 << 6) + (num2 << 5) + (num2 << 2));
  89.         }
  90.         do {
  91.             num2 = p0 * 52429 >>> 19;
  92.             num3 = p0 - ((num2 << 3) + (num2 << 1));
  93.             --num4;
  94.             p2[num4] = Integer.digits[num3];
  95.             p0 = num2;
  96.         }
  97.         while (!(p0 == 0));
  98.         if (num != 0) {
  99.             --num4;
  100.             p2[num4] = num;
  101.         }
  102.     }
  103.    
  104.     static int stringSize(int p0) {
  105.         int num = 0;
  106.         while (p0 > Integer.sizeTable[num]) {
  107.             ++num;
  108.         }
  109.         return num + 1;
  110.     }
  111.    
  112.     public static int parseInt(String p0, int p1) throws NumberFormatException {
  113.         if (p0 == null) {
  114.             throw new NumberFormatException("null");
  115.         }
  116.         if (p1 < 2) {
  117.             throw new NumberFormatException(new StringBuilder().append("radix ").append(p1).append(" less than Character.MIN_RADIX").toString());
  118.         }
  119.         if (p1 > 36) {
  120.             throw new NumberFormatException(new StringBuilder().append("radix ").append(p1).append(" greater than Character.MAX_RADIX").toString());
  121.         }
  122.         int num = 0;
  123.         int num2 = 0;
  124.         int i = 0;
  125.         final int length = p0.length();
  126.         int num3 = -2147483647;
  127.         if (length > 0) {
  128.             final int char = p0.charAt(0);
  129.             if (char < 48) {
  130.                 if (char == 45) {
  131.                     num2 = 1;
  132.                     num3 = -2147483648;
  133.                 }
  134.                 else {
  135.                     if (char != 43) {
  136.                         throw NumberFormatException.forInputString(p0);
  137.                     }
  138.                 }
  139.                 if (length == 1) {
  140.                     throw NumberFormatException.forInputString(p0);
  141.                 }
  142.                 ++i;
  143.             }
  144.             final int num4 = num3 / p1;
  145.             while (i < length) {
  146.                 final int digit = Character.digit(p0.charAt(i++), p1);
  147.                 if (digit < 0) {
  148.                     throw NumberFormatException.forInputString(p0);
  149.                 }
  150.                 if (num < num4) {
  151.                     throw NumberFormatException.forInputString(p0);
  152.                 }
  153.                 num = num * p1;
  154.                 if (num < num3 + digit) {
  155.                     throw NumberFormatException.forInputString(p0);
  156.                 }
  157.                 num = num - digit;
  158.             }
  159.             return (num2 == 0) ? (-num) : num;
  160.         }
  161.         throw NumberFormatException.forInputString(p0);
  162.     }
  163.    
  164.     public static int parseInt(String p0) throws NumberFormatException {
  165.         return parseInt(p0, 10);
  166.     }
  167.    
  168.     public static Integer valueOf(String p0, int p1) throws NumberFormatException {
  169.         return valueOf(parseInt(p0, p1));
  170.     }
  171.    
  172.     public static Integer valueOf(String p0) throws NumberFormatException {
  173.         return valueOf(parseInt(p0, 10));
  174.     }
  175.    
  176.     public static Integer valueOf(int p0) {
  177.         if (!(Integer.$assertionsDisabled || IntegerCache.high >= 127)) {
  178.             throw new AssertionError();
  179.         }
  180.         if (p0 >= -128 && p0 <= IntegerCache.high) {
  181.             return IntegerCache.cache[p0 + 128];
  182.         }
  183.         return new Integer(p0);
  184.     }
  185.    
  186.     public Integer(int p0) {
  187.         super();
  188.         this.value = p0;
  189.     }
  190.    
  191.     public Integer(String p0) throws NumberFormatException {
  192.         super();
  193.         this.value = parseInt(p0, 10);
  194.     }
  195.    
  196.     public byte byteValue() {
  197.         return (byte)this.value;
  198.     }
  199.    
  200.     public short shortValue() {
  201.         return (short)this.value;
  202.     }
  203.    
  204.     public int intValue() {
  205.         return this.value;
  206.     }
  207.    
  208.     public long longValue() {
  209.         return (long)this.value;
  210.     }
  211.    
  212.     public float floatValue() {
  213.         return (float)this.value;
  214.     }
  215.    
  216.     public double doubleValue() {
  217.         return (double)this.value;
  218.     }
  219.    
  220.     public String toString() {
  221.         return toString(this.value);
  222.     }
  223.    
  224.     public int hashCode() {
  225.         return this.value;
  226.     }
  227.    
  228.     public boolean equals(Object p0) {
  229.         return p0 instanceof Integer && this.value == ((Integer)p0).intValue();
  230.     }
  231.    
  232.     public static Integer getInteger(String p0) {
  233.         return getInteger(p0, null);
  234.     }
  235.    
  236.     public static Integer getInteger(String p0, int p1) {
  237.         final Integer integer = getInteger(p0, null);
  238.         return (integer != null) ? integer : valueOf(p1);
  239.     }
  240.    
  241.     public static Integer getInteger(String p0, Integer p1) {
  242.         String property = null;
  243.         try {
  244.             try {
  245.                 property = System.getProperty(p0);
  246.             }
  247.             catch (NullPointerException) {
  248.             }
  249.         }
  250.         catch (IllegalArgumentException $3_10$_0A) {
  251.         }
  252.         if (property != null) {
  253.             try {
  254.                 return decode(property);
  255.             }
  256.             catch (NumberFormatException $3_10$_0A) {
  257.             }
  258.         }
  259.         return p1;
  260.     }
  261.    
  262.     public static Integer decode(String p0) throws NumberFormatException {
  263.         int num = 10;
  264.         int num2 = 0;
  265.         int num3 = 0;
  266.         if (p0.length() == 0) {
  267.             throw new NumberFormatException("Zero length string");
  268.         }
  269.         final int char = p0.charAt(0);
  270.         if (char == 45) {
  271.             num3 = 1;
  272.             ++num2;
  273.         }
  274.         else {
  275.             if (char == 43) {
  276.                 ++num2;
  277.             }
  278.         }
  279.         if (p0.startsWith("0x", num2) || p0.startsWith("0X", num2)) {
  280.             num2 += 2;
  281.             num = 16;
  282.         }
  283.         else {
  284.             if (p0.startsWith("#", num2)) {
  285.                 ++num2;
  286.                 num = 16;
  287.             }
  288.             else {
  289.                 if (p0.startsWith("0", num2) && p0.length() > 1 + num2) {
  290.                     ++num2;
  291.                     num = 8;
  292.                 }
  293.             }
  294.         }
  295.         if (p0.startsWith("-", num2) || p0.startsWith("+", num2)) {
  296.             throw new NumberFormatException("Sign character in wrong position");
  297.         }
  298.         Integer num4;
  299.         try {
  300.             num4 = valueOf(p0.substring(num2), num);
  301.             num4 = ((num3 == 0) ? num4 : valueOf(-num4.intValue()));
  302.         }
  303.         catch (NumberFormatException $6_194$_C2) {
  304.             num4 = valueOf((num3 == 0) ? p0.substring(num2) : new StringBuilder().append("-").append(p0.substring(num2)).toString(), num);
  305.         }
  306.         return num4;
  307.     }
  308.    
  309.     public int compareTo(Integer p0) {
  310.         return compare(this.value, p0.value);
  311.     }
  312.    
  313.     public static int compare(int p0, int p1) {
  314.         return (p0 >= p1) ? ((p0 != p1) ? 1 : 0) : -1;
  315.     }
  316.    
  317.     public static int highestOneBit(int p0) {
  318.         p0 = (p0 | p0 >> 1);
  319.         p0 = (p0 | p0 >> 2);
  320.         p0 = (p0 | p0 >> 4);
  321.         p0 = (p0 | p0 >> 8);
  322.         p0 = (p0 | p0 >> 16);
  323.         return p0 - (p0 >>> 1);
  324.     }
  325.    
  326.     public static int lowestOneBit(int p0) {
  327.         return p0 & -p0;
  328.     }
  329.    
  330.     public static int numberOfLeadingZeros(int p0) {
  331.         if (p0 == 0) {
  332.             return 32;
  333.         }
  334.         int num = 1;
  335.         if (p0 >>> 16 == 0) {
  336.             num += 16;
  337.             p0 = p0 << 16;
  338.         }
  339.         if (p0 >>> 24 == 0) {
  340.             num += 8;
  341.             p0 = p0 << 8;
  342.         }
  343.         if (p0 >>> 28 == 0) {
  344.             num += 4;
  345.             p0 = p0 << 4;
  346.         }
  347.         if (p0 >>> 30 == 0) {
  348.             num += 2;
  349.             p0 = p0 << 2;
  350.         }
  351.         return num - (p0 >>> 31);
  352.     }
  353.    
  354.     public static int numberOfTrailingZeros(int p0) {
  355.         if (p0 == 0) {
  356.             return 32;
  357.         }
  358.         int num = 31;
  359.         int num2 = p0 << 16;
  360.         if (num2 != 0) {
  361.             num = num - 16;
  362.             p0 = num2;
  363.         }
  364.         num2 = p0 << 8;
  365.         if (num2 != 0) {
  366.             num = num - 8;
  367.             p0 = num2;
  368.         }
  369.         num2 = p0 << 4;
  370.         if (num2 != 0) {
  371.             num = num - 4;
  372.             p0 = num2;
  373.         }
  374.         num2 = p0 << 2;
  375.         if (num2 != 0) {
  376.             num = num - 2;
  377.             p0 = num2;
  378.         }
  379.         return num - (p0 << 1 >>> 31);
  380.     }
  381.    
  382.     public static int bitCount(int p0) {
  383.         p0 = p0 - (p0 >>> 1 & 1431655765);
  384.         p0 = (p0 & 858993459) + (p0 >>> 2 & 858993459);
  385.         p0 = (p0 + (p0 >>> 4) & 252645135);
  386.         p0 = p0 + (p0 >>> 8);
  387.         p0 = p0 + (p0 >>> 16);
  388.         return p0 & 63;
  389.     }
  390.    
  391.     public static int rotateLeft(int p0, int p1) {
  392.         return p0 << p1 | p0 >>> -p1;
  393.     }
  394.    
  395.     public static int rotateRight(int p0, int p1) {
  396.         return p0 >>> p1 | p0 << -p1;
  397.     }
  398.    
  399.     public static int reverse(int p0) {
  400.         p0 = ((p0 & 1431655765) << 1 | (p0 >>> 1 & 1431655765));
  401.         p0 = ((p0 & 858993459) << 2 | (p0 >>> 2 & 858993459));
  402.         p0 = ((p0 & 252645135) << 4 | (p0 >>> 4 & 252645135));
  403.         p0 = (p0 << 24 | (p0 & 65280) << 8 | (p0 >>> 8 & 65280) | p0 >>> 24);
  404.         return p0;
  405.     }
  406.    
  407.     public static int signum(int p0) {
  408.         return p0 >> 31 | -p0 >>> 31;
  409.     }
  410.    
  411.     public static int reverseBytes(int p0) {
  412.         return p0 >>> 24 | (p0 >> 8 & 65280) | (p0 << 8 & 16711680) | p0 << 24;
  413.     }
  414.    
  415.     static {
  416.         final boolean b = Integer.$assertionsDisabled = !Integer.class.desiredAssertionStatus();
  417.         Integer.TYPE = Class.getPrimitiveClass("int");
  418.         Integer.digits = new char[] {
  419.             '0',
  420.             '1',
  421.             '2',
  422.             '3',
  423.             '4',
  424.             '5',
  425.             '6',
  426.             '7',
  427.             '8',
  428.             '9',
  429.             'a',
  430.             'b',
  431.             'c',
  432.             'd',
  433.             'e',
  434.             'f',
  435.             'g',
  436.             'h',
  437.             'i',
  438.             'j',
  439.             'k',
  440.             'l',
  441.             'm',
  442.             'n',
  443.             'o',
  444.             'p',
  445.             'q',
  446.             'r',
  447.             's',
  448.             't',
  449.             'u',
  450.             'v',
  451.             'w',
  452.             'x',
  453.             'y',
  454.             'z'
  455.         };
  456.         Integer.DigitTens = new char[] {
  457.             '0',
  458.             '0',
  459.             '0',
  460.             '0',
  461.             '0',
  462.             '0',
  463.             '0',
  464.             '0',
  465.             '0',
  466.             '0',
  467.             '1',
  468.             '1',
  469.             '1',
  470.             '1',
  471.             '1',
  472.             '1',
  473.             '1',
  474.             '1',
  475.             '1',
  476.             '1',
  477.             '2',
  478.             '2',
  479.             '2',
  480.             '2',
  481.             '2',
  482.             '2',
  483.             '2',
  484.             '2',
  485.             '2',
  486.             '2',
  487.             '3',
  488.             '3',
  489.             '3',
  490.             '3',
  491.             '3',
  492.             '3',
  493.             '3',
  494.             '3',
  495.             '3',
  496.             '3',
  497.             '4',
  498.             '4',
  499.             '4',
  500.             '4',
  501.             '4',
  502.             '4',
  503.             '4',
  504.             '4',
  505.             '4',
  506.             '4',
  507.             '5',
  508.             '5',
  509.             '5',
  510.             '5',
  511.             '5',
  512.             '5',
  513.             '5',
  514.             '5',
  515.             '5',
  516.             '5',
  517.             '6',
  518.             '6',
  519.             '6',
  520.             '6',
  521.             '6',
  522.             '6',
  523.             '6',
  524.             '6',
  525.             '6',
  526.             '6',
  527.             '7',
  528.             '7',
  529.             '7',
  530.             '7',
  531.             '7',
  532.             '7',
  533.             '7',
  534.             '7',
  535.             '7',
  536.             '7',
  537.             '8',
  538.             '8',
  539.             '8',
  540.             '8',
  541.             '8',
  542.             '8',
  543.             '8',
  544.             '8',
  545.             '8',
  546.             '8',
  547.             '9',
  548.             '9',
  549.             '9',
  550.             '9',
  551.             '9',
  552.             '9',
  553.             '9',
  554.             '9',
  555.             '9',
  556.             '9'
  557.         };
  558.         Integer.DigitOnes = new char[] {
  559.             '0',
  560.             '1',
  561.             '2',
  562.             '3',
  563.             '4',
  564.             '5',
  565.             '6',
  566.             '7',
  567.             '8',
  568.             '9',
  569.             '0',
  570.             '1',
  571.             '2',
  572.             '3',
  573.             '4',
  574.             '5',
  575.             '6',
  576.             '7',
  577.             '8',
  578.             '9',
  579.             '0',
  580.             '1',
  581.             '2',
  582.             '3',
  583.             '4',
  584.             '5',
  585.             '6',
  586.             '7',
  587.             '8',
  588.             '9',
  589.             '0',
  590.             '1',
  591.             '2',
  592.             '3',
  593.             '4',
  594.             '5',
  595.             '6',
  596.             '7',
  597.             '8',
  598.             '9',
  599.             '0',
  600.             '1',
  601.             '2',
  602.             '3',
  603.             '4',
  604.             '5',
  605.             '6',
  606.             '7',
  607.             '8',
  608.             '9',
  609.             '0',
  610.             '1',
  611.             '2',
  612.             '3',
  613.             '4',
  614.             '5',
  615.             '6',
  616.             '7',
  617.             '8',
  618.             '9',
  619.             '0',
  620.             '1',
  621.             '2',
  622.             '3',
  623.             '4',
  624.             '5',
  625.             '6',
  626.             '7',
  627.             '8',
  628.             '9',
  629.             '0',
  630.             '1',
  631.             '2',
  632.             '3',
  633.             '4',
  634.             '5',
  635.             '6',
  636.             '7',
  637.             '8',
  638.             '9',
  639.             '0',
  640.             '1',
  641.             '2',
  642.             '3',
  643.             '4',
  644.             '5',
  645.             '6',
  646.             '7',
  647.             '8',
  648.             '9',
  649.             '0',
  650.             '1',
  651.             '2',
  652.             '3',
  653.             '4',
  654.             '5',
  655.             '6',
  656.             '7',
  657.             '8',
  658.             '9'
  659.         };
  660.         Integer.sizeTable = new int[] {
  661.             9,
  662.             99,
  663.             999,
  664.             9999,
  665.             99999,
  666.             999999,
  667.             9999999,
  668.             99999999,
  669.             999999999,
  670.             2147483647
  671.         };
  672.     }
  673.    
  674.     static class IntegerCache
  675.     {
  676.         static final int low = -128;
  677.         static final int high;
  678.         static final Integer[] cache;
  679.        
  680.         private IntegerCache() {
  681.             super();
  682.         }
  683.        
  684.         static {
  685.             int min = 127;
  686.             final String savedProperty = VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
  687.             if (savedProperty != null) {
  688.                 min = Math.min(Math.max(Integer.parseInt(savedProperty), 127), 2147483519);
  689.             }
  690.             IntegerCache.high = min;
  691.             IntegerCache.cache = new Integer[IntegerCache.high - -128 + 1];
  692.             int num = -128;
  693.             for (int i = 0; i < IntegerCache.cache.length; ++i) {
  694.                 IntegerCache.cache[i] = new Integer(num++);
  695.             }
  696.         }
  697.     }
  698. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement