+
+ private static final int provideBase(final String integer) {
+ if (integer == null) {
+ throw new IllegalArgumentException("String representing integer number cannot be NULL!");
+ }
+
+ if ((integer.length() == 1) && (integer.charAt(0) == '0')) {
+ return 10;
+ }
+
+ final Matcher intMatcher = intPattern.matcher(integer);
+ if (intMatcher.matches()) {
+ return 10;
+ } else {
+ final Matcher hexMatcher = hexPattern.matcher(integer);
+ if (hexMatcher.matches()) {
+ return 16;
+ } else {
+ final Matcher octMatcher = octalPattern.matcher(integer);
+ if (octMatcher.matches()) {
+ return 8;
+ } else {
+ throw new NumberFormatException("Incorrect lexical representation of Integer value!"
+ + "The Integer value can be defined as Integer Number, Hexadecimal Number or"
+ + "Octal Number. The sign vlues are allowed. "
+ + "Spaces between digits are NOT allowed!");
+ }
+ }
+ }
+ }
+
+ private static String normalizeHexadecimal(final String hexInt) {
+ if (hexInt == null) {
+ throw new IllegalArgumentException(
+ "String representing integer number in Hexadecimal format cannot be NULL!");
+ }
+ final String normalizedString;
+ if (hexInt.contains("x")) {
+ normalizedString = hexInt.replace("x", "");
+ } else if (hexInt.contains("X")) {
+ normalizedString = hexInt.replace("X", "");
+ } else {
+ normalizedString = hexInt;
+ }
+ return normalizedString;
+ }
+