/** * Sets the range from a string representation. * * @param range the start and end string * */ public void setRange(String range) { String single = range.trim(); int hyphenIndex = range.indexOf('-'); if (hyphenIndex > 0) { this.start = rangeSingle(range.substring(0, hyphenIndex)); this.end = rangeSingle(range.substring(hyphenIndex + 1)); } else { int number = rangeSingle(range); if (number >= 0) { // first n attributes this.start = 0; this.end = number; } else { // last n attributes this.start = this.upperLimit + number > 0 ? this.upperLimit + number : 0; this.end = this.upperLimit - 1; } } }