Constructor and Description |
---|
SourceUtil() |
Modifier and Type | Method and Description |
---|---|
static Set<Source> |
filesToSourceSet(Collection<File> files)
creates a source set from the given collections of script files,
using the default source factory.
|
static Set<Source> |
filesToSourceSet(File... files)
creates a source set from the given script files,
using the default source factory.
|
static Set<Source> |
filesToSourceSet(SourceFactory sourceFactory,
Collection<File> files)
creates a source set from the given collections of script files,
using the given source factory.
|
static Set<Source> |
filesToSourceSet(SourceFactory sourceFactory,
File... files)
creates a source set from the given script files,
using the given source factory.
|
static String |
getTextStartNoLineBreaks(String text,
int maxLen)
gets the start of the given text with line breaks removed.
|
static String |
hash(String text,
String algorithm)
calculates a cryptographic hash function (message digest).
|
static String |
md5(String text)
calculates an MD5 hash.
|
static String |
readUrlText(URL url,
String encoding)
reads the content from the given URL using the given character encoding.
|
static Set<Source> |
sourceArrayToSourceSet(Source... sourceArray)
converts the given source varargs or array of source to a set of source.
|
static Set<Source> |
sourceCollectionToSourceSet(Collection<Source> sourceCollection)
converts the given collection of source to a set of source.
|
static Set<Source> |
sourceToSourceSet(Source source)
converts the given source to a set of source that contains only the given source.
|
static Set<Source> |
textsToSourceSet(Collection<String> texts)
creates a source set from the given collections of script texts,
using the default source factory.
|
static Set<Source> |
textsToSourceSet(Map<String,String> texts)
creates a source set from the given map of desired class name to script text,
using the default source factory.
|
static Set<Source> |
textsToSourceSet(SourceFactory sourceFactory,
Collection<String> texts)
creates a source set from the given collections of script texts,
using the given source factory.
|
static Set<Source> |
textsToSourceSet(SourceFactory sourceFactory,
Map<String,String> texts)
creates a source set from the given map of of desired class name to script text,
using the given source factory.
|
static Set<Source> |
textsToSourceSet(SourceFactory sourceFactory,
String... texts)
creates a source set from the given script texts,
using the given source factory.
|
static Set<Source> |
textsToSourceSet(String... texts)
creates a source set from the given script texts,
using the default source factory.
|
static File |
toCanonicalOrAbsoluteFile(File file)
converts the given file to the canonical file, with fallback
to the absolute file if getting the canonical file failed.
|
static Set<Source> |
urlsToSourceSet(Collection<URL> urls)
creates a source set from the given collections of script URLs,
using the default source factory.
|
static Set<Source> |
urlsToSourceSet(SourceFactory sourceFactory,
Collection<URL> urls)
creates a source set from the given collections of script URLs,
using the given source factory.
|
static Set<Source> |
urlsToSourceSet(SourceFactory sourceFactory,
URL... urls)
creates a source set from the given script URLs,
using the given source factory.
|
static Set<Source> |
urlsToSourceSet(URL... urls)
creates a source set from the given script URLs,
using the default source factory.
|
public static Set<Source> textsToSourceSet(Collection<String> texts)
texts
- script textspublic static Set<Source> textsToSourceSet(String... texts)
texts
- script textspublic static Set<Source> textsToSourceSet(SourceFactory sourceFactory, Collection<String> texts)
sourceFactory
- source factorytexts
- script textspublic static Set<Source> textsToSourceSet(SourceFactory sourceFactory, String... texts)
sourceFactory
- source factorytexts
- script textspublic static Set<Source> textsToSourceSet(Map<String,String> texts)
texts
- map of desired class name to script textpublic static Set<Source> textsToSourceSet(SourceFactory sourceFactory, Map<String,String> texts)
sourceFactory
- source factorytexts
- map of desired class name to script textpublic static Set<Source> filesToSourceSet(Collection<File> files)
files
- script filespublic static Set<Source> filesToSourceSet(File... files)
files
- script filespublic static Set<Source> filesToSourceSet(SourceFactory sourceFactory, Collection<File> files)
sourceFactory
- source factoryfiles
- script filespublic static Set<Source> filesToSourceSet(SourceFactory sourceFactory, File... files)
sourceFactory
- source factoryfiles
- script filespublic static Set<Source> urlsToSourceSet(Collection<URL> urls)
urls
- script URLspublic static Set<Source> urlsToSourceSet(URL... urls)
urls
- script URLspublic static Set<Source> urlsToSourceSet(SourceFactory sourceFactory, Collection<URL> urls)
sourceFactory
- source factoryurls
- script URLspublic static Set<Source> urlsToSourceSet(SourceFactory sourceFactory, URL... urls)
sourceFactory
- source factoryurls
- script URLspublic static Set<Source> sourceToSourceSet(Source source)
source
- sourcepublic static Set<Source> sourceCollectionToSourceSet(Collection<Source> sourceCollection)
sourceCollection
- source collectionpublic static Set<Source> sourceArrayToSourceSet(Source... sourceArray)
sourceArray
- source varargs or array of sourcepublic static String hash(String text, String algorithm)
The given text is first UTF-8 encoded to bytes, then the given hash is calculated and finally returned as a hex string.
text
- the text to hashalgorithm
- the hash algorithm to useUnsupportedOperationException
- if the given hash algorithm is not availablepublic static String md5(String text)
The given text is first UTF-8 encoded to bytes, then the MD5 hash is calculated and finally returned as a hex string.
text
- the text to hashUnsupportedOperationException
- if MD5 is not available (which is very unlikely)public static String getTextStartNoLineBreaks(String text, int maxLen)
The returned text is at most maxLen characters long and line breaks are converted to "%n". If the text had to be cut, this is indicated by "[..]" at the end of the returned text.
text
- textmaxLen
- maximal length of the returned textIllegalArgumentException
- if maxLen is less than 10public static String readUrlText(URL url, String encoding) throws IOException
url
- URLencoding
- encoding, e.g. "UTF-8"IOException
- if could not read from the URLpublic static File toCanonicalOrAbsoluteFile(File file)
The returned file is thus guaranteed to be an absolute file.
file
- file