Class CharArrayUtils

java.lang.Object
org.carrot2.util.CharArrayUtils

public class CharArrayUtils
extends Object
A number of useful methods for working with char [] arrays.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static char[] EMPTY_ARRAY  
  • Constructor Summary

    Constructors 
    Constructor Description
    CharArrayUtils()  
  • Method Summary

    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)
    Returns true 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 into buffer.
    static boolean toLowerCase​(char[] word, char[] buffer, int start, int length)
    Convert to lower case (character-by-character) and save the result into buffer.
    static char[] toLowerCaseCopy​(char[] array)
    To lower case conversion.
    static char[] toLowerCaseInPlace​(char[] array)
    In place to lower case conversion.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • 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)
      Returns true 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 into buffer.
      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 between word and buffer. false indicates an identical copy.
      Throws:
      AssertionError - If buffer is smaller than word.
    • toLowerCase

      public static boolean toLowerCase​(char[] word, char[] buffer, int start, int length)
      Convert to lower case (character-by-character) and save the result into buffer. The buffer must have at least length characters.
      Parameters:
      word - The word to be converted to lower case.
      buffer - The buffer where the result should be saved.
      start - the index in the word at which to start
      length - the number of characters from word to process
      Returns:
      Returns true if at least one character was changed between word and buffer. false indicates an identical copy.
      Throws:
      AssertionError - If buffer is smaller than length.
      AssertionError - If start + length is smaller than the length word .