/** * Creates a new range with the given start and end offsets. * * @param start the first line of the new range, must be >= 0 * @param end the first line not in the range any more (exclusive), must be > <code>start</code> * @return a <code>Range</code> with the given start and end offsets * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of * {@link Range} */ public static Range createAbsolute(int start, int end) { return new Range(start, end - start); }
/** * Creates a new range with the given start offset and length. * * @param start the first line of the new range, must be >= 0 * @param length the number of lines included in the new range, must be > 0 * @return a <code>Range</code> with the given start and length * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of * {@link Range} */ public static Range createRelative(int start, int length) throws LineIndexOutOfBoundsException { return new Range(start, length); }
/** * Creates a new range with the given start offset and length. * * @param start the first line of the new range, must be >= 0 * @param length the number of lines included in the new range, must be > 0 * @return a <code>Range</code> with the given start and length * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of * {@link Range} */ public static Range createRelative(int start, int length) throws LineIndexOutOfBoundsException { return new Range(start, length); }
/** * Creates a new range with the given start and end offsets. * * @param start the first line of the new range, must be >= 0 * @param end the first line not in the range any more (exclusive), must be > <code>start</code> * @return a <code>Range</code> with the given start and end offsets * @throws LineIndexOutOfBoundsException if the parameters violate the invariant of * {@link Range} */ public static Range createAbsolute(int start, int end) { return new Range(start, end - start); }
/** * Splits a range off the end of the receiver. The receiver is shortened to only include * <code>remaining</code> lines after the split. * * @param remaining the number of lines to remain in the receiver, must be in [1, {@link #length() length}) * @return the split off range * @throws LineIndexOutOfBoundsException if <code>remaining</code>>= {@link #length()} or <code>remaining</code><t;= 0 */ public Range split(int remaining) throws LineIndexOutOfBoundsException { if (!(remaining < length())) // assert before modification throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$ int splitLength= length() - remaining; setLength(remaining); return new Range(end(), splitLength); }
/** * Splits a range off the end of the receiver. The receiver is shortened to only include * <code>remaining</code> lines after the split. * * @param remaining the number of lines to remain in the receiver, must be in [1, {@link #length() length}) * @return the split off range * @throws LineIndexOutOfBoundsException if <code>remaining</code>>= {@link #length()} or <code>remaining</code><t;= 0 */ public Range split(int remaining) throws LineIndexOutOfBoundsException { if (!(remaining < length())) // assert before modification throw new LineIndexOutOfBoundsException("Remaining must be less than length: " + length()); //$NON-NLS-1$ int splitLength= length() - remaining; setLength(remaining); return new Range(end(), splitLength); }