Class StringUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappend(StringBuilder buf, byte b, int base) Deprecated.append hex digitstatic voidappend(StringBuilder buf, String s, int offset, int length) Deprecated.Append substring to StringBuilderstatic voidappend2digits(StringBuffer buf, int i) Deprecated.Append 2 digits (zero padded) to the StringBufferstatic voidappend2digits(StringBuilder buf, int i) Deprecated.Append 2 digits (zero padded) to the StringBuilderstatic String[]Deprecated.Parse the string representation of a list usingcsvSplit(List, String, int, int)static StringDeprecated.fast lower case conversion.static StringDeprecated.fast upper case conversion.static String[]Deprecated.Parse a CSV string usingcsvSplit(List, String, int, int)static String[]Deprecated.Parse a CSV string usingcsvSplit(List, String, int, int)Deprecated.Split a quoted comma separated string to a liststatic booleanendsWithIgnoreCase(String s, String w) Deprecated.static booleanDeprecated.static byte[]Deprecated.static byte[]Deprecated.static byte[]Deprecated.static intDeprecated.returns the next index of a character from the chars stringstatic intDeprecated.Find the index of a control characters in Stringstatic booleanDeprecated.Test if a string is null or only has whitespace characters in it.static booleanDeprecated.Checks if a String is empty ("") or null.static booleanDeprecated.static booleanisNotBlank(String str) Deprecated.Test if a string is not null and contains at least 1 non-whitespace characters in it.static booleanDeprecated.static StringDeprecated.Return a non null string.static StringDeprecated.Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).static StringnormalizeCharset(String s, int offset, int length) Deprecated.Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).static Stringprintable(byte[] b) Deprecated.static StringDeprecated.static StringDeprecated.Replace chars within string.static StringDeprecated.Replace substrings within string.static StringreplaceFirst(String original, String target, String replacement) Deprecated.Replace first substrings within string.static StringDeprecated.Replace all characters from input string that are known to have special meaning in various filesystems.static StringsanitizeXmlString(String html) Deprecated.static StringsidBytesToString(byte[] sidBytes) Deprecated.static byte[]sidStringToBytes(String sidString) Deprecated.static booleanstartsWithIgnoreCase(String s, String w) Deprecated.static StringstringFrom(String s, int n) Deprecated.Generate a string from another string repeated n times.static StringDeprecated.static intDeprecated.Convert String to an integer.static longDeprecated.Convert String to an long.static StringDeprecated.static StringtoUTF8String(byte[] b, int offset, int length) Deprecated.static StringDeprecated.Truncate a string to a max size.static StringDeprecated.static StringDeprecated.The String value of an Object
-
Field Details
-
ALL_INTERFACES
Deprecated.- See Also:
-
CRLF
Deprecated.- See Also:
-
__LINE_SEPARATOR
Deprecated.useSystem.lineSeparator()instead -
__ISO_8859_1
Deprecated.- See Also:
-
__UTF8
Deprecated.- See Also:
-
__UTF16
Deprecated.- See Also:
-
lowercases
public static final char[] lowercasesDeprecated.
-
-
Constructor Details
-
StringUtil
public StringUtil()Deprecated.
-
-
Method Details
-
normalizeCharset
Deprecated.Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).- Parameters:
s- the charset to normalize- Returns:
- the normalized charset (or null if normalized version not found)
-
normalizeCharset
Deprecated.Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).- Parameters:
s- the charset to normalizeoffset- the offset in the charsetlength- the length of the charset in the input param- Returns:
- the normalized charset (or null if not found)
-
asciiToLowerCase
Deprecated.fast lower case conversion. Only works on ascii (not unicode)- Parameters:
s- the string to convert- Returns:
- a lower case version of s
-
asciiToUpperCase
Deprecated.fast upper case conversion. Only works on ascii (not unicode)- Parameters:
s- the string to convert- Returns:
- a lower case version of s
-
sanitizeFileSystemName
Deprecated.Replace all characters from input string that are known to have special meaning in various filesystems.This will replace all of the following characters with a "
_" (underscore).- Control Characters
- Anything not 7-bit printable ASCII
- Special characters: pipe, redirect, combine, slash, equivalence, bang, glob, selection, etc...
- Space
- Parameters:
str- the raw input string- Returns:
- the sanitized output string. or null if
stris null.
-
startsWithIgnoreCase
Deprecated. -
endsWithIgnoreCase
Deprecated. -
indexFrom
Deprecated.returns the next index of a character from the chars string- Parameters:
s- the input string to searchchars- the chars to look for- Returns:
- the index of the character in the input stream found.
-
replace
Deprecated.Replace chars within string.Fast replacement for
java.lang.String#String.replace(char, char)- Parameters:
str- the input stringfind- the char to look forwith- the char to replace with- Returns:
- the now replaced string
-
replace
Deprecated.Replace substrings within string.Fast replacement for
java.lang.String#String.replace(CharSequence, CharSequence)- Parameters:
s- the input stringsub- the string to look forwith- the string to replace with- Returns:
- the now replaced string
-
replaceFirst
Deprecated.Replace first substrings within string.Fast replacement for
java.lang.String#String.replaceFirst(String, String), but without Regex support.- Parameters:
original- the original stringtarget- the target string to look forreplacement- the replacement string to use- Returns:
- the replaced string
-
unquote
Deprecated.Remove single or double quotes.- Parameters:
s- the input string- Returns:
- the string with quotes removed
-
append
Deprecated.Append substring to StringBuilder- Parameters:
buf- StringBuilder to append tos- String to append fromoffset- The offset of the substringlength- The length of the substring
-
append
Deprecated.append hex digit- Parameters:
buf- the buffer to append tob- the byte to appendbase- the base of the hex output (almost always 16).
-
append2digits
Deprecated.Append 2 digits (zero padded) to the StringBuffer- Parameters:
buf- the buffer to append toi- the value to append
-
append2digits
Deprecated.Append 2 digits (zero padded) to the StringBuilder- Parameters:
buf- the buffer to append toi- the value to append
-
stringFrom
Deprecated.Generate a string from another string repeated n times.- Parameters:
s- the string to usen- the number of times this string should be appended
-
nonNull
Deprecated.Return a non null string.- Parameters:
s- String- Returns:
- The string passed in or empty string if it is null.
-
equals
Deprecated. -
toUTF8String
Deprecated. -
toString
Deprecated. -
indexOfControlChars
Deprecated.Find the index of a control characters in StringThis will return a result on the first occurrence of a control character, regardless if there are more than one.
Note: uses codepoint version of
Character.isISOControl(int)to support Unicode better.indexOfControlChars(null) == -1 indexOfControlChars("") == -1 indexOfControlChars("\r\n") == 0 indexOfControlChars("\t") == 0 indexOfControlChars(" ") == -1 indexOfControlChars("a") == -1 indexOfControlChars(".") == -1 indexOfControlChars(";\n") == 1 indexOfControlChars("abc\f") == 3 indexOfControlChars("z\010") == 1 indexOfControlChars(":") == 1- Parameters:
str- the string to test.- Returns:
- the index of first control character in string, -1 if no control characters encountered
-
isBlank
Deprecated.Test if a string is null or only has whitespace characters in it.Note: uses codepoint version of
Character.isWhitespace(int)to support Unicode better.isBlank(null) == true isBlank("") == true isBlank("\r\n") == true isBlank("\t") == true isBlank(" ") == true isBlank("a") == false isBlank(".") == false isBlank(";\n") == false- Parameters:
str- the string to test.- Returns:
- true if string is null or only whitespace characters, false if non-whitespace characters encountered.
-
isEmpty
Deprecated.Checks if a String is empty ("") or null.
isEmpty(null) == true isEmpty("") == true isEmpty("\r\n") == false isEmpty("\t") == false isEmpty(" ") == false isEmpty("a") == false isEmpty(".") == false isEmpty(";\n") == false- Parameters:
str- the string to test.- Returns:
- true if string is null or empty.
-
isNotBlank
Deprecated.Test if a string is not null and contains at least 1 non-whitespace characters in it.Note: uses codepoint version of
Character.isWhitespace(int)to support Unicode better.isNotBlank(null) == false isNotBlank("") == false isNotBlank("\r\n") == false isNotBlank("\t") == false isNotBlank(" ") == false isNotBlank("a") == true isNotBlank(".") == true isNotBlank(";\n") == true- Parameters:
str- the string to test.- Returns:
- true if string is not null and has at least 1 non-whitespace character, false if null or all-whitespace characters.
-
isUTF8
Deprecated. -
isHex
Deprecated. -
printable
Deprecated. -
printable
Deprecated. -
getBytes
Deprecated. -
getUtf8Bytes
Deprecated. -
getBytes
Deprecated. -
sidBytesToString
Deprecated.Converts a binary SID to a string SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn- Parameters:
sidBytes- the SID bytes to build from- Returns:
- the string SID
-
sidStringToBytes
Deprecated.Converts a string SID to a binary SID http://en.wikipedia.org/wiki/Security_Identifier S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn- Parameters:
sidString- the string SID- Returns:
- the binary SID
-
toInt
Deprecated.Convert String to an integer. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown- Parameters:
string- A String containing an integer.from- The index to start parsing from- Returns:
- an int
-
toLong
Deprecated.Convert String to an long. Parses up to the first non-numeric character. If no number is found an IllegalArgumentException is thrown- Parameters:
string- A String containing an integer.- Returns:
- an int
-
truncate
Deprecated.Truncate a string to a max size.- Parameters:
str- the string to possibly truncatemaxSize- the maximum size of the string- Returns:
- the truncated string. if
strparam is null, then the returned string will also be null.
-
arrayFromString
Deprecated.Parse the string representation of a list usingcsvSplit(List, String, int, int)- Parameters:
s- The string to parse, expected to be enclosed as '[...]'- Returns:
- An array of parsed values.
-
csvSplit
Deprecated.Parse a CSV string usingcsvSplit(List, String, int, int)- Parameters:
s- The string to parse- Returns:
- An array of parsed values.
-
csvSplit
Deprecated.Parse a CSV string usingcsvSplit(List, String, int, int)- Parameters:
s- The string to parseoff- The offset into the string to start parsinglen- The len in characters to parse- Returns:
- An array of parsed values.
-
csvSplit
Deprecated.Split a quoted comma separated string to a listHandle rfc4180-like CSV strings, with the exceptions:
- quoted values may contain double quotes escaped with back-slash
- Non-quoted values are trimmed of leading trailing white space
- trailing commas are ignored
- double commas result in a empty string value
- Parameters:
list- The Collection to split to (or null to get a new list)s- The string to parseoff- The offset into the string to start parsinglen- The len in characters to parse- Returns:
- list containing the parsed list values
-
sanitizeXmlString
Deprecated. -
strip
Deprecated. -
valueOf
Deprecated.The String value of an ObjectThis method calls
String.valueOf(Object)unless the object is null, in which case null is returned- Parameters:
object- The object- Returns:
- String value or null
-