Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEXT-234] Improve TextStringBuilder documentation for new line text #547

Merged
merged 1 commit into from
May 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/main/java/org/apache/commons/text/TextStringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,9 @@ public static TextStringBuilder wrap(final char[] initialBuffer, final int lengt
/** Internal data storage. */
private char[] buffer;

/** The new line. */
/**
* The new line, {@code null} means use the system default from {@link System#lineSeparator()}.
*/
private String newLine;

/** The null text. */
Expand Down Expand Up @@ -1162,13 +1164,18 @@ public TextStringBuilder appendln(final TextStringBuilder str, final int startIn
}

/**
* Appends the new line string to this string builder.
* Appends this builder's new line string to this builder.
* <p>
* By default, the new line is the system default from {@link System#lineSeparator()}.
* </p>
* <p>
* The new line string can be altered using {@link #setNewLineText(String)}. This might be used to force the output
* to always use UNIX line endings even when on Windows.
* The new line string can be changed using {@link #setNewLineText(String)}. For example, you can use this to force the output to always use UNIX line
* endings even when on Windows.
* </p>
*
* @return this, to enable chaining
* @return this
* @see #getNewLineText()
* @see #setNewLineText(String)
*/
public TextStringBuilder appendNewLine() {
if (newLine == null) {
Expand Down Expand Up @@ -2021,9 +2028,9 @@ public void getChars(final int startIndex, final int endIndex, final char[] targ
}

/**
* Gets the text to be appended when a new line is added.
* Gets the text to be appended when a {@link #appendNewLine() new line} is added.
*
* @return The new line text, null means use system default
* @return The new line text, {@code null} means use the system default from {@link System#lineSeparator()}.
*/
public String getNewLineText() {
return newLine;
Expand Down Expand Up @@ -3014,10 +3021,10 @@ public TextStringBuilder setLength(final int length) {
}

/**
* Sets the text to be appended when a new line is added.
* Sets the text to be appended when {@link #appendNewLine() new line} is called.
*
* @param newLine the new line text, null means use system default
* @return this, to enable chaining
* @param newLine the new line text, {@code null} means use the system default from {@link System#lineSeparator()}.
* @return this.
*/
public TextStringBuilder setNewLineText(final String newLine) {
this.newLine = newLine;
Expand Down