APIdia Launch Partner
Top Description Constructors Methods
io.github.spannm.jackcess.util

public final Class StringUtil

extends Object
Class Inheritance
Imports
java.nio.CharBuffer, java.text.BreakIterator, java.util.Locale, java.util.stream.IntStream

Static utility methods for null-safe String operations.

The class prefers interface CharSequence for inputs over String whenever possible, so that all implementations (e.g. StringBuffer, StringBuilder, CharBuffer) can benefit.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String
capitalize(String str)

Capitalizes a string changing its first character to title case as per Character#toTitleCase(int).

public static String
capitalizeFully(String text, Locale locale)

Converts every word in the given text to title case (first letter upper-cased via Character#toTitleCase(int), remainder lower-cased), using the given Locale for both case conversions and for locating word boundaries via BreakIterator.

public static boolean
isBlank(CharSequence cs)

Returns true if the given char sequence is null or all blank space, false otherwise.

public static boolean

Returns:

true if char sequence is empty or null, false otherwise
isEmpty
(CharSequence
char sequence to test
cs
)

Checks if the given char sequence is either null or empty.

public static int

Returns:

length of string
length
(CharSequence
string
cs
)

Gets the given char sequence's length or 0 if it is null.

public static String

Returns:

modified input
remove
(CharSequence
the character sequence to remove from
cs
,
CharSequence
the character sequence to remove
remove
)

Removes all occurrences of character sequence remove from string cs.

public static String
repeat(String str, int count)

Returns a string whose value is the concatenation of the given string repeated count times.

public static String
replace(String text, CharSequence searchString, CharSequence replacement)

public static boolean

Returns:

true if neither argument is null and str starts with prefix ignoring case
startsWithIgnoreCase
(String
string to test, may be null
str
,
String
prefix to look for, may be null
prefix
)

Checks case-insensitively whether the given string starts with the given prefix.

public static String
toTitleCase(String str)

Converts a string to "title case", a type of capitalization in which the first letter of a word (following an underscore) except in position 0 is capitalized, underscores are removed, and the rest of the letters are lower-case.

public static String
trimToNull(CharSequence cs)

Returns the given char sequence trimmed or null if the string is null or empty.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringUtilback to summary
private StringUtil()

Method Detail

capitalizeback to summary
public static String capitalize(String str)

Capitalizes a string changing its first character to title case as per Character#toTitleCase(int).

capitalizeFullyback to summary
public static String capitalizeFully(String text, Locale locale)

Converts every word in the given text to title case (first letter upper-cased via Character#toTitleCase(int), remainder lower-cased), using the given Locale for both case conversions and for locating word boundaries via BreakIterator. Unlike a naive single-space split, this correctly handles runs of whitespace, punctuation-adjacent words, and locale-specific word-boundary/case rules (e.g. Turkish dotted/dotless i).

isBlankback to summary
public static boolean isBlank(CharSequence cs)

Returns true if the given char sequence is null or all blank space, false otherwise.

isEmptyback to summary
public static boolean isEmpty(CharSequence cs)

Checks if the given char sequence is either null or empty.

Parameters
cs:CharSequence

char sequence to test

Returns:boolean

true if char sequence is empty or null, false otherwise

lengthback to summary
public static int length(CharSequence cs)

Gets the given char sequence's length or 0 if it is null.

Parameters
cs:CharSequence

string

Returns:int

length of string

removeback to summary
public static String remove(CharSequence cs, CharSequence remove)

Removes all occurrences of character sequence remove from string cs.

Parameters
cs:CharSequence

the character sequence to remove from

remove:CharSequence

the character sequence to remove

Returns:String

modified input

repeatback to summary
public static String repeat(String str, int count)

Returns a string whose value is the concatenation of the given string repeated count times.

replaceback to summary
public static String replace(String text, CharSequence searchString, CharSequence replacement)
startsWithIgnoreCaseback to summary
public static boolean startsWithIgnoreCase(String str, String prefix)

Checks case-insensitively whether the given string starts with the given prefix.

Parameters
str:String

string to test, may be null

prefix:String

prefix to look for, may be null

Returns:boolean

true if neither argument is null and str starts with prefix ignoring case

toTitleCaseback to summary
public static String toTitleCase(String str)

Converts a string to "title case", a type of capitalization in which the first letter of a word (following an underscore) except in position 0 is capitalized, underscores are removed, and the rest of the letters are lower-case.

trimToNullback to summary
public static String trimToNull(CharSequence cs)

Returns the given char sequence trimmed or null if the string is null or empty.