private Range(int start, int length) { moveTo(start); setLength(length); }
/** * Moves this range such that the {@link #end()} is at <code>end</code>, keeping * {@link #length()} constant. * * @param end the new end * @throws LineIndexOutOfBoundsException if <code>end</code> <= {@link #start()} */ public void moveEndTo(int end) throws LineIndexOutOfBoundsException { moveTo(end - length()); }
/** * Moves the range by <code>delta</code> lines, keeping {@link #length()} constant. The * resulting start line must be >= 0. * * @param delta the number of lines to shift the range * @throws LineIndexOutOfBoundsException if <code>-delta</code> > {@link #start()} */ public void moveBy(int delta) throws LineIndexOutOfBoundsException { moveTo(start() + delta); }
/** * Moves this range such that the {@link #end()} is at <code>end</code>, keeping * {@link #length()} constant. * * @param end the new end * @throws LineIndexOutOfBoundsException if <code>end</code> <= {@link #start()} */ public void moveEndTo(int end) throws LineIndexOutOfBoundsException { moveTo(end - length()); }
/** * Moves the range by <code>delta</code> lines, keeping {@link #length()} constant. The * resulting start line must be >= 0. * * @param delta the number of lines to shift the range * @throws LineIndexOutOfBoundsException if <code>-delta</code> > {@link #start()} */ public void moveBy(int delta) throws LineIndexOutOfBoundsException { moveTo(start() + delta); }
private Range(int start, int length) { moveTo(start); setLength(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); }