Skip to content

Commit 9da3c6a

Browse files
committed
Javadoc
1 parent 17c6df5 commit 9da3c6a

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

src/main/java/org/apache/commons/lang3/StringUtils.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public class StringUtils {
141141
// (not sure who tested this)
142142

143143
/**
144-
* This is a 3 character version of an ellipsis. There is a Unicode character for a HORIZONTAL ELLIPSIS, U+2026 this isn't it.
144+
* This is a 3 character version of an ellipsis. There is a Unicode character for a HORIZONTAL ELLIPSIS, U+2026 '…', this isn't it.
145145
*/
146146
private static final String ELLIPSIS3 = "...";
147147

@@ -203,18 +203,16 @@ public class StringUtils {
203203
private static final Pattern STRIP_ACCENTS_PATTERN = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
204204

205205
/**
206-
* Abbreviates a String using ellipses. This will turn
207-
* "Now is the time for all good men" into "Now is the time for..."
206+
* Abbreviates a String using ellipses. This will convert "Now is the time for all good men" into "Now is the time for..."
208207
*
209-
* <p>Specifically:</p>
208+
* <p>
209+
* Specifically:
210+
* </p>
210211
* <ul>
211-
* <li>If the number of characters in {@code str} is less than or equal to
212-
* {@code maxWidth}, return {@code str}.</li>
213-
* <li>Else abbreviate it to {@code (substring(str, 0, max-3) + "...")}.</li>
214-
* <li>If {@code maxWidth} is less than {@code 4}, throw an
215-
* {@link IllegalArgumentException}.</li>
216-
* <li>In no case will it return a String of length greater than
217-
* {@code maxWidth}.</li>
212+
* <li>If the number of characters in {@code str} is less than or equal to {@code maxWidth}, return {@code str}.</li>
213+
* <li>Else abbreviate it to {@code (substring(str, 0, max - 3) + "...")}.</li>
214+
* <li>If {@code maxWidth} is less than {@code 4}, throw an {@link IllegalArgumentException}.</li>
215+
* <li>In no case will it return a String of length greater than {@code maxWidth}.</li>
218216
* </ul>
219217
*
220218
* <pre>
@@ -224,11 +222,11 @@ public class StringUtils {
224222
* StringUtils.abbreviate("abcdefg", 7) = "abcdefg"
225223
* StringUtils.abbreviate("abcdefg", 8) = "abcdefg"
226224
* StringUtils.abbreviate("abcdefg", 4) = "a..."
227-
* StringUtils.abbreviate("abcdefg", 3) = IllegalArgumentException
225+
* StringUtils.abbreviate("abcdefg", 3) = Throws {@link IllegalArgumentException}.
228226
* </pre>
229227
*
230-
* @param str the String to check, may be null.
231-
* @param maxWidth maximum length of result String, must be at least 4.
228+
* @param str the String to check, may be null.
229+
* @param maxWidth maximum length of result String, must be at least 4.
232230
* @return abbreviated String, {@code null} if null String input.
233231
* @throws IllegalArgumentException if the width is too small.
234232
* @since 2.0
@@ -238,7 +236,7 @@ public static String abbreviate(final String str, final int maxWidth) {
238236
}
239237

240238
/**
241-
* Abbreviates a String using ellipses. This will turn "Now is the time for all good men" into "...is the time for..."
239+
* Abbreviates a String using ellipses. This will convert "Now is the time for all good men" into "...is the time for...".
242240
*
243241
* <p>
244242
* Works like {@code abbreviate(String, int)}, but allows you to specify a "left edge" offset. Note that this left edge is not necessarily going to be the
@@ -260,8 +258,8 @@ public static String abbreviate(final String str, final int maxWidth) {
260258
* StringUtils.abbreviate("abcdefghijklmno", 8, 10) = "...ijklmno"
261259
* StringUtils.abbreviate("abcdefghijklmno", 10, 10) = "...ijklmno"
262260
* StringUtils.abbreviate("abcdefghijklmno", 12, 10) = "...ijklmno"
263-
* StringUtils.abbreviate("abcdefghij", 0, 3) = IllegalArgumentException
264-
* StringUtils.abbreviate("abcdefghij", 5, 6) = IllegalArgumentException
261+
* StringUtils.abbreviate("abcdefghij", 0, 3) = Throws {@link IllegalArgumentException}.
262+
* StringUtils.abbreviate("abcdefghij", 5, 6) = Throws {@link IllegalArgumentException}.
265263
* </pre>
266264
*
267265
* @param str the String to check, may be null.
@@ -276,15 +274,15 @@ public static String abbreviate(final String str, final int offset, final int ma
276274
}
277275

278276
/**
279-
* Abbreviates a String using another given String as replacement marker. This will turn "Now is the time for all good men" into "Now is the time for..." if
280-
* "..." was defined as the replacement marker.
277+
* Abbreviates a String using another given String as replacement marker. This will convert "Now is the time for all good men" into "Now is the time for..."
278+
* if "..." was defined as the replacement marker.
281279
*
282280
* <p>
283281
* Specifically:
284282
* </p>
285283
* <ul>
286284
* <li>If the number of characters in {@code str} is less than or equal to {@code maxWidth}, return {@code str}.</li>
287-
* <li>Else abbreviate it to {@code (substring(str, 0, max-abbrevMarker.length) + abbrevMarker)}.</li>
285+
* <li>Else abbreviate it to {@code (substring(str, 0, max - abbrevMarker.length) + abbrevMarker)}.</li>
288286
* <li>If {@code maxWidth} is less than {@code abbrevMarker.length + 1}, throw an {@link IllegalArgumentException}.</li>
289287
* <li>In no case will it return a String of length greater than {@code maxWidth}.</li>
290288
* </ul>
@@ -298,8 +296,8 @@ public static String abbreviate(final String str, final int offset, final int ma
298296
* StringUtils.abbreviate("abcdefg", ".", 8) = "abcdefg"
299297
* StringUtils.abbreviate("abcdefg", "..", 4) = "ab.."
300298
* StringUtils.abbreviate("abcdefg", "..", 3) = "a.."
301-
* StringUtils.abbreviate("abcdefg", "..", 2) = IllegalArgumentException
302-
* StringUtils.abbreviate("abcdefg", "...", 3) = IllegalArgumentException
299+
* StringUtils.abbreviate("abcdefg", "..", 2) = Throws {@link IllegalArgumentException}.
300+
* StringUtils.abbreviate("abcdefg", "...", 3) = Throws {@link IllegalArgumentException}.
303301
* </pre>
304302
*
305303
* @param str the String to check, may be null.
@@ -314,7 +312,7 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
314312
}
315313

316314
/**
317-
* Abbreviates a String using a given replacement marker. This will turn "Now is the time for all good men" into "...is the time for..." if "..." was
315+
* Abbreviates a String using a given replacement marker. This will convert "Now is the time for all good men" into "...is the time for..." if "..." was
318316
* defined as the replacement marker.
319317
*
320318
* <p>
@@ -335,15 +333,16 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
335333
* StringUtils.abbreviate("abcdefghijklmno", ",", 2, 10) = "abcdefghi,"
336334
* StringUtils.abbreviate("abcdefghijklmno", "::", 4, 10) = "::efghij::"
337335
* StringUtils.abbreviate("abcdefghijklmno", "...", 6, 10) = "...ghij..."
336+
* StringUtils.abbreviate("abcdefghijklmno", "…", 6, 10) = "…ghij…"
338337
* StringUtils.abbreviate("abcdefghijklmno", "*", 9, 10) = "*ghijklmno"
339338
* StringUtils.abbreviate("abcdefghijklmno", "'", 10, 10) = "'ghijklmno"
340339
* StringUtils.abbreviate("abcdefghijklmno", "!", 12, 10) = "!ghijklmno"
341-
* StringUtils.abbreviate("abcdefghij", "abra", 0, 4) = IllegalArgumentException
342-
* StringUtils.abbreviate("abcdefghij", "...", 5, 6) = IllegalArgumentException
340+
* StringUtils.abbreviate("abcdefghij", "abra", 0, 4) = Throws {@link IllegalArgumentException}.
341+
* StringUtils.abbreviate("abcdefghij", "...", 5, 6) = Throws {@link IllegalArgumentException}.
343342
* </pre>
344343
*
345344
* @param str the String to check, may be null.
346-
* @param abbrevMarker the String used as replacement marker.
345+
* @param abbrevMarker the String used as replacement marker, for example "...", or Unicode HORIZONTAL ELLIPSIS, U+2026 '…'.
347346
* @param offset left edge of source String.
348347
* @param maxWidth maximum length of result String, must be at least 4.
349348
* @return abbreviated String, {@code null} if null String input.

0 commit comments

Comments
 (0)