|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object htsjdk.samtools.util.StringUtil
public class StringUtil
Grab-bag of stateless String-oriented utilities.
Field Summary | |
---|---|
static java.lang.String |
EMPTY_STRING
Returns Object.toString() of the provided value if it isn't null; "" otherwise. |
Constructor Summary | |
---|---|
StringUtil()
|
Method Summary | ||
---|---|---|
static java.lang.String |
asEmptyIfNull(java.lang.Object string)
|
|
static java.lang.String |
assertCharactersNotInString(java.lang.String illegalChars,
char... chars)
Checks that a String doesn't contain one or more characters of interest. |
|
static java.lang.String |
bytesToHexString(byte[] data)
Convert a byte array into a String hex representation. |
|
static java.lang.String |
bytesToString(byte[] data)
|
|
static java.lang.String |
bytesToString(byte[] buffer,
int offset,
int length)
|
|
static char |
byteToChar(byte b)
Convert ASCII byte to ASCII char. |
|
static void |
charsToBytes(char[] chars,
int charOffset,
int length,
byte[] bytes,
int byteOffset)
Convert chars to bytes merely by casting |
|
static byte |
charToByte(char c)
Convert ASCII char to byte. |
|
static int |
fromHexDigit(char c)
|
|
static byte[] |
hexStringToBytes(java.lang.String s)
Convert a String containing hex characters into an array of bytes with the binary representation of the hex string |
|
static java.lang.String |
intValuesToString(int[] intVals)
|
|
static java.lang.String |
intValuesToString(short[] shortVals)
|
|
static boolean |
isBlank(java.lang.String str)
Checks if a String is whitespace, empty ("") or null. |
|
static
|
join(java.lang.String separator,
java.util.Collection<T> objs)
|
|
static
|
join(java.lang.String separator,
T... objs)
|
|
static int |
levenshteinDistance(java.lang.String string1,
java.lang.String string2,
int swap,
int substitution,
int insertion,
int deletion)
|
|
static java.lang.String |
readNullTerminatedString(BinaryCodec binaryCodec)
|
|
static java.lang.String |
repeatCharNTimes(char c,
int repeatNumber)
|
|
static java.lang.String |
reverseString(java.lang.String s)
Reverse the given string. |
|
static int |
split(java.lang.String aString,
java.lang.String[] tokens,
char delim)
Split the string into tokens separated by the given delimiter. |
|
static int |
splitConcatenateExcessTokens(java.lang.String aString,
java.lang.String[] tokens,
char delim)
Split the string into tokens separated by the given delimiter. |
|
static byte[] |
stringToBytes(java.lang.String s)
|
|
static byte[] |
stringToBytes(java.lang.String s,
int offset,
int length)
|
|
static char |
toHexDigit(int value)
|
|
static byte |
toLowerCase(byte b)
|
|
static byte |
toUpperCase(byte b)
|
|
static void |
toUpperCase(byte[] bytes)
Converts in place all lower case letters to upper case in the byte array provided. |
|
static java.lang.String |
wordWrap(java.lang.String s,
int maxLineLength)
Return input string with newlines inserted to ensure that all lines have length <= maxLineLength. |
|
static java.lang.String |
wordWrapSingleLine(java.lang.String s,
int maxLineLength)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String EMPTY_STRING
Object.toString()
of the provided value if it isn't null; "" otherwise.
Constructor Detail |
---|
public StringUtil()
Method Detail |
---|
public static <T> java.lang.String join(java.lang.String separator, java.util.Collection<T> objs)
separator
- String to interject between each string in strings argobjs
- List of objs to be joined
public static <T> java.lang.String join(java.lang.String separator, T... objs)
public static int split(java.lang.String aString, java.lang.String[] tokens, char delim)
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokens
public static int splitConcatenateExcessTokens(java.lang.String aString, java.lang.String[] tokens, char delim)
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokens
public static byte toLowerCase(byte b)
b
- ASCII character
public static byte toUpperCase(byte b)
b
- ASCII character
public static void toUpperCase(byte[] bytes)
public static java.lang.String assertCharactersNotInString(java.lang.String illegalChars, char... chars)
illegalChars
- the String to checkchars
- the characters to check for
java.lang.IllegalArgumentException
- if the String contains one or more of the characterspublic static java.lang.String wordWrap(java.lang.String s, int maxLineLength)
public static java.lang.String wordWrapSingleLine(java.lang.String s, int maxLineLength)
public static java.lang.String intValuesToString(int[] intVals)
public static java.lang.String intValuesToString(short[] shortVals)
public static java.lang.String bytesToString(byte[] data)
public static java.lang.String bytesToString(byte[] buffer, int offset, int length)
public static byte[] stringToBytes(java.lang.String s)
public static byte[] stringToBytes(java.lang.String s, int offset, int length)
public static java.lang.String readNullTerminatedString(BinaryCodec binaryCodec)
public static void charsToBytes(char[] chars, int charOffset, int length, byte[] bytes, int byteOffset)
chars
- input charscharOffset
- where to start converting from chars arraylength
- how many chars to convertbytes
- where to put the converted outputbyteOffset
- where to start writing the converted output.public static byte charToByte(char c)
public static char byteToChar(byte b)
public static java.lang.String bytesToHexString(byte[] data)
data
- Input to be converted.
public static byte[] hexStringToBytes(java.lang.String s) throws java.lang.NumberFormatException
s
- Hex string. Length must be even because each pair of hex chars is converted into a byte.
java.lang.NumberFormatException
public static char toHexDigit(int value)
public static int fromHexDigit(char c) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static java.lang.String reverseString(java.lang.String s)
s
- String to be reversed.
public static boolean isBlank(java.lang.String str)
Checks if a String is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("sam") = false StringUtils.isBlank(" sam ") = false
str
- the String to check, may be null
true
if the String is null, empty or whitespacepublic static java.lang.String repeatCharNTimes(char c, int repeatNumber)
public static java.lang.String asEmptyIfNull(java.lang.Object string)
public static int levenshteinDistance(java.lang.String string1, java.lang.String string2, int swap, int substitution, int insertion, int deletion)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |