Package org.carrot2.util
Class CharArrayUtils
- java.lang.Object
-
- org.carrot2.util.CharArrayUtils
-
public class CharArrayUtils extends Object
A number of useful methods for working withchar []
arrays.
-
-
Field Summary
Fields Modifier and Type Field Description static char[]
EMPTY_ARRAY
-
Constructor Summary
Constructors Constructor Description CharArrayUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static float
getCapitalizedRatio(char[] string)
Computes and returns the ratio of capitalized letters in the string to the numbers of all letters.static boolean
hasCapitalizedLetters(char[] string)
Returnstrue
if the input array contains any capitalized characters.static char[]
toCapitalizedCopy(char[] string)
Returns a capitalized copy of the input character array.static boolean
toLowerCase(char[] word, char[] buffer)
Convert to lower case (character-by-character) and save the result intobuffer
.static boolean
toLowerCase(char[] word, char[] buffer, int start, int length)
Convert to lower case (character-by-character) and save the result intobuffer
.static char[]
toLowerCaseCopy(char[] array)
To lower case conversion.static char[]
toLowerCaseInPlace(char[] array)
In place to lower case conversion.
-
-
-
Method Detail
-
toLowerCaseInPlace
public static char[] toLowerCaseInPlace(char[] array)
In place to lower case conversion. In input array is returned for convenience.
-
toLowerCaseCopy
public static char[] toLowerCaseCopy(char[] array)
To lower case conversion. A copy of the input array will be created.
-
getCapitalizedRatio
public static float getCapitalizedRatio(char[] string)
Computes and returns the ratio of capitalized letters in the string to the numbers of all letters.
-
hasCapitalizedLetters
public static boolean hasCapitalizedLetters(char[] string)
Returnstrue
if the input array contains any capitalized characters.
-
toCapitalizedCopy
public static char[] toCapitalizedCopy(char[] string)
Returns a capitalized copy of the input character array.
-
toLowerCase
public static boolean toLowerCase(char[] word, char[] buffer)
Convert to lower case (character-by-character) and save the result intobuffer
.- Parameters:
word
- The word to be converted to lower case.buffer
- The buffer where the result should be saved.- Returns:
- Returns
true
if at least one character was changed betweenword
andbuffer
.false
indicates an identical copy. - Throws:
AssertionError
- Ifbuffer
is smaller thanword
.
-
toLowerCase
public static boolean toLowerCase(char[] word, char[] buffer, int start, int length)
Convert to lower case (character-by-character) and save the result intobuffer
. The buffer must have at leastlength
characters.- Parameters:
word
- The word to be converted to lower case.buffer
- The buffer where the result should be saved.start
- the index in theword
at which to startlength
- the number of characters fromword
to process- Returns:
- Returns
true
if at least one character was changed betweenword
andbuffer
.false
indicates an identical copy. - Throws:
AssertionError
- Ifbuffer
is smaller thanlength
.AssertionError
- Ifstart + length
is smaller than the lengthword
.
-
-