public class ParsingUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.Object,java.awt.Color> |
colorCache |
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 a URLHelper from the current URLHelperFactory
|
static URLHelperFactory |
getURLHelperFactory() |
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.io.InputStream |
openInputStream(java.lang.String uri,
java.util.function.Function<java.nio.channels.SeekableByteChannel,java.nio.channels.SeekableByteChannel> wrapper)
open an input stream from the given path and wrap the raw byte stream with a wrapper if given
the wrapper will only be applied to paths that are not http, https, ftp, or file, i.e.
|
static java.awt.Color |
parseColor(java.lang.String string)
Convert an rgb string, hex, or symbol to a color.
|
static boolean |
resourceExists(java.lang.String resource) |
static void |
setURLHelperFactory(URLHelperFactory factory)
Set the factory object for providing URLHelpers.
|
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 final java.util.Map<java.lang.Object,java.awt.Color> colorCache
public static java.io.InputStream openInputStream(java.lang.String path) throws java.io.IOException
java.io.IOException
public static java.io.InputStream openInputStream(java.lang.String uri, java.util.function.Function<java.nio.channels.SeekableByteChannel,java.nio.channels.SeekableByteChannel> wrapper) throws java.io.IOException
Path
using a custom filesystem pluginuri
- a uri like stringwrapper
- to wrap the input stream in, may be used to implement caching or prefetching, etcjava.io.IOException
- when stream cannot be opened against uripublic 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
- setURLHelperFactory(URLHelperFactory)
public static void setURLHelperFactory(URLHelperFactory factory)
URLHelperFactory
.factory
- public static URLHelperFactory getURLHelperFactory()
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
-