| 124 | } |
| 125 | |
| 126 | public static Integer decode(String string) { |
| 127 | if (string.startsWith("-")) { |
| 128 | if (string.startsWith("-0") || string.startsWith("-#")) { |
| 129 | return new Integer(-decode(string.substring(1))); |
| 130 | } |
| 131 | } else if (string.startsWith("0")) { |
| 132 | char c = string.length() < 2 ? (char)-1 : string.charAt(1); |
| 133 | if (c == 'x' || c == 'X') { |
| 134 | return new Integer(parseInt(string.substring(2), 0x10)); |
| 135 | } |
| 136 | return new Integer(parseInt(string, 010)); |
| 137 | } else if (string.startsWith("#")) { |
| 138 | return new Integer(parseInt(string.substring(1), 0x10)); |
| 139 | } |
| 140 | return new Integer(parseInt(string, 10)); |
| 141 | } |
| 142 | } |