String (String text, String newSeparator, Collection<? extends TextBlockTransferableData> itemsToUpdate) { if (itemsToUpdate.size() > 0){ int size = 0; for(TextBlockTransferableData data: itemsToUpdate) { size += data.getOffsetCount(); } int[] offsets = new int[size]; int index = 0; for(TextBlockTransferableData data: itemsToUpdate) { index = data.getOffsets(offsets, index); } text = Strings.convertLineSeparators(text, newSeparator, offsets); index = 0; for(TextBlockTransferableData data: itemsToUpdate) { index = data.setOffsets(offsets, index); } return text; } else{ return StringUtil.convertLineSeparators(text, newSeparator); } }