public final class BasicStringHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
javaReservedWords
All java reserved words.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
digitToString(Character digit)
Gets the word-string for a digit.
Example: |
static String |
firstToLower(String str)
Converts the first character of string to uppercase.
|
static String |
firstToUpper(String str)
Converts the first character of string to uppercase.
|
static String |
getContinuedLine(String line)
Checks whether given string introduces a continuation line.
|
static String |
getPlainClassName(String className)
Gets a classname without any optional generics.
|
static boolean |
isAllWhitespace(String str)
Checks if string contains only whitespaces.
|
static boolean |
isReservedWord(String word)
Returns whether given string is a reserved java keyword.
|
static boolean |
isValidJavaClassName(String className)
Checks that given string is a valid Java classname.
Both classnames with a full classpath or without are validated. |
static boolean |
isValidJavaIdentifier(String str)
Returns whether the given string is a valid java identifier.
|
static boolean |
isValidJavaPackageName(String packageName)
Checks that given string is a valid Java packagename.
This is very restrictive verification. |
static String |
parseString(String str)
Parses a string.
The string may be enclosed in double- or single quotes which will be removed. |
static String |
readTextFromResource(String resourceName)
Reads a textfile from a resource.
The textfile must be in the classpath. |
static List<String> |
split(String str,
String delimiters)
Splits a string keeping strings together.
The strings may be enclosed in double- or single quotes which will not be removed. |
static String |
toDoubleQuotes(String str)
Takes a string, surrounds it with double-quotes and escapes all double-quotes
already in the string according to Unix rules.
|
static String |
toLower(String str)
Converts a string to lowercase allowing null values.
|
static String |
toUpper(String str)
Converts a string to uppercase allowing null values.
|
public static final String[] javaReservedWords
public static String toUpper(String str)
str - the stringpublic static String toLower(String str)
str - the stringpublic static String firstToUpper(String str)
str - the stringpublic static String firstToLower(String str)
str - the stringpublic static String getPlainClassName(String className)
className - the original classnamepublic static String getContinuedLine(String line)
This is the case if the last character is an unquoted backslash.
line - the source linepublic static String toDoubleQuotes(String str)
Length 5" --> "Length 5\""
str - the stringpublic static String parseString(String str)
\n = new line \r = carriage return \t = tab \f = form feed
str - the source stringpublic static List<String> split(String str, String delimiters)
\n = new line \r = carriage return \t = tab \f = form feed
str - the stringdelimiters - the delimiter characterspublic static boolean isValidJavaClassName(String className)
className - the classnamepublic static boolean isValidJavaPackageName(String packageName)
packageName - the packagenamepublic static boolean isValidJavaIdentifier(String str)
str - the stringpublic static String readTextFromResource(String resourceName) throws IOException
Example:
String model = BasicStringHelper.readTestFromResource("org/tentackle/model/TestModel.txt");
resourceName - the name of the resourceIOException - if loading failed or no such resourcepublic static boolean isAllWhitespace(String str)
str - the string to checkpublic static boolean isReservedWord(String word)
word - the string to testCopyright © 2016 Krake Softwaretechnik. All rights reserved.