Package mgui.util
Class StringFunctions
java.lang.Object
mgui.util.StringFunctions
public class StringFunctions
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description StringFunctions()
-
Method Summary
Modifier and Type Method Description static int
countOccurrences(java.lang.String s, java.lang.String occ)
Counts the number of timesocc
occurs ins
.static boolean
isInteger(java.lang.String s)
Determines whethers
can be converted to an integerstatic boolean
isNumeric(java.lang.String s)
Determines whethers
can be converted to a numberstatic java.lang.String
replaceAll(java.lang.String string, java.lang.String find, java.lang.String replace)
Replaces all occurrences offind
instring
and replaces them withreplace
, without using regex.static java.lang.String
resizeString(java.lang.String string, int length)
Resizesstring
to lengthlength
, by truncating or padding with spaces.static java.lang.String
resizeString(java.lang.String string, int length, char pad)
Resizesstring
to lengthlength
, by truncating or padding.static java.lang.String
trim(java.lang.String s)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
StringFunctions
public StringFunctions()
-
-
Method Details
-
trim
public static java.lang.String trim(java.lang.String s) -
countOccurrences
public static int countOccurrences(java.lang.String s, java.lang.String occ)Counts the number of timesocc
occurs ins
.- Parameters:
s
-occ
-- Returns:
-
resizeString
public static java.lang.String resizeString(java.lang.String string, int length)Resizesstring
to lengthlength
, by truncating or padding with spaces.- Parameters:
string
-length
-- Returns:
-
resizeString
public static java.lang.String resizeString(java.lang.String string, int length, char pad)Resizesstring
to lengthlength
, by truncating or padding.- Parameters:
string
-length
-pad
-- Returns:
-
replaceAll
public static java.lang.String replaceAll(java.lang.String string, java.lang.String find, java.lang.String replace)Replaces all occurrences offind
instring
and replaces them withreplace
, without using regex.- Parameters:
string
-find
-replace
-- Returns:
-
isNumeric
public static boolean isNumeric(java.lang.String s)Determines whethers
can be converted to a number- Parameters:
s
-- Returns:
-
isInteger
public static boolean isInteger(java.lang.String s)Determines whethers
can be converted to an integer- Parameters:
s
-- Returns:
-