public class ParsingUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.Object,java.awt.Color> |
colorCache |
static java.lang.Class |
urlHelperClass |
Constructor and Description |
---|
ParsingUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
appendToPath(java.lang.String filepath,
java.lang.String indexExtension)
Add the
indexExtension to the filepath , preserving
query string elements if present. |
static URLHelper |
getURLHelper(java.net.URL url)
Return the registered URLHelper, constructed with the provided URL
|
static <T extends java.lang.Comparable<? super T>> |
isSorted(java.lang.Iterable<T> iterable) |
static <T> java.lang.String |
join(java.lang.String separator,
java.util.Collection<T> objects) |
static java.lang.String |
join(java.lang.String separator,
java.lang.String[] strings)
join an array of strings given a seperator
|
static java.lang.String |
join(java.lang.String separator,
java.lang.String[] strings,
int start,
int end)
join a set of strings, using the separator provided, from index start to index stop
|
static java.io.InputStream |
openInputStream(java.lang.String path) |
static java.awt.Color |
parseColor(java.lang.String string)
Convert an rgb string, hex, or symbol to a color.
|
static void |
registerHelperClass(java.lang.Class helperClass)
Register a
URLHelper class to be used for URL operations. |
static boolean |
resourceExists(java.lang.String resource) |
static <T extends java.lang.Comparable<T>,V> |
sortedString(java.util.Map<T,V> c) |
static <T extends java.lang.Comparable> |
sortList(java.util.Collection<T> list)
a small utility function for sorting a list
|
static java.util.List<java.lang.String> |
split(java.lang.String input,
char delim)
Split the string into tokens separated by the given delimiter.
|
static int |
split(java.lang.String aString,
java.lang.String[] tokens,
char delim)
Split the string into tokesn separated by the given delimiter.
|
static int |
split(java.lang.String aString,
java.lang.String[] tokens,
char delim,
boolean condenseTrailingTokens)
Split the string into tokens separated by the given delimiter.
|
static int |
splitWhitespace(java.lang.String aString,
java.lang.String[] tokens)
Split the string into tokens separated by tab or space(s).
|
static java.lang.String |
trim(java.lang.String str,
char ch) |
public static java.util.Map<java.lang.Object,java.awt.Color> colorCache
public static java.lang.Class urlHelperClass
public static java.io.InputStream openInputStream(java.lang.String path) throws java.io.IOException
java.io.IOException
public static <T> java.lang.String join(java.lang.String separator, java.util.Collection<T> objects)
public static <T extends java.lang.Comparable> java.util.List<T> sortList(java.util.Collection<T> list)
T
- list
- public static <T extends java.lang.Comparable<T>,V> java.lang.String sortedString(java.util.Map<T,V> c)
public static java.lang.String join(java.lang.String separator, java.lang.String[] strings)
separator
- the string to insert between each array elementstrings
- the array of stringspublic static java.lang.String join(java.lang.String separator, java.lang.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 java.util.List<java.lang.String> split(java.lang.String input, char delim)
input
- the string to splitdelim
- the character that delimits tokenspublic static int split(java.lang.String aString, java.lang.String[] tokens, char delim)
aString
- the string to splittokens
- an array to hold the parsed tokensdelim
- character that delimits tokenspublic static int split(java.lang.String aString, java.lang.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 java.lang.String trim(java.lang.String str, char ch)
public static int splitWhitespace(java.lang.String aString, java.lang.String[] tokens)
aString
- the string to splittokens
- an array to hold the parsed tokenspublic static <T extends java.lang.Comparable<? super T>> boolean isSorted(java.lang.Iterable<T> iterable)
public static java.awt.Color parseColor(java.lang.String string)
string
- public static boolean resourceExists(java.lang.String resource) throws java.io.IOException
java.io.IOException
public static URLHelper getURLHelper(java.net.URL url)
url
- registerHelperClass(Class)
public static void registerHelperClass(java.lang.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 java.lang.String appendToPath(java.lang.String filepath, java.lang.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
-