public interface StringTools
Tools for working with strings.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public String |
caseConversion(CaseFormats inputFormat, CaseFormats outputFormat, Object stringy)Converts a string in one format to another. |
|
public String |
hashUri(URI uri)Creates a SHA-256 hash of a URI. |
|
public String |
loadTextFromResource(String resourcePath)Loads text from a resource file. |
|
public byte[] |
makeByteArray(Object src)Converts a source to a byte array. |
|
public byte[] |
makeByteArrayOrNull(Object src)Converts a source to a byte array. |
|
public String |
packageNameFromUri(URI uri)Get final package or directory name from a URI |
|
public java.util.regex.Pattern |
patternize(Object stringy)Converts most things to a pattern. |
|
public java.util.List<java.util.regex.Pattern> |
patternize(java.util.Collection<?> stringyThings)Converts a collection of most things to a list of regex patterns. |
|
public java.util.List<java.util.regex.Pattern> |
patternizeDropNull(java.util.Collection<?> stringyThings)Like patternize, but drops any nulls, or empty instances of Provider and java.util.Optional. |
|
public java.util.regex.Pattern |
patternizeOrNull(Object stringy)Like patternize, but returns null rather than throwing an exception, when item is null,
an empty {
|
|
public Provider<byte[]> |
provideByteArray(Object src)Like provideByteArray(Object), but lazy-evaluates the value.. |
|
public Provider<byte[]> |
provideByteArrayOrNull(Object src)Like provideByteArrayOrNull(Object), but lazy-evaluates the value.. |
|
public Provider<String> |
provideCaseConversion(CaseFormats inputFormat, CaseFormats outputFormat, Object stringy)Converts a string in one format to another. |
|
public Provider<java.util.regex.Pattern> |
providePattern(Object stringy)Like patternize, but does not immediately evaluate the passed parameter. |
|
public Provider<java.util.regex.Pattern> |
providePatternOrNull(Object stringy)Like patternizeOrNull(Object), but does not evaluate the passed parameter immediately. |
|
public Provider<String> |
provideString(Object stringy)Like stringize, but does not immediately evaluate the passed parameter. |
|
public Provider<String> |
provideStringOrNull(Object stringy)Like stringizeOrNull(Object), but does not evaluate the passed parameter immediately. |
|
public Provider<java.util.List<String>> |
provideStrings(java.util.Collection<Object> stringyThings)Provides a list of items to be converted to strings. |
|
public Provider<java.util.List<String>> |
provideStringsDropNull(java.util.Collection<Object> stringyThings)Provides a list of items to be converted to strings dropping anything evaluating to null |
|
public Provider<String> |
provideTextFromResource(String resourcePath)Lazy-loads text from a resource file. |
|
public Provider<URI> |
provideUri(Object uriThingy)Similar to urize(Object), but does not evaluate the parameter immediately, only when the provider is resolved. |
|
public Provider<java.util.Map<String, String>> |
provideValues(java.util.Map<String, ?> props)Similar to stringizeValues, but does not evaluate the parameter immediately, only when the provider is resolved. |
|
public Provider<java.util.Map<String, String>> |
provideValues(Provider<java.util.Map<String, Object>> props)Similar to stringizeValues, but does not evaluate the parameter immediately, only when the provider is resolved. |
|
public Provider<java.util.Map<String, String>> |
provideValuesDropNull(java.util.Map<String, ?> props)Similar to stringizeValuesDropNull(Map), but does not evaluate the parameter immediately, only when the provider is resolved. |
|
public Provider<java.util.Map<String, String>> |
provideValuesDropNull(Provider<java.util.Map<String, Object>> props)Similar to stringizeValuesDropNull(Map), but does not evaluate the parameter immediately, only when the provider is resolved. |
|
public Provider<java.util.Map<String, String>> |
provideValuesKeepNull(java.util.Map<String, ?> props)Lazy-evaluate the map. |
|
public Provider<java.util.Map<String, String>> |
provideValuesKeepNull(Provider<java.util.Map<String, Object>> props)Lazy-evaluate the map. |
|
public URI |
safeUri(URI uri)Create a URI where the user/password is masked out. |
|
public String |
stringize(Object stringy)Converts most things to a string. |
|
public java.util.List<String> |
stringize(java.util.Collection<?> stringyThings)Converts a collection of most things to a list of strings. |
|
public java.util.List<String> |
stringizeDropNull(java.util.Collection<?> stringyThings)Like stringize, but drops any nulls, or empty instances of Provider and java.util.Optional. |
|
public String |
stringizeOrNull(Object stringy)Like stringize, but returns null rather than throwing an exception, when item is null,
an empty {
|
|
public java.util.Map<String, String> |
stringizeValues(java.util.Map<String, ?> props)Evaluates a map of objects to a map of strings. |
|
public java.util.Map<String, String> |
stringizeValuesDropNull(java.util.Map<String, ?> props)Like stringizeValues(Map), but drops the key, if the corresponding value is null or an empty Provider or java.util.Optional. |
|
public void |
updateStringProperty(Property<String> provider, Object stringy)Updates a Property<String>. |
|
public URI |
urize(Object uriThingy)Attempts to convert object to a URI. |
Converts a string in one format to another.
inputFormat - Input case format.outputFormat - Output case format.stringy - Object to convertCreates a SHA-256 hash of a URI.
uri - URI to hashLoads text from a resource file.
resourcePath - Resource path.Converts a source to a byte array.
Can convert the following:
byte[] and Byte[]CharSequence including String and GString.Unwraps the following recursively until it gets to something of the above:
Be careful when passing large files for conversion as all of the content will be read into memory.
src - Anything providing a byte[], a Byte[], or a string in some form other.
Usual recursive unwrapping will occur, before evaluation.
Empty wrappers and null are not accepted.byte[].Converts a source to a byte array.
src - Anything providing a byte[], a Byte[], or a string in some form other.
Usual recursive unwrapping will occur, before evaluation.byte[] or null if null or an empty wrapper is supplied.Get final package or directory name from a URI
uri - URI to processConverts most things to a pattern. Closures are evaluated as well.
Unwraps the following recursively until it gets to a pattern:
CharSequence including String and GString.
stringy - An object that can be converted to a pattern or a closure that
can be evaluated to something that can be converted to a pattern.Converts a collection of most things to a list of regex patterns. Closures are evaluated as well.
stringyThings - Iterable list of objects that can be converted to patterns,
including closure that can be evaluated
into objects that can be converted to patterns.Like patternize, but drops any nulls, or empty instances of Provider and java.util.Optional.
stringyThings - Iterable list of objects that can be converted to patterns,
including closure that can be evaluated
into objects that can be converted to patterns. Like patternize, but returns null rather than throwing an exception, when item is null,
an empty {
stringy - An object that can be converted to a pattern or a closure that
can be evaluated to something that can be converted to a pattern.nullLike provideByteArray(Object), but lazy-evaluates the value..
src - Anything providing a byte[], a Byte[], or a string in some form other.
Usual recursive unwrapping will occur, before evaluation.
Empty wrappers and null are not accepted.byte[]Like provideByteArrayOrNull(Object), but lazy-evaluates the value..
src - Anything providing a byte[], a Byte[], or a string in some form other.
Usual recursive unwrapping will occur, before evaluation.byte[]. Empty wrappers and null will result in an empty provider.Converts a string in one format to another.
inputFormat - Input case format.outputFormat - Output case format.stringy - Object to convertLike patternize, but does not immediately evaluate the passed parameter. The latter is only done when the provider is resolved.
stringy - An object that can be converted to a pattern or a closure that
can be evaluated to something that can be converted to a pattern.Like patternizeOrNull(Object), but does not evaluate the passed parameter immediately.
stringy - An object that can be converted to a pattern or a closure that
can be evaluated to something that can be converted to a pattern.Like stringize, but does not immediately evaluate the passed parameter. The latter is only done when the provider is resolved.
stringy - An object that can be converted to a string or a closure that
can be evaluated to something that can be converted to a string.Like stringizeOrNull(Object), but does not evaluate the passed parameter immediately.
stringy - Anything convertible to a string.Provides a list of items to be converted to strings.
stringyThings - Anything convertible to a string. Provides a list of items to be converted to strings dropping anything evaluating to null
stringyThings - Anything convertible to a string.Lazy-loads text from a resource file.
resourcePath - Resource path.Similar to urize(Object), but does not evaluate the parameter immediately, only when the provider is resolved.
uriThingy - Anything that could be converted to a URISimilar to stringizeValues, but does not evaluate the parameter immediately, only when the provider is resolved.
props - A map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Similar to stringizeValues, but does not evaluate the parameter immediately, only when the provider is resolved.
props - A provider to a map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Similar to stringizeValuesDropNull(Map), but does not evaluate the parameter immediately, only when the provider is resolved.
props - A map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Similar to stringizeValuesDropNull(Map), but does not evaluate the parameter immediately, only when the provider is resolved.
props - A provider to a map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Lazy-evaluate the map. If the values are null or contain empty providers, the resulting value will be kept with a null value.
props - A map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Lazy-evaluate the map. If the values are null or contain empty providers, the resulting value will be kept with a null value.
props - A map that is keyed on strings, but for which the values can be converted to strings
using stringize(Object).Create a URI where the user/password is masked out.
uri - Original URIConverts most things to a string. Closures are evaluated as well.
Converts collections of the following recursively until it gets to a string:
CharSequence including String and GString.
stringy - An object that can be converted to a string or a closure that
can be evaluated to something that can be converted to a string.Converts a collection of most things to a list of strings. Closures are evaluated as well.
stringyThings - Iterable list of objects that can be converted to strings, including closure that can be evaluated
into objects that can be converted to strings.Like stringize, but drops any nulls, or empty instances of Provider and java.util.Optional.
Like stringize, but returns null rather than throwing an exception, when item is null,
an empty {
nullEvaluates a map of objects to a map of strings.
Anything value that can be evaluated by stringize is evaluated
props - Map that will be evaluatedMap<String,String>Like stringizeValues(Map), but drops the key, if the corresponding value is null or an empty Provider or java.util.Optional.
props - Map that wil be evaluatednull. Updates a Property<String>.
THis provides a more powerful way than Property.set.
provider - String propertystringy - Objexct that is a string or can be converted to a string.Attempts to convert object to a URI.
Converts collections of the following recursively until it gets to a file:
CharSequence including String and GString.
uriThingy - Anything that could be converted to a URI