You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/07/21 19:25:42 UTC
[commons-text] branch master updated: Chnage new drain method name
to be similar to other drain method.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
The following commit(s) were added to refs/heads/master by this push:
new 3e15928 Chnage new drain method name to be similar to other drain method.
3e15928 is described below
commit 3e159282b4347cc215721da4e445ec5385bea74b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Jul 21 15:25:33 2020 -0400
Chnage new drain method name to be similar to other drain method.
---
.../org/apache/commons/text/TextStringBuilder.java | 40 +++++++++++-----------
.../apache/commons/text/TextStringBuilderTest.java | 8 ++---
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/TextStringBuilder.java b/src/main/java/org/apache/commons/text/TextStringBuilder.java
index b24170b..b617403 100644
--- a/src/main/java/org/apache/commons/text/TextStringBuilder.java
+++ b/src/main/java/org/apache/commons/text/TextStringBuilder.java
@@ -75,9 +75,6 @@ import org.apache.commons.text.matcher.StringMatcher;
*/
public class TextStringBuilder implements CharSequence, Appendable, Serializable, Builder<String> {
- /** The space character. */
- private static final char SPACE = ' ';
-
/**
* Inner class to allow StrBuilder to operate as a reader.
*/
@@ -256,6 +253,9 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
}
}
+ /** The space character. */
+ private static final char SPACE = ' ';
+
/**
* The extra capacity for new builders.
*/
@@ -1552,23 +1552,6 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
}
/**
- * Gets the character at the specified index before deleting it.
- *
- * @see #charAt(int)
- * @see #deleteCharAt(int)
- * @param index the index to retrieve, must be valid
- * @return The character at the index
- * @throws IndexOutOfBoundsException if the index is invalid
- * @since 1.9
- */
- public char charAtDelete(final int index) {
- validateIndex(index);
- final char c = buffer[index];
- deleteCharAt(index);
- return c;
- }
-
- /**
* Clears the string builder (convenience Collections API style method).
* <p>
* This method does not reduce the size of the internal character buffer. To do that, call {@code clear()} followed
@@ -1772,6 +1755,23 @@ public class TextStringBuilder implements CharSequence, Appendable, Serializable
}
/**
+ * Gets the character at the specified index before deleting it.
+ *
+ * @see #charAt(int)
+ * @see #deleteCharAt(int)
+ * @param index the index to retrieve, must be valid
+ * @return The character at the index
+ * @throws IndexOutOfBoundsException if the index is invalid
+ * @since 1.9
+ */
+ public char drainChar(final int index) {
+ validateIndex(index);
+ final char c = buffer[index];
+ deleteCharAt(index);
+ return c;
+ }
+
+ /**
* Drains (copies, then deletes) this character sequence into the specified array. This is equivalent to copying the
* characters from this sequence into the target and then deleting those character from this sequence.
*
diff --git a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
index 8e47b43..650ab4f 100644
--- a/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
+++ b/src/test/java/org/apache/commons/text/TextStringBuilderTest.java
@@ -527,16 +527,16 @@ public class TextStringBuilderTest {
final String str = "abc";
//
final TextStringBuilder sb1 = new TextStringBuilder(str);
- assertEquals('a', sb1.charAtDelete(0));
+ assertEquals('a', sb1.drainChar(0));
assertEquals("bc", sb1.toString());
//
final TextStringBuilder sb2 = new TextStringBuilder(str);
- assertEquals('c', sb2.charAtDelete(str.length() - 1));
+ assertEquals('c', sb2.drainChar(str.length() - 1));
assertEquals("ab", sb2.toString());
//
final TextStringBuilder sb3 = new TextStringBuilder(str);
- assertThrows(IndexOutOfBoundsException.class, () -> sb3.charAtDelete(str.length()));
- assertThrows(IndexOutOfBoundsException.class, () -> sb3.charAtDelete(1000));
+ assertThrows(IndexOutOfBoundsException.class, () -> sb3.drainChar(str.length()));
+ assertThrows(IndexOutOfBoundsException.class, () -> sb3.drainChar(1000));
}
@Test