This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 958ae3d6b5 Merge changes from commons-io
958ae3d6b5 is described below
commit 958ae3d6b5bf7fcc24b831d6f6547fde5232b555
Author: Daniel Sun <[email protected]>
AuthorDate: Sun Nov 3 21:19:14 2024 +0800
Merge changes from commons-io
---
.../org/apache/groovy/io/StringBuilderWriter.java | 48 +++++++++++-----------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/src/main/java/org/apache/groovy/io/StringBuilderWriter.java
b/src/main/java/org/apache/groovy/io/StringBuilderWriter.java
index 8cbd3ce652..6334820eac 100644
--- a/src/main/java/org/apache/groovy/io/StringBuilderWriter.java
+++ b/src/main/java/org/apache/groovy/io/StringBuilderWriter.java
@@ -22,21 +22,24 @@ import java.io.Serializable;
import java.io.Writer;
/**
+ * <p>
* Copied from
https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java
- *
+ * </p>
* {@link Writer} implementation that outputs to a {@link StringBuilder}.
* <p>
* <strong>NOTE:</strong> This implementation, as an alternative to
- * <code>java.io.StringWriter</code>, provides an <i>un-synchronized</i>
+ * {@link java.io.StringWriter}, provides an <em>un-synchronized</em>
* (i.e. for use in a single thread) implementation for better performance.
* For safe usage with multiple {@link Thread}s then
- * <code>java.io.StringWriter</code> should be used.
- *
+ * {@link java.io.StringWriter} should be used.
+ * </p>
* @since 2.0
*/
public class StringBuilderWriter extends Writer implements Serializable {
private static final long serialVersionUID = -146927496096066153L;
+
+ /** The append target. */
private final StringBuilder builder;
/**
@@ -120,17 +123,23 @@ public class StringBuilderWriter extends Writer
implements Serializable {
// no-op
}
+ /**
+ * Gets the underlying builder.
+ *
+ * @return The underlying builder
+ */
+ public StringBuilder getBuilder() {
+ return builder;
+ }
/**
- * Writes a String to the {@link StringBuilder}.
+ * Returns {@link StringBuilder#toString()}.
*
- * @param value The value to write
+ * @return The contents of the String builder.
*/
@Override
- public void write(final String value) {
- if (value != null) {
- builder.append(value);
- }
+ public String toString() {
+ return builder.toString();
}
/**
@@ -148,21 +157,14 @@ public class StringBuilderWriter extends Writer
implements Serializable {
}
/**
- * Returns the underlying builder.
- *
- * @return The underlying builder
- */
- public StringBuilder getBuilder() {
- return builder;
- }
-
- /**
- * Returns {@link StringBuilder#toString()}.
+ * Writes a String to the {@link StringBuilder}.
*
- * @return The contents of the String builder.
+ * @param value The value to write
*/
@Override
- public String toString() {
- return builder.toString();
+ public void write(final String value) {
+ if (value != null) {
+ builder.append(value);
+ }
}
}