MCPcopy Create free account
hub / github.com/M66B/FairEmail / parseInt

Method parseInt

app/src/main/java/com/sun/mail/util/ASCIIUtility.java:43–101  ·  view source on GitHub ↗

Convert the bytes within the specified range of the given byte array into a signed integer in the given radix . The range extends from start till, but not including end . Based on java.lang.Integer.parseInt() @param b the bytes @param start the first byte offset @param

(byte[] b, int start, int end, int radix)

Source from the content-addressed store, hash-verified

41 * @exception NumberFormatException for conversion errors
42 */
43 public static int parseInt(byte[] b, int start, int end, int radix)
44 throws NumberFormatException {
45 if (b == null)
46 throw new NumberFormatException("null");
47
48 int result = 0;
49 boolean negative = false;
50 int i = start;
51 int limit;
52 int multmin;
53 int digit;
54
55 if (end > start) {
56 if (b[i] == '-') {
57 negative = true;
58 limit = Integer.MIN_VALUE;
59 i++;
60 } else {
61 limit = -Integer.MAX_VALUE;
62 }
63 multmin = limit / radix;
64 if (i < end) {
65 digit = Character.digit((char)b[i++], radix);
66 if (digit < 0) {
67 throw new NumberFormatException(
68 "illegal number: " + toString(b, start, end)
69 );
70 } else {
71 result = -digit;
72 }
73 }
74 while (i < end) {
75 // Accumulating negatively avoids surprises near MAX_VALUE
76 digit = Character.digit((char)b[i++], radix);
77 if (digit < 0) {
78 throw new NumberFormatException("illegal number");
79 }
80 if (result < multmin) {
81 throw new NumberFormatException("illegal number");
82 }
83 result *= radix;
84 if (result < limit + digit) {
85 throw new NumberFormatException("illegal number");
86 }
87 result -= digit;
88 }
89 } else {
90 throw new NumberFormatException("illegal number");
91 }
92 if (negative) {
93 if (i > start + 1) {
94 return result;
95 } else { /* Only got "-" */
96 throw new NumberFormatException("illegal number");
97 }
98 } else {
99 return -result;
100 }

Callers 15

readMethod · 0.95
readResponseMethod · 0.95
readNumberMethod · 0.95
parseStringMethod · 0.95
readMethod · 0.95
readMethod · 0.95
initMethod · 0.45
readServerResponseMethod · 0.45
getIntMethod · 0.45
readPrefixMethod · 0.45
createSocketMethod · 0.45
initCapacityMethod · 0.45

Calls 1

toStringMethod · 0.95

Tested by

no test coverage detected