(String s)
| 131 | } |
| 132 | |
| 133 | int parseInt(String s) throws NumberFormatException { |
| 134 | int radix; |
| 135 | int i; |
| 136 | if( s.startsWith("0x") || s.startsWith("0X") ) { |
| 137 | radix = 16; |
| 138 | i = 2; |
| 139 | } else if( s.startsWith("0") && s.length() > 1 ) { |
| 140 | radix = 8; |
| 141 | i = 1; |
| 142 | } else { |
| 143 | radix = 10; |
| 144 | i = 0; |
| 145 | } |
| 146 | int result = 0; |
| 147 | int len = s.length(); |
| 148 | for( ; i<len; i++ ) { |
| 149 | if( result < 0 ) |
| 150 | throw new NumberFormatException("Number too big for integer type: "+s); |
| 151 | result *= radix; |
| 152 | int digit = Character.digit(s.charAt(i),radix); |
| 153 | if( digit < 0 ) |
| 154 | throw new NumberFormatException("Invalid integer type: "+s); |
| 155 | result += digit; |
| 156 | } |
| 157 | return result; |
| 158 | } |
| 159 | |
| 160 | long parseLong(String s) throws NumberFormatException { |
| 161 | int radix; |
no outgoing calls
no test coverage detected