public int moveIndex(int delta){
  int x=Math.max(0,Math.min(getIndex() + delta,getLength()));
  setIndex(x);
  return x;
}

public int moveIndex ( int delta ) { int x = Math . max ( 0 , Math . min ( getIndex ( ) + delta , getLength ( ) ) ) ; setIndex ( x ) ; return x ; }
moves the current position by the number of code units specified , either forward or backward depending on the sign of delta ( positive or negative respectively ) . if the resulting index would be less than zero , the index is set to zero , and if the resulting index would be greater than limit , the index is set to limit .
