/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteAll(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { int start = i; while (++i < size) { if (buffer[i] != ch) { break; } } int len = i - start; deleteImpl(start, i, len); i -= len; } } return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the string wherever it occurs in the builder. * * @param str the string to delete, null causes no action * @return this, to enable chaining */ public StrBuilder deleteFirst(String str) { int len = (str == null ? 0 : str.length()); if (len > 0) { int index = indexOf(str, 0); if (index >= 0) { deleteImpl(index, index + len, len); } } return this; }
/** * Deletes the characters between the two specified indices. * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except * that if too large it is treated as end of string * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder delete(int startIndex, int endIndex) { endIndex = validateRange(startIndex, endIndex); int len = endIndex - startIndex; if (len > 0) { deleteImpl(startIndex, endIndex, len); } return this; }
/** * Deletes the string wherever it occurs in the builder. * * @param str the string to delete, null causes no action * @return this, to enable chaining */ public StrBuilder deleteAll(String str) { int len = (str == null ? 0 : str.length()); if (len > 0) { int index = indexOf(str, 0); while (index >= 0) { deleteImpl(index, index + len, len); index = indexOf(str, index); } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character wherever it occurs in the builder. * * @param ch the character to delete * @return this, to enable chaining */ public StrBuilder deleteFirst(char ch) { for (int i = 0; i < size; i++) { if (buffer[i] == ch) { deleteImpl(i, i + 1, 1); break; } } return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the string wherever it occurs in the builder. * * @param str the string to delete, null causes no action * @return this, to enable chaining */ public StrBuilder deleteFirst(String str) { int len = (str == null ? 0 : str.length()); if (len > 0) { int index = indexOf(str, 0); if (index >= 0) { deleteImpl(index, index + len, len); } } return this; }
/** * Deletes the string wherever it occurs in the builder. * * @param str the string to delete, null causes no action * @return this, to enable chaining */ public StrBuilder deleteFirst(String str) { int len = (str == null ? 0 : str.length()); if (len > 0) { int index = indexOf(str, 0); if (index >= 0) { deleteImpl(index, index + len, len); } } return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the string wherever it occurs in the builder. * * @param str the string to delete, null causes no action * @return this, to enable chaining */ public StrBuilder deleteFirst(String str) { int len = (str == null ? 0 : str.length()); if (len > 0) { int index = indexOf(str, 0); if (index >= 0) { deleteImpl(index, index + len, len); } } return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the character at the specified index. * * @see #charAt(int) * @see #setCharAt(int, char) * @param index the index to delete * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder deleteCharAt(int index) { if (index < 0 || index >= size) { throw new StringIndexOutOfBoundsException(index); } deleteImpl(index, index + 1, 1); return this; }
/** * Deletes the characters between the two specified indices. * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except * that if too large it is treated as end of string * @return this, to enable chaining * @throws IndexOutOfBoundsException if the index is invalid */ public StrBuilder delete(int startIndex, int endIndex) { endIndex = validateRange(startIndex, endIndex); int len = endIndex - startIndex; if (len > 0) { deleteImpl(startIndex, endIndex, len); } return this; }