/** * Inserts elements after the position specified by the hitIterator. * * @param operation the operation that wants to insert elements. * @param doc the document to insert elements in. * @param view the {@link ApiView} of that document. * @param hitIterator the iterator over the places where to insert. * @param modifyAction the action that specifies what to insert. * @throws InvalidRequestException if something goes wrong. */ private void insertAfter(OperationRequest operation, Document doc, ApiView view, DocumentHitIterator hitIterator, DocumentModifyAction modifyAction) throws InvalidRequestException { int valueIndex = 0; Range range = hitIterator.next(); while (range != null) { int insertAt = range.getEnd(); int inserted = insertInto(operation, doc, view, insertAt, modifyAction, valueIndex); hitIterator.shift(insertAt, inserted); valueIndex++; range = hitIterator.next(); } }
/** * Inserts elements at the position specified by the hitIterator. * * @param operation the operation that wants to insert elements. * @param doc the document to insert elements in. * @param view the {@link ApiView} of that document. * @param hitIterator the iterator over the places where to insert. * @param modifyAction the action that specifies what to insert. * @throws InvalidRequestException if something goes wrong. */ private void insert(OperationRequest operation, Document doc, ApiView view, DocumentHitIterator hitIterator, DocumentModifyAction modifyAction) throws InvalidRequestException { int valueIndex = 0; Range range = hitIterator.next(); while (range != null) { int insertAt = range.getStart(); int inserted = insertInto(operation, doc, view, insertAt, modifyAction, valueIndex); hitIterator.shift(insertAt, inserted); valueIndex++; range = hitIterator.next(); } }
int replaceAt = range.getStart(); int numInserted = insertInto(operation, doc, view, replaceAt, modifyAction, valueIndex);