question: protected void moveAndResizeGap ( int position , int size ) { char [ ] content = null ; int oldSize = this . gapEnd - this . gapStart ; if ( size < 0 ) { if ( oldSize > 0 ) { content = new char [ this . contents . length - oldSize ] ; System . arraycopy ( this . contents , 0 , content , 0 , this . gapStart ) ; System . arraycopy ( this . contents , this . gapEnd , content , this . gapStart , content . length - this . gapStart ) ; this . contents = content ; } this . gapStart = this . gapEnd = position ; return ; } content = new char [ this . contents . length + ( size - oldSize ) ] ; int newGapStart = position ; int newGapEnd = newGapStart + size ; if ( oldSize == 0 ) { System . arraycopy ( this . contents , 0 , content , 0 , newGapStart ) ; System . arraycopy ( this . contents , newGapStart , content , newGapEnd , content . length - newGapEnd ) ; } else if ( newGapStart < this . gapStart ) { int delta = this . gapStart - newGapStart ; System . arraycopy ( this . contents , 0 , content , 0 , newGapStart ) ; System . arraycopy ( this . contents , newGapStart , content , newGapEnd , delta ) ; System . arraycopy ( this . contents , this . gapEnd , content , newGapEnd + delta , this . contents . length - this . gapEnd ) ; } else { int delta = newGapStart - this . gapStart ; System . arraycopy ( this . contents , 0 , content , 0 , this . gapStart ) ; System . arraycopy ( this . contents , this . gapEnd , content , this . gapStart , delta ) ; System . arraycopy ( this . contents , this . gapEnd + delta , content , newGapEnd , content . length - newGapEnd ) ; } this . contents = content ; this . gapStart = newGapStart ; this . gapEnd = newGapEnd ; }
target:  Moves the gap to location and adjust its size to the anticipated change size. The size represents the expected range of the gap that will be filled after the gap has been moved. Thus the gap is resized to actual size + the specified size and moved to the given position.