public IntItem(Limit from, Limit to, int hitLimit, String indexName, boolean isFromQuery) { super(indexName, isFromQuery); setLimits(from, to); this.hitLimit = hitLimit; this.expression = toExpression(from, to, hitLimit); }
private void parseAndAssignLimits(String e) { if (e.startsWith("<") && ! e.contains(";")) { from = Limit.NEGATIVE_INFINITY; to = new Limit(asNumber(e.substring(1)), false); } else if (e.startsWith(">")) { from = new Limit(asNumber(e.substring(1)), false); to = Limit.POSITIVE_INFINITY; } else if (e.startsWith("[") || e.startsWith("<")) { if ( ! (e.endsWith("]") || e.endsWith(">"))) throw new IllegalArgumentException("No closing bracket"); boolean inclusiveStart = e.startsWith("["); boolean inclusiveEnd = e.startsWith("["); String[] limits = e.substring(1, e.length()-1).split(";"); if (limits.length < 1 || limits.length > 3) throw new IllegalArgumentException("Unexpected bracket content"); Limit from = new Limit(getOr(Double.NEGATIVE_INFINITY, 0, limits), inclusiveStart); Limit to = new Limit(getOr(Double.POSITIVE_INFINITY, 1, limits), inclusiveEnd); setLimits(from, to); hitLimit = getOr(0, 2, limits).intValue(); } else { to = from = new Limit(asNumber(e), true); } }