/** * Moves the receiver to <code>start</code>, keeping {@link #length()} constant. * * @param start the new start, must be >= 0 * @throws LineIndexOutOfBoundsException if <code>start</code> < 0 */ public void moveTo(int start) throws LineIndexOutOfBoundsException { if (!(start >= 0)) throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ fStart= start; }
/** * Sets the length of this range, keeping {@link #start()} constant. * * @param length the new length, must be > 0 * @throws LineIndexOutOfBoundsException if <code>length</code> <= 0 */ public void setLength(int length) throws LineIndexOutOfBoundsException { if (!(length > 0)) throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$ fLength= length; }
/** * Moves the receiver to <code>start</code>, keeping {@link #length()} constant. * * @param start the new start, must be >= 0 * @throws LineIndexOutOfBoundsException if <code>start</code> < 0 */ public void moveTo(int start) throws LineIndexOutOfBoundsException { if (!(start >= 0)) throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ fStart= start; }
/** * Sets the length of this range, keeping {@link #start()} constant. * * @param length the new length, must be > 0 * @throws LineIndexOutOfBoundsException if <code>length</code> <= 0 */ public void setLength(int length) throws LineIndexOutOfBoundsException { if (!(length > 0)) throw new LineIndexOutOfBoundsException("Cannot set length <= 0: " + length); //$NON-NLS-1$ fLength= length; }
/** * Moves the start offset to <code>start</code>, keeping {@link #end()} constant. * * @param start the new start, must be >= 0 and < {@link #end()} * @throws LineIndexOutOfBoundsException if <code>start</code> < 0 or >= {@link #end()} */ public void setStart(int start) throws LineIndexOutOfBoundsException { int end= end(); if (!(start >= 0 && start < end)) throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ moveTo(start); setEnd(end); }
/** * Moves the start offset to <code>start</code>, keeping {@link #end()} constant. * * @param start the new start, must be >= 0 and < {@link #end()} * @throws LineIndexOutOfBoundsException if <code>start</code> < 0 or >= {@link #end()} */ public void setStart(int start) throws LineIndexOutOfBoundsException { int end= end(); if (!(start >= 0 && start < end)) throw new LineIndexOutOfBoundsException("Cannot set a negative start: " + start); //$NON-NLS-1$ moveTo(start); setEnd(end); }
/** * 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); }