1268 * converted to a string by the method {@link String#valueOf(double)}, 1269 * and the characters of that string were then 1270 * {@link #insert(int,String) inserted} into this character 1271 * sequence at the indicated offset. 1272 * <p> 1273 * The {@code offset} argument must be greater than or equal to 1274 * {@code 0}, and less than or equal to the {@linkplain #length() length} 1275 * of this sequence. 1276 * 1277 * @param offset the offset. 1278 * @param d a {@code double}. 1279 * @return a reference to this object. 1280 * @throws StringIndexOutOfBoundsException if the offset is invalid. 1281 */ 1282 public AbstractStringBuilder insert(int offset, double d) { 1283 return insert(offset, String.valueOf(d)); 1284 } 1285 1286 /** 1287 * Returns the index within this string of the first occurrence of the 1288 * specified substring. The integer returned is the smallest value 1289 * <i>k</i> such that: 1290 * <pre>{@code 1291 * this.toString().startsWith(str, <i>k</i>) 1292 * }</pre> 1293 * is {@code true}. 1294 * 1295 * @param str any string. 1296 * @return if the string argument occurs as a substring within this 1297 * object, then the index of the first character of the first 1298 * such substring is returned; if it does not occur as a 1299 * substring, {@code -1} is returned. 1300 */ 1301 public int indexOf(String str) { 1302 return indexOf(str, 0); 1303 } 1304 1305 /** 1306 * Returns the index within this string of the first occurrence of the 1307 * specified substring, starting at the specified index. The integer 1308 * returned is the smallest value {@code k} for which: 1309 * <pre>{@code 1310 * k >= Math.min(fromIndex, this.length()) && 1311 * this.toString().startsWith(str, k) 1312 * }</pre> 1313 * If no such value of <i>k</i> exists, then -1 is returned. 1314 * 1315 * @param str the substring for which to search. 1316 * @param fromIndex the index from which to start the search. 1317 * @return the index within this string of the first occurrence of the 1318 * specified substring, starting at the specified index. 1319 */ 1320 public int indexOf(String str, int fromIndex) { 1321 return String.indexOf(value, 0, count, str, fromIndex); 1322 } 1323 1324 /** 1325 * Returns the index within this string of the rightmost occurrence 1326 * of the specified substring. The rightmost empty string "" is 1327 * considered to occur at the index value {@code this.length()}. 1328 * The returned index is the largest value <i>k</i> such that 1329 * <pre>{@code 1330 * this.toString().startsWith(str, k) 1331 * }</pre> 1332 * is true. 1333 * 1334 * @param str the substring to search for. 1335 * @return if the string argument occurs one or more times as a substring 1336 * within this object, then the index of the first character of 1337 * the last such substring is returned. If it does not occur as 1338 * a substring, {@code -1} is returned. 1339 */ 1340 public int lastIndexOf(String str) { 1341 return lastIndexOf(str, count); 1342 } 1343 1344 /** 1345 * Returns the index within this string of the last occurrence of the 1346 * specified substring. The integer returned is the largest value <i>k</i> 1347 * such that: 1348 * <pre>{@code 1349 * k <= Math.min(fromIndex, this.length()) && 1350 * this.toString().startsWith(str, k) 1351 * }</pre> 1352 * If no such value of <i>k</i> exists, then -1 is returned. 1353 * 1354 * @param str the substring to search for. 1355 * @param fromIndex the index to start the search from. 1356 * @return the index within this sequence of the last occurrence of the 1357 * specified substring. 1358 */ 1359 public int lastIndexOf(String str, int fromIndex) { 1360 return String.lastIndexOf(value, 0, count, str, fromIndex); 1361 } 1362 1363 /** 1364 * Causes this character sequence to be replaced by the reverse of 1365 * the sequence. If there are any surrogate pairs included in the 1366 * sequence, these are treated as single characters for the 1367 * reverse operation. Thus, the order of the high-low surrogates 1368 * is never reversed. 1369 * 1370 * Let <i>n</i> be the character length of this character sequence 1371 * (not the length in {@code char} values) just prior to 1372 * execution of the {@code reverse} method. Then the 1373 * character at index <i>k</i> in the new character sequence is 1374 * equal to the character at index <i>n-k-1</i> in the old 1375 * character sequence. 1376 * 1377 * <p>Note that the reverse operation may result in producing | 1268 * converted to a string by the method {@link String#valueOf(double)}, 1269 * and the characters of that string were then 1270 * {@link #insert(int,String) inserted} into this character 1271 * sequence at the indicated offset. 1272 * <p> 1273 * The {@code offset} argument must be greater than or equal to 1274 * {@code 0}, and less than or equal to the {@linkplain #length() length} 1275 * of this sequence. 1276 * 1277 * @param offset the offset. 1278 * @param d a {@code double}. 1279 * @return a reference to this object. 1280 * @throws StringIndexOutOfBoundsException if the offset is invalid. 1281 */ 1282 public AbstractStringBuilder insert(int offset, double d) { 1283 return insert(offset, String.valueOf(d)); 1284 } 1285 1286 /** 1287 * Returns the index within this string of the first occurrence of the 1288 * specified substring. 1289 * 1290 * <p>The returned index is the smallest value {@code k} for which: 1291 * <pre>{@code 1292 * this.toString().startsWith(str, k) 1293 * }</pre> 1294 * If no such value of {@code k} exists, then {@code -1} is returned. 1295 * 1296 * @param str the substring to search for. 1297 * @return the index of the first occurrence of the specified substring, 1298 * or {@code -1} if there is no such occurrence. 1299 */ 1300 public int indexOf(String str) { 1301 return indexOf(str, 0); 1302 } 1303 1304 /** 1305 * Returns the index within this string of the first occurrence of the 1306 * specified substring, starting at the specified index. 1307 * 1308 * <p>The returned index is the smallest value {@code k} for which: 1309 * <pre>{@code 1310 * k >= Math.min(fromIndex, this.length()) && 1311 * this.toString().startsWith(str, k) 1312 * }</pre> 1313 * If no such value of {@code k} exists, then {@code -1} is returned. 1314 * 1315 * @param str the substring to search for. 1316 * @param fromIndex the index from which to start the search. 1317 * @return the index of the first occurrence of the specified substring, 1318 * starting at the specified index, 1319 * or {@code -1} if there is no such occurrence. 1320 */ 1321 public int indexOf(String str, int fromIndex) { 1322 return String.indexOf(value, 0, count, str, fromIndex); 1323 } 1324 1325 /** 1326 * Returns the index within this string of the last occurrence of the 1327 * specified substring. The last occurrence of the empty string "" is 1328 * considered to occur at the index value {@code this.length()}. 1329 * 1330 * <p>The returned index is the largest value {@code k} for which: 1331 * <pre>{@code 1332 * this.toString().startsWith(str, k) 1333 * }</pre> 1334 * If no such value of {@code k} exists, then {@code -1} is returned. 1335 * 1336 * @param str the substring to search for. 1337 * @return the index of the last occurrence of the specified substring, 1338 * or {@code -1} if there is no such occurrence. 1339 */ 1340 public int lastIndexOf(String str) { 1341 return lastIndexOf(str, count); 1342 } 1343 1344 /** 1345 * Returns the index within this string of the last occurrence of the 1346 * specified substring, searching backward starting at the specified index. 1347 * 1348 * <p>The returned index is the largest value {@code k<} for which: 1349 * <pre>{@code 1350 * k <= Math.min(fromIndex, this.length()) && 1351 * this.toString().startsWith(str, k) 1352 * }</pre> 1353 * If no such value of {@code k} exists, then {@code -1} is returned. 1354 * 1355 * @param str the substring to search for. 1356 * @param fromIndex the index to start the search from. 1357 * @return the index of the last occurrence of the specified substring, 1358 * searching backward from the specified index, 1359 * or {@code -1} if there is no such occurrence. 1360 */ 1361 public int lastIndexOf(String str, int fromIndex) { 1362 return String.lastIndexOf(value, 0, count, str, fromIndex); 1363 } 1364 1365 /** 1366 * Causes this character sequence to be replaced by the reverse of 1367 * the sequence. If there are any surrogate pairs included in the 1368 * sequence, these are treated as single characters for the 1369 * reverse operation. Thus, the order of the high-low surrogates 1370 * is never reversed. 1371 * 1372 * Let <i>n</i> be the character length of this character sequence 1373 * (not the length in {@code char} values) just prior to 1374 * execution of the {@code reverse} method. Then the 1375 * character at index <i>k</i> in the new character sequence is 1376 * equal to the character at index <i>n-k-1</i> in the old 1377 * character sequence. 1378 * 1379 * <p>Note that the reverse operation may result in producing |