Skip to content

Commit 81edf56

Browse files
committed
Improve javadoc
1 parent 89f7f45 commit 81edf56

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,11 @@ private UTF8String copyUTF8String(int start, int end) {
529529
return UTF8String.fromBytes(newBytes);
530530
}
531531

532+
/**
533+
* Trims space characters (ASCII 32) from both ends of this string.
534+
*
535+
* @return this string with no spaces at the start or end
536+
*/
532537
public UTF8String trim() {
533538
int s = 0;
534539
// skip all of the space (0x20) in the left side
@@ -548,11 +553,11 @@ public UTF8String trim() {
548553
}
549554

550555
/**
551-
* Based on the given trim string, trim this string starting from both ends
552-
* This method searches for each character in the source string, removes the character if it is
553-
* found in the trim string, stops at the first not found. It calls the trimLeft first, then
554-
* trimRight. It returns a new string in which both ends trim characters have been removed.
556+
* Trims instances of the given trim string from both ends of this string.
557+
*
555558
* @param trimString the trim character string
559+
* @return this string with no occurrences of the trim string at the start or end, or `null`
560+
* if `trimString` is `null`
556561
*/
557562
public UTF8String trim(UTF8String trimString) {
558563
if (trimString != null) {
@@ -562,6 +567,11 @@ public UTF8String trim(UTF8String trimString) {
562567
}
563568
}
564569

570+
/**
571+
* Trims space characters (ASCII 32) from the start of this string.
572+
*
573+
* @return this string with no spaces at the start
574+
*/
565575
public UTF8String trimLeft() {
566576
int s = 0;
567577
// skip all of the space (0x20) in the left side
@@ -578,11 +588,11 @@ public UTF8String trimLeft() {
578588
}
579589

580590
/**
581-
* Based on the given trim string, trim this string starting from left end
582-
* This method searches each character in the source string starting from the left end, removes
583-
* the character if it is in the trim string, stops at the first character which is not in the
584-
* trim string, returns the new string.
591+
* Trims instances of the given trim string from the start of this string.
592+
*
585593
* @param trimString the trim character string
594+
* @return this string with no occurrences of the trim string at the start, or `null`
595+
* if `trimString` is `null`
586596
*/
587597
public UTF8String trimLeft(UTF8String trimString) {
588598
if (trimString == null) return null;
@@ -615,6 +625,11 @@ public UTF8String trimLeft(UTF8String trimString) {
615625
return copyUTF8String(trimIdx, numBytes - 1);
616626
}
617627

628+
/**
629+
* Trims space characters (ASCII 32) from the end of this string.
630+
*
631+
* @return this string with no spaces at the end
632+
*/
618633
public UTF8String trimRight() {
619634
int e = numBytes - 1;
620635
// skip all of the space (0x20) in the right side
@@ -631,11 +646,11 @@ public UTF8String trimRight() {
631646
}
632647

633648
/**
634-
* Based on the given trim string, trim this string starting from right end
635-
* This method searches each character in the source string starting from the right end,
636-
* removes the character if it is in the trim string, stops at the first character which is not
637-
* in the trim string, returns the new string.
649+
* Trims instances of the given trim string from the end of this string.
650+
*
638651
* @param trimString the trim character string
652+
* @return this string with no occurrences of the trim string at the end, or `null`
653+
* if `trimString` is `null`
639654
*/
640655
public UTF8String trimRight(UTF8String trimString) {
641656
if (trimString == null) return null;

0 commit comments

Comments
 (0)