/** * @return the ending index based on the start index and the max items to return * (not based on the actual items in the results), return the max int if the max is 0 */ public int getEndIndex() { int end; int max = getMaxItemsToReturn(); if (max <= 0) { end = Integer.MAX_VALUE; } else { end = startIndex + getMaxItemsToReturn(); } return end; }
/** * @return the count of the number of items returned */ public int getResultsNum() { return getResults().size(); }
/** * @return the ending number for these results * (this is the true ending number and also the ending index based on the items returned * and not only based on the max items to return) */ public int getEndNum() { return startIndex + getResultsNum(); // or (startIndex + 1) + (resultsNum - 1) }
/** * Add results to the total results, * this will not allow adding results beyond the totalItemsMatched (max) number * * @param steepleItem the result to add * @return true if the item was added OR false if it was null or the max number is already added */ public boolean addResult(SearchContent content) { boolean added = false; if (content != null) { SearchResult sr = new SearchResult(content); added = addResult(sr); } return added; }
/** * Add results to the total results, * this will not allow adding results beyond the maxItemsToReturn (max) number * * @param searchResult the result to add * @return true if the item was added OR false if it was null or the max number is already added */ public boolean addResult(SearchResult searchResult) { boolean added = false; if (searchResult != null) { if (this.maxItemsToReturn <= 0 || getResults().size() < this.maxItemsToReturn) { getResults().add(searchResult); // this will ensure that the total items matched is not completely wrong if (getResults().size() > this.totalItemsMatched) { this.totalItemsMatched = getResults().size(); } added = true; } } return added; }