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 floatgetCapitalizedRatio(char[] string)Computes and returns the ratio of capitalized letters in the string to the numbers of all letters.static booleanhasCapitalizedLetters(char[] string)Returnstrueif the input array contains any capitalized characters.static char[]toCapitalizedCopy(char[] string)Returns a capitalized copy of the input character array.static booleantoLowerCase(char[] word, char[] buffer)Convert to lower case (character-by-character) and save the result intobuffer.static booleantoLowerCase(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)
Returnstrueif 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
trueif at least one character was changed betweenwordandbuffer.falseindicates an identical copy. - Throws:
AssertionError- Ifbufferis 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 leastlengthcharacters.- Parameters:
word- The word to be converted to lower case.buffer- The buffer where the result should be saved.start- the index in thewordat which to startlength- the number of characters fromwordto process- Returns:
- Returns
trueif at least one character was changed betweenwordandbuffer.falseindicates an identical copy. - Throws:
AssertionError- Ifbufferis smaller thanlength.AssertionError- Ifstart + lengthis smaller than the lengthword.
-
-