java.lang.Object
org.cybergarage.util.StringUtil
Utility class for string manipulation and conversion operations. This class provides static methods for string validation, type conversion, character searching, and custom trimming operations.
Constructor Summary
ConstructorsConstructorDescriptionEvery validator, converter and trimmer below is static, so an instance carries nothing.Method Summary
All MethodsModifier and TypeMethodDescriptionstatic final intfindFirstNotOf(String str, String chars) Finds the first character that is NOT in the specified character set.static final intfindFirstOf(String str, String chars) Finds the first occurrence of any character from the specified set.static final intfindLastNotOf(String str, String chars) Finds the last character that is NOT in the specified character set.static final intfindLastOf(String str, String chars) Finds the last occurrence of any character from the specified set.static final intGeneric character finding method with customizable search parameters.static final booleanChecks if a string contains valid data (not null and not empty).static final intConverts a string to an integer value.static final longConverts a string to a long value.static final StringTrims specified characters from both ends of a string.
Constructor Details
StringUtil
public StringUtil()Every validator, converter and trimmer below is static, so an instance carries nothing.
Method Details
hasData
Checks if a string contains valid data (not null and not empty).- Parameters:
value- the string to check- Returns:
- true if the string is not null and has length > 0, false otherwise
toInteger
Converts a string to an integer value.- Parameters:
value- the string to convert- Returns:
- the integer value, or 0 if conversion fails
toLong
Converts a string to a long value.- Parameters:
value- the string to convert- Returns:
- the long value, or 0 if conversion fails
findOf
public static final int findOf(String str, String chars, int startIdx, int endIdx, int offset, boolean isEqual) Generic character finding method with customizable search parameters.- Parameters:
str- the string to search inchars- the characters to search forstartIdx- the starting indexendIdx- the ending indexoffset- the search direction (1 for forward, -1 for backward)isEqual- true to find matching characters, false to find non-matching- Returns:
- the index of the found character, or -1 if not found
findFirstOf
findFirstNotOf
findLastOf
findLastNotOf
trim