boolean (@NotNull String s) { char charZero = s.charAt(0); int startIndex = (charZero == '-' || charZero == '+') ? 1 : 0; char baseSign = ' '; boolean expectBase = false; for (int i = startIndex; i < s.length(); ++i) { if (i == startIndex && s.charAt(i) == '0') { if (startIndex != 0) return false; expectBase = true; continue; } if (i == startIndex + 1 && expectBase) { char c = s.charAt(i); if (c != 'o' && c != 'x') return false; baseSign = c; } if (baseSign == ' ' && !Character.isDigit(s.charAt(i))) return false; else if (baseSign == 'o' && !StringUtil.isOctalDigit(s.charAt(i))) return false; else if (baseSign == 'x' && !StringUtil.isHexDigit(s.charAt(i))) return false; } return true; }