|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.argval.utils.StringUtil
public final class StringUtil
Utility class for String related functions.
| Field Summary | |
|---|---|
static String |
LINE_SEPARATOR
|
| Method Summary | |
|---|---|
static int |
charCount(String text,
char ch)
|
static List<String> |
convertToList(String text)
|
static List<String> |
convertToList(String text,
String separator)
|
static Set<String> |
convertToSet(String text)
|
static Set<String> |
convertToSet(String text,
String separator)
Converts the text into separated String instance, based on the separator. |
static List<Integer> |
getCharIndexList(String text,
char ch)
|
static String |
getClassName(Class<?> clazz)
Returns the class name, without the package prefix. |
static String |
getPackageName(Class<?> clazz)
Returns the package name, without the class name. |
static String |
polish(String text)
Trims spaces on the outside of the text and in the case of an empty string null is returned. |
static String |
polish(String text,
String defaultText)
Returns the polished text, see polish(String), or when that leads to
null the default text. |
static String |
remove(String text,
String toRemove)
Cleans up the text, by removing the toRemove instance(s). |
static String |
removeCharacter(String text,
char character)
Removes the character instances from the given text. |
static String |
removeCharacter(String text,
char[] characterArray)
Removes all the given characters from the given text. |
static List<String> |
toHexList(byte[] byteArray)
|
static List<String> |
toHexList(String hexStr)
|
static String |
toHexString(byte[] byteArray)
Converts a byte array into a hex string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String LINE_SEPARATOR
| Method Detail |
|---|
public static String polish(String text)
null is returned.
text - The text to polish.
null, when no characters are left.
public static String polish(String text,
String defaultText)
polish(String), or when that leads to
null the default text.
text - The text to polish.defaultText - The default text to return, if the polished text, result
in to null.
null, the default text.
public static Set<String> convertToSet(String text,
String separator)
Example:
convertToSet("Winnie The Pooh;Piglet;Tigger;Rabbit", ";") will return a Set instance
containing the Strings:
"Winnie The Pooh""Piglet""Tigger""Rabbit"
text - The text to separate.separator - The separator String instance.
public static Set<String> convertToSet(String text)
public static List<String> convertToList(String text,
String separator)
public static List<String> convertToList(String text)
public static String removeCharacter(String text,
char character)
Example:
removeCharacter("ISBN: 0-596-10094-9", '-') will return "ISBN: 0596100949"
text - The text to filter.character - The character to remove.
public static String removeCharacter(String text,
char[] characterArray)
Exmaple:
removeCharacter("ISBN: 0-596-10094-9", new char[] { '-', ':' } ) will return "ISBN 0596100949"
text - The text to filter.character - The character to remove.
public static String remove(String text,
String toRemove)
This can be used to remove unwanted Strings from a text.
// Remove "ISBN:" from the text
StringUtil.remove("ISBN: 0-596-10094-9", "ISBN:");
This will return the text " 0-596-10094-9".
text - The text, which needs to be clean up.toRemove - The character sequence which needs to be removed, from the given text.
public static String getClassName(Class<?> clazz)
clazz - The class, from which to get it's name.
public static String getPackageName(Class<?> clazz)
clazz - The class, from which to get it's package name.
public static int charCount(String text,
char ch)
public static List<Integer> getCharIndexList(String text,
char ch)
public static String toHexString(byte[] byteArray)
byteArray - The bytes.
public static List<String> toHexList(byte[] byteArray)
public static List<String> toHexList(String hexStr)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||