Package com.pnfsoftware.jeb.util.format
Class CharSequences
java.lang.Object
com.pnfsoftware.jeb.util.format.CharSequences
Utility methods for character sequences.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intindexOf(CharSequence text, char c) Implementation ofindexOffor CharSequence.static intindexOf(CharSequence text, char c, int from) Implementation ofindexOffor CharSequence.static intindexOf2(CharSequence text, char c0, char c1) Find the first one of two characters and return its position.static intindexOfn(CharSequence text, char... cs) Find the first one of n characters and return its position.static booleanDetermine if a character sequence is null, empty, or contains WSP chars exclusively.static booleanstartsWith(CharSequence text, String prefix) static booleanstartsWith(CharSequence text, String prefix, boolean trim) Tests if this character sequence starts with the specified prefix.static byte[]toByteArray(char[] chars) Convert a char[] to a byte[] using the system-default charset.
-
Constructor Details
-
CharSequences
public CharSequences()
-
-
Method Details
-
toByteArray
public static byte[] toByteArray(char[] chars) Convert a char[] to a byte[] using the system-default charset.- Parameters:
chars- char[] to be converted- Returns:
- the byte[]
-
isBlank
Determine if a character sequence is null, empty, or contains WSP chars exclusively.- Parameters:
s- the character sequence- Returns:
- true if the sequence is null or blank
-
indexOf
Implementation ofindexOffor CharSequence. Same behavior asString.indexOf(int).- Parameters:
text- the character sequencec- char- Returns:
- the index position, or -1 if not found
-
indexOf
Implementation ofindexOffor CharSequence. Same behavior asString.indexOf(int).- Parameters:
text- the character sequencec- charfrom- first index to start from- Returns:
- the index position, or -1 if not found
-
indexOf2
Find the first one of two characters and return its position.- Parameters:
text- the character sequencec0- first charc1- second char- Returns:
- the position of the first occurrence of c0 or c1 (whichever came first), -1 if not found
-
indexOfn
Find the first one of n characters and return its position.- Parameters:
text- stringcs- characters- Returns:
- the position of the first occurrence of any char (whichever came first), -1 if not found
-
startsWith
-
startsWith
Tests if this character sequence starts with the specified prefix.- Parameters:
text- the main character sequenceprefix- the prefix tokentrim- act as a trimmed string: ignore preceding spaces- Returns:
trueif the string is a prefix of the main character sequence
-