| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.util.Strings |
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Strings() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static String[] |
decodeArray(String s)
Decode an encoded array of strings.
| ||||||||||
| static List<String> |
decodeList(String s)
Decode an encoded list of strings.
| ||||||||||
| static Map<String, String> |
decodeMap(String s)
Decode an encoded map of strings to strings.
| ||||||||||
| static String |
decodeUTF8(byte[] bytes)
Decode a byte buffer using UTF-8.
| ||||||||||
| static String |
decodeUTF8(byte[] bytes, int offset, int length)
Decode a byte buffer using UTF-8.
| ||||||||||
| static String |
encodeArray(String[] array)
Encode an array of strings.
| ||||||||||
| static String |
encodeList(List<String> list)
Encode a list of strings.
| ||||||||||
| static String |
encodeMap(Map<String, String> map)
Encode a map of strings to strings.
| ||||||||||
| static byte[] |
encodeUTF8(String s)
Encode a string using UTF-8.
| ||||||||||
| static boolean |
equals(String a, String b)
A safer version of
equals(Object). | ||||||||||
| static boolean |
equalsIgnoreCase(String a, String b)
A safer version of
equalsIgnoreCase(String) | ||||||||||
| static String |
generate(char c, int count)
Generate a repeated-character string.
| ||||||||||
| static int |
getAsciiLength(byte[] data)
Retrieve the length of the potential String is the data byte array.
| ||||||||||
| static boolean |
hasBlank(CharSequence s)
Determine if a string contains one or more WSP characters.
| ||||||||||
| static boolean |
isBlank(String s)
Determine if a string is null, empty, or contains WSP chars exclusively.
| ||||||||||
| static boolean |
isContainedIn(String s, String... elts)
Determine if a string is contained in an var-arg list of provided strings.
| ||||||||||
| static String |
join(String separator, Object... objects)
Join the string representations of a sequence of objects using the provided separator.
| ||||||||||
| static String |
join(String separator, Iterable<?> iterator)
Join the string representations of a sequence of objects using the provided separator.
| ||||||||||
| static String |
joinList(Iterable<?> objects)
Join the elements of a list using "," as a separator and surround the resulting string with
square brackets.
| ||||||||||
| static String |
ltrim(String s)
Left trim: A leading-characters-only version of
trim(). | ||||||||||
| static String |
parseUrlParameter(String s, String entry)
Same as
parseUrlParameters(String, String...) with a single entry. | ||||||||||
| static String[] |
parseUrlParameters(String s, String... entries)
Extract the parameters of a URL-like encoded string.
| ||||||||||
| static String |
replaceNewLines(String s, String repl)
Replace newline characters.
| ||||||||||
| static String |
rtrim(String s)
Right trim: A trailing-characters-only version of
trim(). | ||||||||||
| static String |
safe(Object s)
Get the string representation of the parameter object, or the empty string if the object is
null.
| ||||||||||
| static String |
safe(Object s, String def)
Get the string representation of the parameter object, or the provided string if the object
is null.
| ||||||||||
| static String |
safe2(Object s, String def)
Get the string representation of the parameter object, or the provided non-empty string if
the object is null or its string representation is the empty string.
| ||||||||||
| static int |
search(String data, int begin, String pattern, boolean caseSensitive, boolean reverseSearch)
Search a substring inside a bigger string.
| ||||||||||
| static String[] |
splitLines(String s)
Split a text into an array of Lines.
| ||||||||||
| static String |
toString(Object o)
A safe version of
String.toString. | ||||||||||
| static String |
urldecodeUTF8(String s)
Decode a
URL-encoded string. | ||||||||||
| static String |
urlencodeUTF8(String s)
Urlencode a string.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Decode an encoded array of strings.
| s | the encoded array |
|---|
Decode an encoded list of strings.
| s | optional encoded list |
|---|
Decode an encoded map of strings to strings.
| s | optional encoded map |
|---|
Decode a byte buffer using UTF-8. If UTF-8 is not available, the byte buffer is decoded using the system's default decoder.
| bytes | mandatory byte buffer |
|---|
Decode a byte buffer using UTF-8. If UTF-8 is not available, the byte buffer is decoded using the system's default decoder.
| bytes | byte buffer |
|---|---|
| offset | start offset |
| length | count of bytes to be decoded |
Encode an array of strings.
| array | the array of strings |
|---|
Encode a list of strings.
| list | the list of strings |
|---|
Encode a map of strings to strings.
| map | the map |
|---|
Encode a string using UTF-8. If UTF-8 is not available, the string is encoded using the system's default encoder. This should never happen.
| s | mandatory string |
|---|
A safer version of equals(Object).
| a | first string, may be null |
|---|---|
| b | second string, may be null |
A safer version of equalsIgnoreCase(String)
| a | first string, may be null |
|---|---|
| b | second string, may be null |
Generate a repeated-character string.
| c | character to repeat |
|---|---|
| count | repeat count (ie, string length) |
Retrieve the length of the potential String is the data byte array. The String characters allowed are contained between 0x20 and 0x7F.
| data | byte array representing String |
|---|
Determine if a string contains one or more WSP characters.
Determine if a string is null, empty, or contains WSP chars exclusively.
This method is deprecated and left out for compatibility reason only. Use #isBlank(CharSequence) instead.
| s | the string |
|---|
Determine if a string is contained in an var-arg list of provided strings.
| s | string to be searched |
|---|---|
| elts | the list of elements |
Join the string representations of a sequence of objects using the provided separator. Null objects will be formatted as "null".
This method is error-prone and was deprecated
| separator | a non-null separator |
|---|---|
| objects | a sequence of objects |
Join the string representations of a sequence of objects using the provided separator. Null objects will be formatted as "null".
| separator | a non-null separator |
|---|---|
| iterator | an iterator |
Join the elements of a list using "," as a separator and surround the resulting string with
square brackets. Careful, this method does not abide to the common semantic of
join.
| objects | a list of objects |
|---|
Same as parseUrlParameters(String, String...) with a single entry.
| s | the URL-like string to be parsed, containing a single key-value pair, eg
hometype=house |
|---|
Extract the parameters of a URL-like encoded string. No decoding is taking place. Example:
- s: "type=home&subtype=house&[another_key]=[another_value]" - entries: "type", "subtype" - returns: ["home", "house"]
| s | the string to be parsed |
|---|---|
| entries | the entries, whose count must match the number of key-value pairs |
Replace newline characters. This method accepts null strings as input.
| s | a string or null; in the latter case, null will be returned |
|---|---|
| repl | the non-null substitution string |
Get the string representation of the parameter object, or the empty string if the object is null.
| s | an object, possibly null |
|---|
toString() representation, or the empty string
Get the string representation of the parameter object, or the provided string if the object is null.
| s | an object, possibly null |
|---|---|
| def | a non-null string |
Get the string representation of the parameter object, or the provided non-empty string if the object is null or its string representation is the empty string.
| s | an object, possibly null |
|---|---|
| def | a non-null, non-empty string |
Search a substring inside a bigger string.
| data | buffer to be searched (aka, the haystack) |
|---|---|
| begin | where to start in the case of a forward search, where to end in the case of a backward/reverse search |
| pattern | text that is being searched (aka, the needle) |
| caseSensitive | search is case-sensitibe |
| reverseSearch | search is reverse |
Split a text into an array of Lines. Empty lines are returned. The final new-line character(s) are trimmed off. Works for all new lines characters (\r, \n) or sequences of characters (\r\n)
| s | mandatory input string |
|---|
A safe version of String.toString.
| o | an object, could be null |
|---|
Urlencode a string. The resulting string will have the following characteristics:
| s | the string to be encoded |
|---|