public class ParsingUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Map<Object,Color> |
colorCache |
static Class |
urlHelperClass |
Constructor and Description |
---|
ParsingUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
appendToPath(String filepath,
String indexExtension)
Add the
indexExtension to the filepath , preserving
query string elements if present. |
static URLHelper |
getURLHelper(URL url)
Return the registered URLHelper, constructed with the provided URL
|
static <T extends Comparable<? super T>> |
isSorted(Iterable<T> iterable) |
static <T> String |
join(String separator,
Collection<T> objects) |
static String |
join(String separator,
String[] strings)
join an array of strings given a seperator
|
static String |
join(String separator,
String[] strings,
int start,
int end)
join a set of strings, using the separator provided, from index start to index stop
|
static InputStream |
openInputStream(String path) |
static Color |
parseColor(String string)
Convert an rgb string, hex, or symbol to a color.
|
static void |
registerHelperClass(Class helperClass)
Register a
URLHelper class to be used for URL operations. |
static boolean |
resourceExists(String resource) |
static <T extends Comparable<T>,V> |
sortedString(Map<T,V> c) |
static <T extends Comparable> |
sortList(Collection<T> list)
a small utility function for sorting a list
|
static List<String> |
split(String input,
char delim)
Split the string into tokens separated by the given delimiter.
|
static int |
split(String aString,
String[] tokens,
char delim)
Split the string into tokesn separated by the given delimiter.
|
static int |
split(String aString,
String[] tokens,
char delim,
boolean condenseTrailingTokens)
Split the string into tokens separated by the given delimiter.
|
static int |
splitWhitespace(String aString,
String[] tokens)
Split the string into tokens separated by tab or space(s).
|
static String |
trim(String str,
char ch) |
public static Class urlHelperClass
public static InputStream openInputStream(String path) throws IOException
IOException
public static <T> String join(String separator, Collection<T> objects)
public static <T extends Comparable> List<T> sortList(Collection<T> list)
T
- list
- public static <T extends Comparable<T>,V> String sortedString(Map<T,V> c)
public static String join(String separator, String[] strings)
separator
- the string to insert between each array elementstrings
- the array of stringspublic static String join(String separator, String[] strings, int start, int end)
separator
- the separator to usestrings
- the list of stringsstart
- the start position (index in the list)0end
- the end position (index in the list)public static List<String> split(String input, char delim)
input
- the string to splitdelim
- the character that delimits tokenspublic static int split(String aString, String[] tokens, char delim)
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokenspublic static int split(String aString, String[] tokens, char delim, boolean condenseTrailingTokens)
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokenscondenseTrailingTokens
- if true and there are more tokens than will fit in the tokens array,
condense all trailing tokens into the last tokenpublic static int splitWhitespace(String aString, String[] tokens)
aString
- the string to splittokens
- an array to hold the parsed tokenspublic static <T extends Comparable<? super T>> boolean isSorted(Iterable<T> iterable)
public static Color parseColor(String string)
string
- public static boolean resourceExists(String resource) throws IOException
IOException
public static URLHelper getURLHelper(URL url)
url
- registerHelperClass(Class)
public static void registerHelperClass(Class helperClass)
URLHelper
class to be used for URL operations. The helper
may be used for both FTP and HTTP operations, so if any FTP URLs are used
the URLHelper
must support it.
The default helper class is RemoteURLHelper
, which delegates to FTP/HTTP
helpers as appropriate.public static String appendToPath(String filepath, String indexExtension)
indexExtension
to the filepath
, preserving
query string elements if present. Intended for use where filepath
is a URL. Will behave correctly on regular file paths (just add the extension
to the end)filepath
- indexExtension
-