private static GroupResult checkRange( final String string, final char[] charArray, int endIndex, final long data) { final Long min, max; { boolean sign = true; for (final int charArrayLength = charArray.length; endIndex < charArrayLength; endIndex++) { final char c = charArray[endIndex]; if (sign) { sign = false; if ((c == '+') || (c == '-')) { continue; } } if ((c < '0') || (c > '9')) { break; } } if (endIndex == 0) { return new GroupResult(false, false, 0); } min = DioriteMathUtils.asLong(string.substring(0, endIndex)); if (min == null) { return new GroupResult(false, false, 0); } } if (charArray[endIndex++] != '-') { return new GroupResult(false, false, 0); } final int start = endIndex; { boolean sign = true; for (final int charArrayLength = charArray.length; endIndex < charArrayLength; endIndex++) { final char c = charArray[endIndex]; if (sign) { sign = false; if ((c == '+') || (c == '-')) { continue; } } if ((c < '0') || (c > '9')) { break; } } if (endIndex == 0) { return new GroupResult(false, false, 0); } max = DioriteMathUtils.asLong(string.substring(start, endIndex)); if (max == null) { return new GroupResult(false, false, 0); } } return new GroupResult(true, (data >= min) && (data <= max), endIndex); }
private static boolean checkIfValidRange(final String string) { final int index = string.lastIndexOf('-'); if (index == -1) { return false; } final int index2 = string.lastIndexOf('-', index - 1); // to handle negative values in ranges if ((index2 == 0) || (index2 == -1)) { return (DioriteMathUtils.asLong(string.substring(0, index)) != null) && (DioriteMathUtils.asLong(string.substring(index + 1)) != null); } return (DioriteMathUtils.asLong(string.substring(0, index2)) != null) && (DioriteMathUtils.asLong(string.substring(index2 + 1)) != null); }
@Override public Long parseValueData(final String data) { if (data == null) { return null; } return DioriteMathUtils.asLong(data); }
private static LongRange parseSingleRange(final String string) { final int index = string.lastIndexOf('-'); if (index == -1) { return null; } final int index2 = string.lastIndexOf('-', index - 1); // to handle negative values in ranges final Long a; final Long b; if ((index2 == 0) || (index2 == -1)) { a = DioriteMathUtils.asLong(string.substring(0, index)); b = DioriteMathUtils.asLong(string.substring(index + 1)); } else { a = DioriteMathUtils.asLong(string.substring(0, index2)); b = DioriteMathUtils.asLong(string.substring(index2 + 1)); } if ((a == null) || (b == null)) { return null; } return new LongRange(a, b); }
@Override public boolean isValidValue(final String string) { return DioriteMathUtils.asLong(string) != null; }