mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8230800: Clarify String::stripIndent javadoc when string ends with line terminator
Reviewed-by: jlaskey, bchristi, rriggs
This commit is contained in:
parent
7467cd2ee5
commit
bfd2e96120
1 changed files with 27 additions and 16 deletions
|
@ -2917,22 +2917,34 @@ public final class String
|
||||||
* | </body>
|
* | </body>
|
||||||
* |</html>
|
* |</html>
|
||||||
* </pre></blockquote>
|
* </pre></blockquote>
|
||||||
* First, the individual lines of this string are extracted as if by using
|
* First, the individual lines of this string are extracted. A <i>line</i>
|
||||||
* {@link String#lines()}.
|
* is a sequence of zero or more characters followed by either a line
|
||||||
|
* terminator or the end of the string.
|
||||||
|
* If the string has at least one line terminator, the last line consists
|
||||||
|
* of the characters between the last terminator and the end of the string.
|
||||||
|
* Otherwise, if the string has no terminators, the last line is the start
|
||||||
|
* of the string to the end of the string, in other words, the entire
|
||||||
|
* string.
|
||||||
|
* A line does not include the line terminator.
|
||||||
* <p>
|
* <p>
|
||||||
* Then, the <i>minimum indentation</i> (min) is determined as follows.
|
* Then, the <i>minimum indentation</i> (min) is determined as follows:
|
||||||
* For each non-blank line (as defined by {@link String#isBlank()}), the
|
* <ul>
|
||||||
* leading {@linkplain Character#isWhitespace(int) white space} characters are
|
* <li><p>For each non-blank line (as defined by {@link String#isBlank()}),
|
||||||
* counted. The leading {@linkplain Character#isWhitespace(int) white space}
|
* the leading {@linkplain Character#isWhitespace(int) white space}
|
||||||
* characters on the last line are also counted even if
|
* characters are counted.</p>
|
||||||
* {@linkplain String#isBlank() blank}. The <i>min</i> value is the smallest
|
* </li>
|
||||||
* of these counts.
|
* <li><p>The leading {@linkplain Character#isWhitespace(int) white space}
|
||||||
|
* characters on the last line are also counted even if
|
||||||
|
* {@linkplain String#isBlank() blank}.</p>
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
|
* <p>The <i>min</i> value is the smallest of these counts.
|
||||||
* <p>
|
* <p>
|
||||||
* For each {@linkplain String#isBlank() non-blank} line, <i>min</i> leading
|
* For each {@linkplain String#isBlank() non-blank} line, <i>min</i> leading
|
||||||
* {@linkplain Character#isWhitespace(int) white space} characters are removed,
|
* {@linkplain Character#isWhitespace(int) white space} characters are
|
||||||
* and any trailing {@linkplain Character#isWhitespace(int) white space}
|
* removed, and any trailing {@linkplain Character#isWhitespace(int) white
|
||||||
* characters are removed. {@linkplain String#isBlank() Blank} lines are
|
* space} characters are removed. {@linkplain String#isBlank() Blank} lines
|
||||||
* replaced with the empty string.
|
* are replaced with the empty string.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* Finally, the lines are joined into a new string, using the LF character
|
* Finally, the lines are joined into a new string, using the LF character
|
||||||
|
@ -2943,12 +2955,11 @@ public final class String
|
||||||
* possible to the left, while preserving relative indentation. Lines
|
* possible to the left, while preserving relative indentation. Lines
|
||||||
* that were indented the least will thus have no leading
|
* that were indented the least will thus have no leading
|
||||||
* {@linkplain Character#isWhitespace(int) white space}.
|
* {@linkplain Character#isWhitespace(int) white space}.
|
||||||
* The line count of the result will be the same as line count of this
|
* The result will have the same number of line terminators as this string.
|
||||||
* string.
|
|
||||||
* If this string ends with a line terminator then the result will end
|
* If this string ends with a line terminator then the result will end
|
||||||
* with a line terminator.
|
* with a line terminator.
|
||||||
*
|
*
|
||||||
* @implNote
|
* @implSpec
|
||||||
* This method treats all {@linkplain Character#isWhitespace(int) white space}
|
* This method treats all {@linkplain Character#isWhitespace(int) white space}
|
||||||
* characters as having equal width. As long as the indentation on every
|
* characters as having equal width. As long as the indentation on every
|
||||||
* line is consistently composed of the same character sequences, then the
|
* line is consistently composed of the same character sequences, then the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue