Package org.lifstools.jgoslin.domain
Class StringFunctions
java.lang.Object
org.lifstools.jgoslin.domain.StringFunctions
Utility methods for strings and grammars.
- Author:
- Dominik Kopczynski, Nils Hoffmann
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetResourceAsString(String resourcePath) Read the provided resource path and return it as a string.static StringgetResourceAsString(org.springframework.core.io.Resource resource) Read the provided resource and return it as a string.getResourceAsStringList(String resourcePath) Read the provided resource path, which is converted to aClassPathResourceand split it at default new line characters into a list for each line.getResourceAsStringList(org.springframework.core.io.Resource resource) Read the provided resource and split it at default new line characters into a list for each line.splitString(String text) Split the provided text atDEFAULT_SPLITas separator, usingDEFAULT_QUOTEas the default quotation char.splitString(String text, char separator, char quote) Split the provided text at separator, respecting the quote char to not split in between quoted parts.splitString(String text, char separator, char quote, boolean withEmpty) Split the provided text at separator, respecting the quote char to not split in between quoted parts.static String
-
Field Details
-
DEFAULT_QUOTE
public static char DEFAULT_QUOTE -
DEFAULT_SPLIT
public static char DEFAULT_SPLIT
-
-
Method Details
-
strip
-
splitString
Split the provided text atDEFAULT_SPLITas separator, usingDEFAULT_QUOTEas the default quotation char.- Parameters:
text- the text to split- Returns:
- the split string as a list
-
splitString
Split the provided text at separator, respecting the quote char to not split in between quoted parts.- Parameters:
text- the text to splitseparator- the separator to split atquote- the quotation character- Returns:
- the split string as a list
-
splitString
public static ArrayList<String> splitString(String text, char separator, char quote, boolean withEmpty) Split the provided text at separator, respecting the quote char to not split in between quoted parts. Optionally allow empty / whitespace at the end.- Parameters:
text- the text to splitseparator- the separator to split atquote- the quotation characterwithEmpty- if true, allow empty parts- Returns:
- the split string as a list
-
getResourceAsStringList
Read the provided resource and split it at default new line characters into a list for each line.- Parameters:
resource- the resource to read- Returns:
- a list of line strings
-
getResourceAsStringList
Read the provided resource path, which is converted to aClassPathResourceand split it at default new line characters into a list for each line.- Parameters:
resourcePath- the resource path to read from- Returns:
- a list of line strings
-
getResourceAsString
Read the provided resource and return it as a string.- Parameters:
resource- the resource to read- Returns:
- the resource content as a string
-
getResourceAsString
Read the provided resource path and return it as a string.- Parameters:
resourcePath- the resource path to read from- Returns:
- the resource content as a string
-