Class StringCase

java.lang.Object
com.github.sttk.stringcase.StringCase

public final class StringCase extends Object
Is the class that provides the static methods to convert a string to following cases.
  • Ada_Case
  • camelCase
  • COBOL-CASE
  • kebab-case
  • MACRO_CASE
  • PascalCase
  • snake_case
  • Title Case
  • Train-Case
Since:
1.0
  • Method Details

    • upperize

      public static String upperize(String input, char joiner, Options opts)
      Converts all ASCII alphabetic characters in the input string to uppercase, inserting the specified joiner char between word boundaries according to the given options. It serves as a core engine for transforming input strings into uppercase-based casing styles, such as MACRO_CASE or COBOL-CASE, using custom joiner chars and customizable word separation rules defined in Options.

      During conversion, all ASCII lowercase letters are converted to ASCII uppercase letters, and word boundaries are automatically recognized between casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner char.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • upperize

      public static String upperize(String input, int joiner, Options opts)
      Converts all ASCII alphabetic characters in the input string to uppercase, inserting the specified joiner code point between word boundaries according to the given options. It serves as a core engine for transforming input strings into uppercase-based casing styles, such as MACRO_CASE or COBOL-CASE, using custom joiner code points and customizable word separation rules defined in Options.

      During conversion, all ASCII lowercase letters are converted to ASCII uppercase letters, and word boundaries are automatically recognized between casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner code point.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • lowerize

      public static String lowerize(String input, char joiner, Options opts)
      Converts all ASCII alphabetic characters in the input string to lowercase, inserting the specified joiner char between word boundaries according to the given options. It serves as a core engine for transforming input strings into lowercase-based casing styles, such as snake_case or kebab-case, using custom joiner chars and customizable word separation rules defined in Options.

      During conversion, all ASCII uppercase letters are converted to ASCII lowercase letters, and word boundaries are automatically recognized between casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner char.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • lowerize

      public static String lowerize(String input, int joiner, Options opts)
      Converts all ASCII alphabetic characters in the input string to lowercase, inserting the specified joiner code point between word boundaries according to the given options. It serves as a core engine for transforming input strings into lowercase-based casing styles, such as snake_case or kebab-case, using custom joiner code points and customizable word separation rules defined in Options.

      During conversion, all ASCII uppercase letters are converted to ASCII lowercase letters, and word boundaries are automatically recognized between casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner code point.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • capitalize

      public static String capitalize(String input, char joiner, Options opts)
      Converts the input string by capitalizing the first ASCII letter of each word and lowercasing subsequent letters, inserting the specified joiner char between word boundaries according to the given options. It serves as a core engine for transforming input strings into capitalized casing styles, such as Train-Case or PascalCase, using custom joiner codes and customizable word separation rules defined in Options.

      During conversion, the initial ASCII letter of each word is converted to ASCII uppercase, while subsequent ASCII letters in that word are converted to ASCII lowercase. Word boundaries are automatically recognized at casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner char.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • capitalize

      public static String capitalize(String input, int joiner, Options opts)
      Converts the input string by capitalizing the first ASCII letter of each word and lowercasing subsequent letters, inserting the specified joiner code point between word boundaries according to the given options. It serves as a core engine for transforming input strings into capitalized casing styles, such as Train-Case or PascalCase, using custom joiner code points and customizable word separation rules defined in Options.

      During conversion, the initial ASCII letter of each word is converted to ASCII uppercase, while subsequent ASCII letters in that word are converted to ASCII lowercase. Word boundaries are automatically recognized at casing transitions, such as between lowercase and uppercase letters or before the final uppercase letter of an acronym preceding a lowercase sequence. When non-alphanumeric characters are encountered, ASCII digits are kept by default, while other characters are evaluated against Options. If opts.Separators is non-empty, characters matching opts.Separators are removed as separators while other non-alphanumeric characters are kept; otherwise, if opts.Keep is non-empty, specified characters are kept and all other non-alphanumeric characters are removed. If neither is specified, all non-alphanumeric characters are treated as separators and removed. The fields opts.SeparateBeforeNonAlphabets and opts.SeparateAfterNonAlphabets further determine whether word boundaries are inserted before or after non-alphabetic sequences.

      This static method never throws an exception on any input, returning an empty string when the input is empty. Casing transformations and word boundary detections apply strictly to ASCII letters, treating non-ASCII characters as non-alphanumeric. If both opts.Separators and opts.Keep are specified, opts.Separators takes precedence and opts.Keep is ignored, while any alphanumeric characters listed in either field are disregarded. Additionally, leading and trailing separator characters are trimmed from the result without producing leading or trailing joiners.

      Parameters:
      input - The input string.
      joiner - A joiner code point.
      opts - The Options object which holds the fields to customize separation rules.
      Returns:
      The converted string.
    • camelCaseWithOptions

      public static String camelCaseWithOptions(String input, Options opts)
      Converts the input string to camel case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to camel case.
    • camelCase

      public static String camelCase(String input)
      Converts the input string to camel case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to camel case.
    • cobolCaseWithOptions

      public static String cobolCaseWithOptions(String input, Options opts)
      Converts the input string to cobol case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to cobol case.
    • cobolCase

      public static String cobolCase(String input)
      Converts the input string to cobol case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to cobol case.
    • kebabCaseWithOptions

      public static String kebabCaseWithOptions(String input, Options opts)
      Converts the input string to kebab case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to kebab case.
    • kebabCase

      public static String kebabCase(String input)
      Converts the input string to kebab case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to kebab case.
    • macroCaseWithOptions

      public static String macroCaseWithOptions(String input, Options opts)
      Converts the input string to macro case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to macro case.
    • macroCase

      public static String macroCase(String input)
      Converts the input string to macro case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to macro case.
    • pascalCaseWithOptions

      public static String pascalCaseWithOptions(String input, Options opts)
      Converts the input string to pascal case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to pascal case.
    • pascalCase

      public static String pascalCase(String input)
      Converts the input string to pascal case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to pascal case.
    • snakeCaseWithOptions

      public static String snakeCaseWithOptions(String input, Options opts)
      Converts the input string to snake case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to snake case.
    • snakeCase

      public static String snakeCase(String input)
      Converts the input string to snake case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to snake case.
    • trainCaseWithOptions

      public static String trainCaseWithOptions(String input, Options opts)
      Converts the input string to train case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to train case.
    • trainCase

      public static String trainCase(String input)
      Converts the input string to train case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to train case.
    • adaCaseWithOptions

      public static String adaCaseWithOptions(String input, Options opts)
      Converts the input string to Ada case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to Ada case.
    • adaCase

      public static String adaCase(String input)
      Converts the input string to Ada case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to Ada case.
    • titleCaseWithOptions

      public static String titleCaseWithOptions(String input, Options opts)
      Converts the input string to title case with the specified options.
      Parameters:
      input - The input string.
      opts - The options which specifies the ways of case conversion.
      Returns:
      A string converted to title case.
    • titleCase

      public static String titleCase(String input)
      Converts the input string to title case.

      It treats the end of a sequence of non-alphabetical characters as a word boundary, but not the beginning.

      Parameters:
      input - The input string.
      Returns:
      A string converted to title case.