From 76cc4fbe4031ec78cb734079d7a6893ec5fbf80e Mon Sep 17 00:00:00 2001 From: BuildTools Date: Fri, 30 Apr 2021 07:56:49 +0200 Subject: [PATCH] 2021.5.355 --- README.md | 1 - pom.xml | 4 +- template-cli/pom.xml | 2 +- template-cli/template-cli.iml | 13 +- template-maven-plugin/pom.xml | 2 +- .../AbstractConvertMojo.java | 4 + .../convert_maven_plugin/ToHsonMojo.java | 3 + .../convert_maven_plugin/ToJsonMojo.java | 13 +- .../convert_maven_plugin/ToPdataMojo.java | 13 +- .../util/ContextHelper.java | 1751 +---------- .../util/ContextUtil.java | 2553 +---------------- .../template-maven-plugin.iml | 13 +- 12 files changed, 175 insertions(+), 4197 deletions(-) create mode 100644 template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/AbstractConvertMojo.java diff --git a/README.md b/README.md index dd79dc7..e0bb136 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ various template files using various data files. * java properties * yaml/yml -- ie. YAML 1.1 -- https://yaml.org/spec/1.1/current.html -* toml/tml -- ie. TOML 0.4 -- https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md * json -- ie. JSON -- https://www.json.org/json-en.html * hson/hjson -- ie. human JSON -- https://hjson.github.io/ * ini -- simple windows ini file format diff --git a/pom.xml b/pom.xml index aa171cc..477c1c8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.terefang.template template - 2021.5.351 + 2021.5.355 template-cli template-maven-plugin @@ -29,7 +29,7 @@ 3.6.3 ${maven.build.timestamp} yyyyMMdd'.'HHmm - 2021.5.125 + 2021.5.135 diff --git a/template-cli/pom.xml b/template-cli/pom.xml index d01fb3d..edfa8a1 100644 --- a/template-cli/pom.xml +++ b/template-cli/pom.xml @@ -5,7 +5,7 @@ template com.github.terefang.template - 2021.5.351 + 2021.5.355 4.0.0 diff --git a/template-cli/template-cli.iml b/template-cli/template-cli.iml index 4b7aa73..48cafc7 100644 --- a/template-cli/template-cli.iml +++ b/template-cli/template-cli.iml @@ -12,9 +12,10 @@ - - - + + + + @@ -47,7 +48,7 @@ - + @@ -71,13 +72,13 @@ - + - + diff --git a/template-maven-plugin/pom.xml b/template-maven-plugin/pom.xml index 9784473..d6a7ced 100644 --- a/template-maven-plugin/pom.xml +++ b/template-maven-plugin/pom.xml @@ -5,7 +5,7 @@ template com.github.terefang.template - 2021.5.351 + 2021.5.355 4.0.0 diff --git a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/AbstractConvertMojo.java b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/AbstractConvertMojo.java new file mode 100644 index 0000000..a18d9f3 --- /dev/null +++ b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/AbstractConvertMojo.java @@ -0,0 +1,4 @@ +package com.github.terefang.convert_maven_plugin; + +public class AbstractConvertMojo { +} diff --git a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToHsonMojo.java b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToHsonMojo.java index 42e78bb..ceeb4dc 100644 --- a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToHsonMojo.java +++ b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToHsonMojo.java @@ -42,6 +42,9 @@ public class ToHsonMojo extends AbstractMojo @Parameter private String excludes; + @Parameter + boolean singleFileOutput; + @Override public void execute() throws MojoExecutionException, MojoFailureException { diff --git a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToJsonMojo.java b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToJsonMojo.java index 3a275e0..dc5c71f 100644 --- a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToJsonMojo.java +++ b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToJsonMojo.java @@ -40,6 +40,9 @@ public class ToJsonMojo extends AbstractMojo @Parameter private String excludes; + @Parameter + boolean singleFileOutput; + @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -89,10 +92,18 @@ public void process(String[] includedFiles) { file = new File(resourcesOutput, file.getName()); } - file.getParentFile().mkdirs(); File localFile = new File(resourcesDirectory, key); + if(resourcesDirectory.isFile()) + { + localFile = resourcesDirectory; + } + + if(singleFileOutput) { + file = resourcesOutput; + } + file.getParentFile().mkdirs(); convertToJson(localFile, file); } diff --git a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToPdataMojo.java b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToPdataMojo.java index 70c5289..7087740 100644 --- a/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToPdataMojo.java +++ b/template-maven-plugin/src/main/java/com/github/terefang/convert_maven_plugin/ToPdataMojo.java @@ -39,6 +39,9 @@ public class ToPdataMojo extends AbstractMojo @Parameter private String excludes; + @Parameter + boolean singleFileOutput; + @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -88,10 +91,18 @@ public void process(String[] includedFiles) { file = new File(resourcesOutput, file.getName()); } - file.getParentFile().mkdirs(); File localFile = new File(resourcesDirectory, key); + if(resourcesDirectory.isFile()) + { + localFile = resourcesDirectory; + } + + if(singleFileOutput) { + file = resourcesOutput; + } + file.getParentFile().mkdirs(); convertToPdata(localFile, file); } diff --git a/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextHelper.java b/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextHelper.java index ac4631e..45acdb9 100644 --- a/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextHelper.java +++ b/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextHelper.java @@ -1,22 +1,15 @@ package com.github.terefang.template_maven_plugin.util; -import com.github.terefang.jmelange.dao.JDAO; -import com.github.terefang.jmelange.image.PdfImage; -import com.github.terefang.jmelange.image.PixelImage; -import com.github.terefang.jmelange.image.SvgImage; import com.github.terefang.template_maven_plugin.TemplateContext; import lombok.SneakyThrows; -import org.apache.commons.codec.DecoderException; import java.io.*; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.nio.charset.Charset; -import java.text.ParseException; +import java.text.MessageFormat; import java.util.*; -public class ContextHelper { +public class ContextHelper extends ContextUtil +{ TemplateContext context; public static ContextHelper from(TemplateContext _tc) @@ -30,1736 +23,18 @@ public static ContextHelper from(TemplateContext _tc) @SneakyThrows public final Map loadContextFile(String _file) { - return ContextUtil.loadContextFrom(new File(this.context.processParent, _file)); - } - - /*----- dao helper -----*/ - - public final JDAO daoFromJdbc(String _driver, String _url, String _user, String _pass) - { - return ContextUtil.daoFromJdbc(_driver, _url, _user,_pass); - } - - public static String toString(Object _o) - { - return Objects.toString(_o); - } - - public final PixelImage pixImage(int _w, int _h) { - return ContextUtil.pixImage(_w, _h); - } - - public final SvgImage svgImage(int _w, int _h) { - return ContextUtil.svgImage(_w, _h); - } - - public final PdfImage pdfImage(int _w, int _h) { - return ContextUtil.pdfImage(_w, _h); - } - - public final String hmacMd5Hex(String key, String valueToDigest) { - return ContextUtil.hmacMd5Hex(key, valueToDigest); - } - - public final String hmacSha1Hex(String key, String valueToDigest) { - return ContextUtil.hmacSha1Hex(key, valueToDigest); - } - - public final String hmacSha256Hex(String key, String valueToDigest) { - return ContextUtil.hmacSha256Hex(key, valueToDigest); - } - - public final String hmacSha384Hex(String key, String valueToDigest) { - return ContextUtil.hmacSha384Hex(key, valueToDigest); - } - - public final String hmacSha512Hex(String key, String valueToDigest) { - return ContextUtil.hmacSha512Hex(key, valueToDigest); - } - - public final String md5Hex(String data) { - return ContextUtil.md5Hex(data); - } - - public final String sha1Hex(String data) { - return ContextUtil.sha1Hex(data); - } - - public final String sha256Hex(String data) { - return ContextUtil.sha256Hex(data); - } - - public final String sha384Hex(String data) { - return ContextUtil.sha384Hex(data); - } - - public final String sha512Hex(String data) { - return ContextUtil.sha512Hex(data); - } - - public final String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords, String wrapOn) { - return ContextUtil.wrap(str, wrapLength, newLineStr, wrapLongWords, wrapOn); - } - - public final boolean containsAllWords(CharSequence word, CharSequence... words) { - return ContextUtil.containsAllWords(word, words); - } - - @Deprecated - public final boolean isDelimiter(char ch, char[] delimiters) { - return ContextUtil.isDelimiter(ch, delimiters); - } - - @Deprecated - public final boolean isDelimiter(int codePoint, char[] delimiters) { - return ContextUtil.isDelimiter(codePoint, delimiters); - } - - public final String abbreviate(String str, int lower, int upper, String appendToEnd) { - return ContextUtil.abbreviate(str, lower, upper, appendToEnd); - } - - public final String toCamelCase(String str, boolean capitalizeFirstLetter, char... delimiters) { - return ContextUtil.toCamelCase(str, capitalizeFirstLetter, delimiters); - } - - public final String toCamelCase(String str) { - return ContextUtil.toCamelCase(str); - } - - public final String wrap(String str, int wrapLength) { - return ContextUtil.wrap(str, wrapLength); - } - - public final String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords) { - return ContextUtil.wrap(str, wrapLength, newLineStr, wrapLongWords); - } - - public final String escapeJava(String input) { - return ContextUtil.escapeJava(input); - } - - public final String escapeEcmaScript(String input) { - return ContextUtil.escapeEcmaScript(input); - } - - public final String escapeJson(String input) { - return ContextUtil.escapeJson(input); - } - - public final String unescapeJava(String input) { - return ContextUtil.unescapeJava(input); - } - - public final String unescapeEcmaScript(String input) { - return ContextUtil.unescapeEcmaScript(input); - } - - public final String unescapeJson(String input) { - return ContextUtil.unescapeJson(input); - } - - public final String escapeHtml4(String input) { - return ContextUtil.escapeHtml4(input); - } - - public final String escapeHtml3(String input) { - return ContextUtil.escapeHtml3(input); - } - - public final String unescapeHtml4(String input) { - return ContextUtil.unescapeHtml4(input); - } - - public final String unescapeHtml3(String input) { - return ContextUtil.unescapeHtml3(input); - } - - public final String escapeXml(String input) { - return ContextUtil.escapeXml(input); - } - - public final String escapeXml10(String input) { - return ContextUtil.escapeXml10(input); - } - - public final String escapeXml11(String input) { - return ContextUtil.escapeXml11(input); - } - - public final String unescapeXml(String input) { - return ContextUtil.unescapeXml(input); - } - - public final String escapeCsv(String input) { - return ContextUtil.escapeCsv(input); - } - - public final String unescapeCsv(String input) { - return ContextUtil.unescapeCsv(input); - } - - public final boolean isEmpty(CharSequence cs) { - return ContextUtil.isEmpty(cs); - } - - public final boolean isNotEmpty(CharSequence cs) { - return ContextUtil.isNotEmpty(cs); - } - - public final boolean isAnyEmpty(CharSequence... css) { - return ContextUtil.isAnyEmpty(css); - } - - public final boolean isNoneEmpty(CharSequence... css) { - return ContextUtil.isNoneEmpty(css); - } - - public final boolean isBlank(CharSequence cs) { - return ContextUtil.isBlank(cs); - } - - public final boolean isNotBlank(CharSequence cs) { - return ContextUtil.isNotBlank(cs); - } - - public final boolean isAnyBlank(CharSequence... css) { - return ContextUtil.isAnyBlank(css); - } - - public final boolean isNoneBlank(CharSequence... css) { - return ContextUtil.isNoneBlank(css); - } - - public final String trim(String str) { - return ContextUtil.trim(str); - } - - public final String trimToNull(String str) { - return ContextUtil.trimToNull(str); - } - - public final String trimToEmpty(String str) { - return ContextUtil.trimToEmpty(str); - } - - public final String strip(String str) { - return ContextUtil.strip(str); - } - - public final String stripToNull(String str) { - return ContextUtil.stripToNull(str); - } - - public final String stripToEmpty(String str) { - return ContextUtil.stripToEmpty(str); - } - - public final String strip(String str, String stripChars) { - return ContextUtil.strip(str, stripChars); - } - - public final String stripStart(String str, String stripChars) { - return ContextUtil.stripStart(str, stripChars); - } - - public final String stripEnd(String str, String stripChars) { - return ContextUtil.stripEnd(str, stripChars); - } - - public final String[] stripAll(String... strs) { - return ContextUtil.stripAll(strs); - } - - public final String[] stripAll(String[] strs, String stripChars) { - return ContextUtil.stripAll(strs, stripChars); - } - - public final String stripAccents(String input) { - return ContextUtil.stripAccents(input); - } - - public final boolean equals(CharSequence cs1, CharSequence cs2) { - return ContextUtil.equals(cs1, cs2); - } - - public final boolean equalsIgnoreCase(CharSequence str1, CharSequence str2) { - return ContextUtil.equalsIgnoreCase(str1, str2); - } - - public final int indexOf(CharSequence seq, int searchChar) { - return ContextUtil.indexOf(seq, searchChar); - } - - public final int indexOf(CharSequence seq, int searchChar, int startPos) { - return ContextUtil.indexOf(seq, searchChar, startPos); - } - - public final int indexOf(CharSequence seq, CharSequence searchSeq) { - return ContextUtil.indexOf(seq, searchSeq); - } - - public final int indexOf(CharSequence seq, CharSequence searchSeq, int startPos) { - return ContextUtil.indexOf(seq, searchSeq, startPos); - } - - public final int ordinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal) { - return ContextUtil.ordinalIndexOf(str, searchStr, ordinal); - } - - public final int indexOfIgnoreCase(CharSequence str, CharSequence searchStr) { - return ContextUtil.indexOfIgnoreCase(str, searchStr); - } - - public final int indexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos) { - return ContextUtil.indexOfIgnoreCase(str, searchStr, startPos); - } - - public final int lastIndexOf(CharSequence seq, int searchChar) { - return ContextUtil.lastIndexOf(seq, searchChar); - } - - public final int lastIndexOf(CharSequence seq, int searchChar, int startPos) { - return ContextUtil.lastIndexOf(seq, searchChar, startPos); - } - - public final int lastIndexOf(CharSequence seq, CharSequence searchSeq) { - return ContextUtil.lastIndexOf(seq, searchSeq); - } - - public final int lastOrdinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal) { - return ContextUtil.lastOrdinalIndexOf(str, searchStr, ordinal); - } - - public final int lastIndexOf(CharSequence seq, CharSequence searchSeq, int startPos) { - return ContextUtil.lastIndexOf(seq, searchSeq, startPos); - } - - public final int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr) { - return ContextUtil.lastIndexOfIgnoreCase(str, searchStr); - } - - public final int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos) { - return ContextUtil.lastIndexOfIgnoreCase(str, searchStr, startPos); - } - - public final boolean contains(CharSequence seq, int searchChar) { - return ContextUtil.contains(seq, searchChar); - } - - public final boolean contains(CharSequence seq, CharSequence searchSeq) { - return ContextUtil.contains(seq, searchSeq); - } - - public final boolean containsIgnoreCase(CharSequence str, CharSequence searchStr) { - return ContextUtil.containsIgnoreCase(str, searchStr); - } - - public final boolean containsWhitespace(CharSequence seq) { - return ContextUtil.containsWhitespace(seq); - } - - public final int indexOfAny(CharSequence cs, char... searchChars) { - return ContextUtil.indexOfAny(cs, searchChars); - } - - public final int indexOfAny(CharSequence cs, String searchChars) { - return ContextUtil.indexOfAny(cs, searchChars); - } - - public final boolean containsAny(CharSequence cs, char... searchChars) { - return ContextUtil.containsAny(cs, searchChars); - } - - public final boolean containsAny(CharSequence cs, CharSequence searchChars) { - return ContextUtil.containsAny(cs, searchChars); - } - - public final boolean containsAny(CharSequence cs, CharSequence... searchCharSequences) { - return ContextUtil.containsAny(cs, searchCharSequences); - } - - public final int indexOfAnyBut(CharSequence cs, char... searchChars) { - return ContextUtil.indexOfAnyBut(cs, searchChars); - } - - public final int indexOfAnyBut(CharSequence seq, CharSequence searchChars) { - return ContextUtil.indexOfAnyBut(seq, searchChars); - } - - public final boolean containsOnly(CharSequence cs, char... valid) { - return ContextUtil.containsOnly(cs, valid); - } - - public final boolean containsOnly(CharSequence cs, String validChars) { - return ContextUtil.containsOnly(cs, validChars); - } - - public final boolean containsNone(CharSequence cs, char... searchChars) { - return ContextUtil.containsNone(cs, searchChars); - } - - public final boolean containsNone(CharSequence cs, String invalidChars) { - return ContextUtil.containsNone(cs, invalidChars); - } - - public final int indexOfAny(CharSequence str, CharSequence... searchStrs) { - return ContextUtil.indexOfAny(str, searchStrs); - } - - public final int lastIndexOfAny(CharSequence str, CharSequence... searchStrs) { - return ContextUtil.lastIndexOfAny(str, searchStrs); - } - - public final String substring(String str, int start) { - return ContextUtil.substring(str, start); - } - - public final String substring(String str, int start, int end) { - return ContextUtil.substring(str, start, end); - } - - public final String left(String str, int len) { - return ContextUtil.left(str, len); - } - - public final String right(String str, int len) { - return ContextUtil.right(str, len); - } - - public final String mid(String str, int pos, int len) { - return ContextUtil.mid(str, pos, len); - } - - public final String substringBefore(String str, String separator) { - return ContextUtil.substringBefore(str, separator); - } - - public final String substringAfter(String str, String separator) { - return ContextUtil.substringAfter(str, separator); - } - - public final String substringBeforeLast(String str, String separator) { - return ContextUtil.substringBeforeLast(str, separator); - } - - public final String substringAfterLast(String str, String separator) { - return ContextUtil.substringAfterLast(str, separator); - } - - public final String substringBetween(String str, String tag) { - return ContextUtil.substringBetween(str, tag); - } - - public final String substringBetween(String str, String open, String close) { - return ContextUtil.substringBetween(str, open, close); - } - - public final String[] substringsBetween(String str, String open, String close) { - return ContextUtil.substringsBetween(str, open, close); - } - - public final String[] split(String str) { - return ContextUtil.split(str); - } - - public final String[] split(String str, char separatorChar) { - return ContextUtil.split(str, separatorChar); - } - - public final String[] split(String str, String separatorChars) { - return ContextUtil.split(str, separatorChars); - } - - public final String[] split(String str, String separatorChars, int max) { - return ContextUtil.split(str, separatorChars, max); - } - - public final String[] splitByWholeSeparator(String str, String separator) { - return ContextUtil.splitByWholeSeparator(str, separator); - } - - public final String[] splitByWholeSeparator(String str, String separator, int max) { - return ContextUtil.splitByWholeSeparator(str, separator, max); - } - - public final String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator) { - return ContextUtil.splitByWholeSeparatorPreserveAllTokens(str, separator); - } - - public final String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max) { - return ContextUtil.splitByWholeSeparatorPreserveAllTokens(str, separator, max); - } - - public final String[] splitPreserveAllTokens(String str) { - return ContextUtil.splitPreserveAllTokens(str); - } - - public final String[] splitPreserveAllTokens(String str, char separatorChar) { - return ContextUtil.splitPreserveAllTokens(str, separatorChar); - } - - public final String[] splitPreserveAllTokens(String str, String separatorChars) { - return ContextUtil.splitPreserveAllTokens(str, separatorChars); - } - - public final String[] splitPreserveAllTokens(String str, String separatorChars, int max) { - return ContextUtil.splitPreserveAllTokens(str, separatorChars, max); - } - - public final String[] splitByCharacterType(String str) { - return ContextUtil.splitByCharacterType(str); - } - - public final String[] splitByCharacterTypeCamelCase(String str) { - return ContextUtil.splitByCharacterTypeCamelCase(str); - } - - public final String join(T... elements) { - return ContextUtil.join(elements); - } - - public final String join(Object[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(long[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(int[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(short[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(byte[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(char[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(float[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(double[] array, char separator) { - return ContextUtil.join(array, separator); - } - - public final String join(Object[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(long[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(int[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(byte[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(short[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(char[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(double[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(float[] array, char separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(Object[] array, String separator) { - return ContextUtil.join(array, separator); - } - - public final String join(Object[] array, String separator, int startIndex, int endIndex) { - return ContextUtil.join(array, separator, startIndex, endIndex); - } - - public final String join(Iterator iterator, char separator) { - return ContextUtil.join(iterator, separator); - } - - public final String join(Iterator iterator, String separator) { - return ContextUtil.join(iterator, separator); - } - - public final String join(Iterable iterable, char separator) { - return ContextUtil.join(iterable, separator); - } - - public final String join(Iterable iterable, String separator) { - return ContextUtil.join(iterable, separator); - } - - public final String deleteWhitespace(String str) { - return ContextUtil.deleteWhitespace(str); - } - - public final String removeStart(String str, String remove) { - return ContextUtil.removeStart(str, remove); - } - - public final String removeStartIgnoreCase(String str, String remove) { - return ContextUtil.removeStartIgnoreCase(str, remove); - } - - public final String removeEnd(String str, String remove) { - return ContextUtil.removeEnd(str, remove); - } - - public final String removeEndIgnoreCase(String str, String remove) { - return ContextUtil.removeEndIgnoreCase(str, remove); - } - - public final String remove(String str, String remove) { - return ContextUtil.remove(str, remove); - } - - public final String remove(String str, char remove) { - return ContextUtil.remove(str, remove); - } - - public final String replaceOnce(String text, String searchString, String replacement) { - return ContextUtil.replaceOnce(text, searchString, replacement); - } - - public final String replacePattern(String source, String regex, String replacement) { - return ContextUtil.replacePattern(source, regex, replacement); - } - - public final String removePattern(String source, String regex) { - return ContextUtil.removePattern(source, regex); - } - - public final String replace(String text, String searchString, String replacement) { - return ContextUtil.replace(text, searchString, replacement); - } - - public final String replace(String text, String searchString, String replacement, int max) { - return ContextUtil.replace(text, searchString, replacement, max); - } - - public final String replaceEach(String text, String[] searchList, String[] replacementList) { - return ContextUtil.replaceEach(text, searchList, replacementList); - } - - public final String replaceEachRepeatedly(String text, String[] searchList, String[] replacementList) { - return ContextUtil.replaceEachRepeatedly(text, searchList, replacementList); - } - - public final String replaceChars(String str, char searchChar, char replaceChar) { - return ContextUtil.replaceChars(str, searchChar, replaceChar); - } - - public final String replaceChars(String str, String searchChars, String replaceChars) { - return ContextUtil.replaceChars(str, searchChars, replaceChars); - } - - public final String overlay(String str, String overlay, int start, int end) { - return ContextUtil.overlay(str, overlay, start, end); - } - - public final String chomp(String str) { - return ContextUtil.chomp(str); - } - - @Deprecated - public final String chomp(String str, String separator) { - return ContextUtil.chomp(str, separator); - } - - public final String chop(String str) { - return ContextUtil.chop(str); - } - - public final String repeat(String str, int repeat) { - return ContextUtil.repeat(str, repeat); - } - - public final String repeat(String str, String separator, int repeat) { - return ContextUtil.repeat(str, separator, repeat); - } - - public final String repeat(char ch, int repeat) { - return ContextUtil.repeat(ch, repeat); - } - - public final String rightPad(String str, int size) { - return ContextUtil.rightPad(str, size); - } - - public final String rightPad(String str, int size, char padChar) { - return ContextUtil.rightPad(str, size, padChar); - } - - public final String rightPad(String str, int size, String padStr) { - return ContextUtil.rightPad(str, size, padStr); - } - - public final String leftPad(String str, int size) { - return ContextUtil.leftPad(str, size); - } - - public final String leftPad(String str, int size, char padChar) { - return ContextUtil.leftPad(str, size, padChar); - } - - public final String leftPad(String str, int size, String padStr) { - return ContextUtil.leftPad(str, size, padStr); - } - - public final int length(CharSequence cs) { - return ContextUtil.length(cs); - } - - public final String center(String str, int size) { - return ContextUtil.center(str, size); - } - - public final String center(String str, int size, char padChar) { - return ContextUtil.center(str, size, padChar); - } - - public final String center(String str, int size, String padStr) { - return ContextUtil.center(str, size, padStr); - } - - public final String upperCase(String str) { - return ContextUtil.upperCase(str); - } - - public final String upperCase(String str, Locale locale) { - return ContextUtil.upperCase(str, locale); - } - - public final String lowerCase(String str) { - return ContextUtil.lowerCase(str); - } - - public final String lowerCase(String str, Locale locale) { - return ContextUtil.lowerCase(str, locale); - } - - public final String capitalize(String str) { - return ContextUtil.capitalize(str); - } - - public final String capitalize(String str, char... delimiters) { - return ContextUtil.capitalize(str, delimiters); - } - - public final String capitalizeFully(String str) { - return ContextUtil.capitalizeFully(str); - } - - public final String capitalizeFully(String str, char... delimiters) { - return ContextUtil.capitalizeFully(str, delimiters); - } - - public final String uncapitalize(String str) { - return ContextUtil.uncapitalize(str); - } - - public final String uncapitalize(String str, char... delimiters) { - return ContextUtil.uncapitalize(str, delimiters); - } - - public final String swapCase(String str) { - return ContextUtil.swapCase(str); - } - - public final String initials(String str) { - return ContextUtil.initials(str); - } - - public final String initials(String str, char... delimiters) { - return ContextUtil.initials(str, delimiters); - } - - public final int countMatches(CharSequence str, CharSequence sub) { - return ContextUtil.countMatches(str, sub); - } - - public final int countMatches(CharSequence str, char ch) { - return ContextUtil.countMatches(str, ch); - } - - public final boolean isAlpha(CharSequence cs) { - return ContextUtil.isAlpha(cs); - } - - public final boolean isAlphaSpace(CharSequence cs) { - return ContextUtil.isAlphaSpace(cs); - } - - public final boolean isAlphanumeric(CharSequence cs) { - return ContextUtil.isAlphanumeric(cs); - } - - public final boolean isAlphanumericSpace(CharSequence cs) { - return ContextUtil.isAlphanumericSpace(cs); - } - - public final boolean isAsciiPrintable(CharSequence cs) { - return ContextUtil.isAsciiPrintable(cs); - } - - public final boolean isNumeric(CharSequence cs) { - return ContextUtil.isNumeric(cs); - } - - public final boolean isNumericSpace(CharSequence cs) { - return ContextUtil.isNumericSpace(cs); - } - - public final boolean isWhitespace(CharSequence cs) { - return ContextUtil.isWhitespace(cs); - } - - public final boolean isAllLowerCase(CharSequence cs) { - return ContextUtil.isAllLowerCase(cs); - } - - public final boolean isAllUpperCase(CharSequence cs) { - return ContextUtil.isAllUpperCase(cs); - } - - public final String defaultString(String str) { - return ContextUtil.defaultString(str); - } - - public final String defaultString(String str, String defaultStr) { - return ContextUtil.defaultString(str, defaultStr); - } - - public final T defaultIfBlank(T str, T defaultStr) { - return ContextUtil.defaultIfBlank(str, defaultStr); - } - - public final T defaultIfEmpty(T str, T defaultStr) { - return ContextUtil.defaultIfEmpty(str, defaultStr); - } - - public final String reverse(String str) { - return ContextUtil.reverse(str); - } - - public final String reverseDelimited(String str, char separatorChar) { - return ContextUtil.reverseDelimited(str, separatorChar); - } - - public final String abbreviate(String str, int maxWidth) { - return ContextUtil.abbreviate(str, maxWidth); - } - - public final String abbreviate(String str, int offset, int maxWidth) { - return ContextUtil.abbreviate(str, offset, maxWidth); - } - - public final String abbreviateMiddle(String str, String middle, int length) { - return ContextUtil.abbreviateMiddle(str, middle, length); - } - - public final String difference(String str1, String str2) { - return ContextUtil.difference(str1, str2); - } - - public final int indexOfDifference(CharSequence cs1, CharSequence cs2) { - return ContextUtil.indexOfDifference(cs1, cs2); - } - - public final int indexOfDifference(CharSequence... css) { - return ContextUtil.indexOfDifference(css); - } - - public final String getCommonPrefix(String... strs) { - return ContextUtil.getCommonPrefix(strs); - } - - public final int getLevenshteinDistance(CharSequence s, CharSequence t) { - return ContextUtil.getLevenshteinDistance(s, t); - } - - public final int getLevenshteinDistance(CharSequence s, CharSequence t, int threshold) { - return ContextUtil.getLevenshteinDistance(s, t, threshold); - } - - public final double getJaroWinklerDistance(CharSequence first, CharSequence second) { - return ContextUtil.getJaroWinklerDistance(first, second); - } - - public final int getFuzzyDistance(CharSequence term, CharSequence query, Locale locale) { - return ContextUtil.getFuzzyDistance(term, query, locale); - } - - public final boolean startsWith(CharSequence str, CharSequence prefix) { - return ContextUtil.startsWith(str, prefix); - } - - public final boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix) { - return ContextUtil.startsWithIgnoreCase(str, prefix); - } - - public final boolean startsWithAny(CharSequence string, CharSequence... searchStrings) { - return ContextUtil.startsWithAny(string, searchStrings); - } - - public final boolean endsWith(CharSequence str, CharSequence suffix) { - return ContextUtil.endsWith(str, suffix); - } - - public final boolean endsWithIgnoreCase(CharSequence str, CharSequence suffix) { - return ContextUtil.endsWithIgnoreCase(str, suffix); - } - - public final String normalizeSpace(String str) { - return ContextUtil.normalizeSpace(str); - } - - public final boolean endsWithAny(CharSequence string, CharSequence... searchStrings) { - return ContextUtil.endsWithAny(string, searchStrings); - } - - public final String appendIfMissing(String str, CharSequence suffix, CharSequence... suffixes) { - return ContextUtil.appendIfMissing(str, suffix, suffixes); - } - - public final String appendIfMissingIgnoreCase(String str, CharSequence suffix, CharSequence... suffixes) { - return ContextUtil.appendIfMissingIgnoreCase(str, suffix, suffixes); - } - - public final String prependIfMissing(String str, CharSequence prefix, CharSequence... prefixes) { - return ContextUtil.prependIfMissing(str, prefix, prefixes); - } - - public final String prependIfMissingIgnoreCase(String str, CharSequence prefix, CharSequence... prefixes) { - return ContextUtil.prependIfMissingIgnoreCase(str, prefix, prefixes); - } - - @Deprecated - public final String toString(byte[] bytes, String charsetName) throws UnsupportedEncodingException { - return ContextUtil.toString(bytes, charsetName); - } - - public final String toEncodedString(byte[] bytes, Charset charset) { - return ContextUtil.toEncodedString(bytes, charset); - } - - public final String wrap(String str, char wrapWith) { - return ContextUtil.wrap(str, wrapWith); - } - - public final String wrap(String str, String wrapWith) { - return ContextUtil.wrap(str, wrapWith); - } - - public final int toInt(String str) { - return ContextUtil.toInt(str); - } - - public final int toInt(String str, int defaultValue) { - return ContextUtil.toInt(str, defaultValue); - } - - public final long toLong(String str) { - return ContextUtil.toLong(str); - } - - public final long toLong(String str, long defaultValue) { - return ContextUtil.toLong(str, defaultValue); - } - - public final float toFloat(String str) { - return ContextUtil.toFloat(str); - } - - public final float toFloat(String str, float defaultValue) { - return ContextUtil.toFloat(str, defaultValue); - } - - public final double toDouble(String str) { - return ContextUtil.toDouble(str); - } - - public final double toDouble(String str, double defaultValue) { - return ContextUtil.toDouble(str, defaultValue); - } - - public final byte toByte(String str) { - return ContextUtil.toByte(str); - } - - public final byte toByte(String str, byte defaultValue) { - return ContextUtil.toByte(str, defaultValue); - } - - public final short toShort(String str) { - return ContextUtil.toShort(str); - } - - public final short toShort(String str, short defaultValue) { - return ContextUtil.toShort(str, defaultValue); - } - - public final Number createNumber(String str) throws NumberFormatException { - return ContextUtil.createNumber(str); - } - - public final Float createFloat(String str) { - return ContextUtil.createFloat(str); - } - - public final Double createDouble(String str) { - return ContextUtil.createDouble(str); - } - - public final Integer createInteger(String str) { - return ContextUtil.createInteger(str); - } - - public final Long createLong(String str) { - return ContextUtil.createLong(str); - } - - public final BigInteger createBigInteger(String str) { - return ContextUtil.createBigInteger(str); - } - - public final BigDecimal createBigDecimal(String str) { - return ContextUtil.createBigDecimal(str); - } - - public final long min(long... array) { - return ContextUtil.min(array); - } - - public final int min(int... array) { - return ContextUtil.min(array); - } - - public final short min(short... array) { - return ContextUtil.min(array); - } - - public final byte min(byte... array) { - return ContextUtil.min(array); - } - - public final double min(double... array) { - return ContextUtil.min(array); - } - - public final float min(float... array) { - return ContextUtil.min(array); - } - - public final long max(long... array) { - return ContextUtil.max(array); - } - - public final int max(int... array) { - return ContextUtil.max(array); - } - - public final short max(short... array) { - return ContextUtil.max(array); - } - - public final byte max(byte... array) { - return ContextUtil.max(array); - } - - public final double max(double... array) { - return ContextUtil.max(array); - } - - public final float max(float... array) { - return ContextUtil.max(array); - } - - public final long min(long a, long b, long c) { - return ContextUtil.min(a, b, c); - } - - public final int min(int a, int b, int c) { - return ContextUtil.min(a, b, c); - } - - public final short min(short a, short b, short c) { - return ContextUtil.min(a, b, c); - } - - public final byte min(byte a, byte b, byte c) { - return ContextUtil.min(a, b, c); - } - - public final double min(double a, double b, double c) { - return ContextUtil.min(a, b, c); - } - - public final float min(float a, float b, float c) { - return ContextUtil.min(a, b, c); - } - - public final long max(long a, long b, long c) { - return ContextUtil.max(a, b, c); - } - - public final int max(int a, int b, int c) { - return ContextUtil.max(a, b, c); - } - - public final short max(short a, short b, short c) { - return ContextUtil.max(a, b, c); - } - - public final byte max(byte a, byte b, byte c) { - return ContextUtil.max(a, b, c); - } - - public final double max(double a, double b, double c) { - return ContextUtil.max(a, b, c); - } - - public final float max(float a, float b, float c) { - return ContextUtil.max(a, b, c); - } - - public final boolean isDigits(String str) { - return ContextUtil.isDigits(str); - } - - public final boolean isNumber(String str) { - return ContextUtil.isNumber(str); - } - - public final boolean isParsable(String str) { - return ContextUtil.isParsable(str); - } - - public final int compare(int x, int y) { - return ContextUtil.compare(x, y); - } - - public final int compare(long x, long y) { - return ContextUtil.compare(x, y); - } - - public final int compare(short x, short y) { - return ContextUtil.compare(x, y); - } - - public final int compare(byte x, byte y) { - return ContextUtil.compare(x, y); - } - - public final Boolean negate(Boolean bool) { - return ContextUtil.negate(bool); - } - - public final boolean isTrue(Boolean bool) { - return ContextUtil.isTrue(bool); - } - - public final boolean isNotTrue(Boolean bool) { - return ContextUtil.isNotTrue(bool); - } - - public final boolean isFalse(Boolean bool) { - return ContextUtil.isFalse(bool); - } - - public final boolean isNotFalse(Boolean bool) { - return ContextUtil.isNotFalse(bool); - } - - public final boolean toBoolean(Boolean bool) { - return ContextUtil.toBoolean(bool); - } - - public final boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) { - return ContextUtil.toBooleanDefaultIfNull(bool, valueIfNull); - } - - public final boolean toBoolean(int value) { - return ContextUtil.toBoolean(value); - } - - public final Boolean toBooleanObject(int value) { - return ContextUtil.toBooleanObject(value); - } - - public final Boolean toBooleanObject(Integer value) { - return ContextUtil.toBooleanObject(value); - } - - public final boolean toBoolean(int value, int trueValue, int falseValue) { - return ContextUtil.toBoolean(value, trueValue, falseValue); - } - - public final boolean toBoolean(Integer value, Integer trueValue, Integer falseValue) { - return ContextUtil.toBoolean(value, trueValue, falseValue); - } - - public final Boolean toBooleanObject(int value, int trueValue, int falseValue, int nullValue) { - return ContextUtil.toBooleanObject(value, trueValue, falseValue, nullValue); - } - - public final Boolean toBooleanObject(Integer value, Integer trueValue, Integer falseValue, Integer nullValue) { - return ContextUtil.toBooleanObject(value, trueValue, falseValue, nullValue); - } - - public final int toInteger(boolean bool) { - return ContextUtil.toInteger(bool); - } - - public final Integer toIntegerObject(boolean bool) { - return ContextUtil.toIntegerObject(bool); - } - - public final Integer toIntegerObject(Boolean bool) { - return ContextUtil.toIntegerObject(bool); - } - - public final int toInteger(boolean bool, int trueValue, int falseValue) { - return ContextUtil.toInteger(bool, trueValue, falseValue); - } - - public final int toInteger(Boolean bool, int trueValue, int falseValue, int nullValue) { - return ContextUtil.toInteger(bool, trueValue, falseValue, nullValue); - } - - public final Integer toIntegerObject(boolean bool, Integer trueValue, Integer falseValue) { - return ContextUtil.toIntegerObject(bool, trueValue, falseValue); - } - - public final Integer toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue) { - return ContextUtil.toIntegerObject(bool, trueValue, falseValue, nullValue); - } + File _fn = new File(_file); + if(!_fn.exists()) + { + _fn = new File(this.context.processParent, _file); + } - public final Boolean toBooleanObject(String str) { - return ContextUtil.toBooleanObject(str); - } - - public final Boolean toBooleanObject(String str, String trueString, String falseString, String nullString) { - return ContextUtil.toBooleanObject(str, trueString, falseString, nullString); - } - - public final boolean toBoolean(String str) { - return ContextUtil.toBoolean(str); - } - - public final boolean toBoolean(String str, String trueString, String falseString) { - return ContextUtil.toBoolean(str, trueString, falseString); - } - - public final String toStringTrueFalse(Boolean bool) { - return ContextUtil.toStringTrueFalse(bool); - } - - public final String toStringOnOff(Boolean bool) { - return ContextUtil.toStringOnOff(bool); - } - - public final String toStringYesNo(Boolean bool) { - return ContextUtil.toStringYesNo(bool); - } - - public final String toString(Boolean bool, String trueString, String falseString, String nullString) { - return ContextUtil.toString(bool, trueString, falseString, nullString); - } - - public final String toStringTrueFalse(boolean bool) { - return ContextUtil.toStringTrueFalse(bool); - } - - public final String toStringOnOff(boolean bool) { - return ContextUtil.toStringOnOff(bool); - } - - public final String toStringYesNo(boolean bool) { - return ContextUtil.toStringYesNo(bool); - } - - public final String toString(boolean bool, String trueString, String falseString) { - return ContextUtil.toString(bool, trueString, falseString); - } - - public final boolean and(boolean... array) { - return ContextUtil.and(array); - } - - public final Boolean and(Boolean... array) { - return ContextUtil.and(array); - } - - public final boolean or(boolean... array) { - return ContextUtil.or(array); - } - - public final Boolean or(Boolean... array) { - return ContextUtil.or(array); - } - - public final boolean xor(boolean... array) { - return ContextUtil.xor(array); - } - - public final Boolean xor(Boolean... array) { - return ContextUtil.xor(array); - } - - public final int compare(boolean x, boolean y) { - return ContextUtil.compare(x, y); - } - - public final boolean checkBoolean(Object _str) { - return ContextUtil.checkBoolean(_str); - } - - public final boolean checkBoolean(String _str) { - return ContextUtil.checkBoolean(_str); - } - - public final byte[] decodeHex(String data) throws DecoderException { - return ContextUtil.decodeHex(data); - } - - public final byte[] decodeHex(char[] data) throws DecoderException { - return ContextUtil.decodeHex(data); - } - - public final char[] encodeHex(byte[] data) { - return ContextUtil.encodeHex(data); - } - - public final char[] encodeHex(byte[] data, boolean toLowerCase) { - return ContextUtil.encodeHex(data, toLowerCase); - } - - public final String encodeHexString(byte[] data) { - return ContextUtil.encodeHexString(data); - } - - public final String encodeHexString(byte[] data, boolean toLowerCase) { - return ContextUtil.encodeHexString(data, toLowerCase); - } - - @SneakyThrows - public final String encodePercent(String _raw) { - return ContextUtil.encodePercent(_raw); - } - - @SneakyThrows - public final String decodePercent(String _cooked) { - return ContextUtil.decodePercent(_cooked); - } - - @SneakyThrows - public final String encodeUrl(String _raw) { - return ContextUtil.encodeUrl(_raw); - } - - @SneakyThrows - public final String decodeUrl(String _cooked) { - return ContextUtil.decodeUrl(_cooked); - } - - public final boolean isSameDay(Date date1, Date date2) { - return ContextUtil.isSameDay(date1, date2); - } - - public final boolean isSameDay(Calendar cal1, Calendar cal2) { - return ContextUtil.isSameDay(cal1, cal2); - } - - public final boolean isSameInstant(Date date1, Date date2) { - return ContextUtil.isSameInstant(date1, date2); - } - - public final boolean isSameInstant(Calendar cal1, Calendar cal2) { - return ContextUtil.isSameInstant(cal1, cal2); - } - - public final boolean isSameLocalTime(Calendar cal1, Calendar cal2) { - return ContextUtil.isSameLocalTime(cal1, cal2); - } - - public final Date parseDate(String str, String... parsePatterns) throws ParseException { - return ContextUtil.parseDate(str, parsePatterns); - } - - public final Date parseDate(String str, Locale locale, String... parsePatterns) throws ParseException { - return ContextUtil.parseDate(str, locale, parsePatterns); - } - - public final Date parseDateStrictly(String str, String... parsePatterns) throws ParseException { - return ContextUtil.parseDateStrictly(str, parsePatterns); - } - - public final Date parseDateStrictly(String str, Locale locale, String... parsePatterns) throws ParseException { - return ContextUtil.parseDateStrictly(str, locale, parsePatterns); - } - - public final Date addYears(Date date, int amount) { - return ContextUtil.addYears(date, amount); - } - - public final Date addMonths(Date date, int amount) { - return ContextUtil.addMonths(date, amount); - } - - public final Date addWeeks(Date date, int amount) { - return ContextUtil.addWeeks(date, amount); - } - - public final Date addDays(Date date, int amount) { - return ContextUtil.addDays(date, amount); - } - - public final Date addHours(Date date, int amount) { - return ContextUtil.addHours(date, amount); - } - - public final Date addMinutes(Date date, int amount) { - return ContextUtil.addMinutes(date, amount); - } - - public final Date addSeconds(Date date, int amount) { - return ContextUtil.addSeconds(date, amount); - } - - public final Date addMilliseconds(Date date, int amount) { - return ContextUtil.addMilliseconds(date, amount); - } - - public final Date setYears(Date date, int amount) { - return ContextUtil.setYears(date, amount); - } - - public final Date setMonths(Date date, int amount) { - return ContextUtil.setMonths(date, amount); - } - - public final Date setDays(Date date, int amount) { - return ContextUtil.setDays(date, amount); - } - - public final Date setHours(Date date, int amount) { - return ContextUtil.setHours(date, amount); - } - - public final Date setMinutes(Date date, int amount) { - return ContextUtil.setMinutes(date, amount); - } - - public final Date setSeconds(Date date, int amount) { - return ContextUtil.setSeconds(date, amount); - } - - public final Date setMilliseconds(Date date, int amount) { - return ContextUtil.setMilliseconds(date, amount); - } - - public final Calendar toCalendar(Date date) { - return ContextUtil.toCalendar(date); - } - - public final Calendar toCalendar(Date date, TimeZone tz) { - return ContextUtil.toCalendar(date, tz); - } - - public final Date dateRound(Date date, int field) { - return ContextUtil.dateRound(date, field); - } - - public final Calendar dateRound(Calendar date, int field) { - return ContextUtil.dateRound(date, field); - } - - public final Date dateRound(Object date, int field) { - return ContextUtil.dateRound(date, field); - } - - public final Date dateTruncate(Date date, int field) { - return ContextUtil.dateTruncate(date, field); - } - - public final Calendar dateTruncate(Calendar date, int field) { - return ContextUtil.dateTruncate(date, field); - } - - public final Date dateTruncate(Object date, int field) { - return ContextUtil.dateTruncate(date, field); - } - - public final Date dateCeiling(Date date, int field) { - return ContextUtil.dateCeiling(date, field); - } - - public final Calendar dateCeiling(Calendar date, int field) { - return ContextUtil.dateCeiling(date, field); - } - - public final Date dateCeiling(Object date, int field) { - return ContextUtil.dateCeiling(date, field); - } - - public final Iterator dateIterator(Date focus, int rangeStyle) { - return ContextUtil.dateIterator(focus, rangeStyle); - } - - public final Iterator dateIterator(Calendar focus, int rangeStyle) { - return ContextUtil.dateIterator(focus, rangeStyle); - } - - public final Iterator dateIterator(Object focus, int rangeStyle) { - return ContextUtil.dateIterator(focus, rangeStyle); - } - - public final long getFragmentInMilliseconds(Date date, int fragment) { - return ContextUtil.getFragmentInMilliseconds(date, fragment); - } - - public final long getFragmentInSeconds(Date date, int fragment) { - return ContextUtil.getFragmentInSeconds(date, fragment); - } - - public final long getFragmentInMinutes(Date date, int fragment) { - return ContextUtil.getFragmentInMinutes(date, fragment); - } - - public final long getFragmentInHours(Date date, int fragment) { - return ContextUtil.getFragmentInHours(date, fragment); - } - - public final long getFragmentInDays(Date date, int fragment) { - return ContextUtil.getFragmentInDays(date, fragment); - } - - public final long getFragmentInMilliseconds(Calendar calendar, int fragment) { - return ContextUtil.getFragmentInMilliseconds(calendar, fragment); - } - - public final long getFragmentInSeconds(Calendar calendar, int fragment) { - return ContextUtil.getFragmentInSeconds(calendar, fragment); - } - - public final long getFragmentInMinutes(Calendar calendar, int fragment) { - return ContextUtil.getFragmentInMinutes(calendar, fragment); - } - - public final long getFragmentInHours(Calendar calendar, int fragment) { - return ContextUtil.getFragmentInHours(calendar, fragment); - } - - public final long getFragmentInDays(Calendar calendar, int fragment) { - return ContextUtil.getFragmentInDays(calendar, fragment); - } - - public final boolean dateTruncatedEquals(Calendar cal1, Calendar cal2, int field) { - return ContextUtil.dateTruncatedEquals(cal1, cal2, field); - } - - public final boolean dateTruncatedEquals(Date date1, Date date2, int field) { - return ContextUtil.dateTruncatedEquals(date1, date2, field); - } - - public final int dateTruncatedCompareTo(Calendar cal1, Calendar cal2, int field) { - return ContextUtil.dateTruncatedCompareTo(cal1, cal2, field); - } - - public final int dateTruncatedCompareTo(Date date1, Date date2, int field) { - return ContextUtil.dateTruncatedCompareTo(date1, date2, field); - } - - @SneakyThrows - public final Date dateToTime(String _format, String _text) { - return ContextUtil.dateToTime(_format, _text); - } - - @SneakyThrows - public final Long dateToLong(String _format, String _text) { - return ContextUtil.dateToLong(_format, _text); - } - - public final Date getDate() { - return ContextUtil.getDate(); - } - - public final Long getDateLong() { - return ContextUtil.getDateLong(); - } - - public final String timeToDate(String _format, Date _time) { - return ContextUtil.timeToDate(_format, _time); - } - - public final String timeToDate(String _format, long _time) { - return ContextUtil.timeToDate(_format, _time); - } - - public final String toBase(int _base, long _n) { - return ContextUtil.toBase(_base, _n); - } - - public final String regReplace(String _text, String _expr, String _repl) { - return ContextUtil.regReplace(_text, _expr, _repl); - } - - public final String regReplace(String _text, String _expr, String _repl, int _count) { - return ContextUtil.regReplace(_text, _expr, _repl, _count); - } - - public final String decimalToAscii(String _text) { - return ContextUtil.decimalToAscii(_text); - } - - public final String decimalToHex(String _text) { - return ContextUtil.decimalToHex(_text); - } - - public final String decimalToHex(String _text, String _sep) { - return ContextUtil.decimalToHex(_text, _sep); - } - - public final String decimalToHex(String _text, String _sep, String _delim) { - return ContextUtil.decimalToHex(_text, _sep, _delim); - } - - public final String extract(String s, String rx) { - return ContextUtil.extract(s, rx); - } - - public final String[] extractN(String s, String rx) { - return ContextUtil.extractN(s, rx); - } - - public final String formatMsg(String _fmt, Object... _params) { - return ContextUtil.formatMsg(_fmt, _params); - } - - public final String format(String _fmt, Object... _params) { - return ContextUtil.format(_fmt, _params); - } - - public final boolean fnmatch(String a, String fx) { - return ContextUtil.fnmatch(a, fx); - } - - public final boolean wcmatch(String expr, String value) { - return ContextUtil.wcmatch(expr, value); - } - - public final String randomUUID() { - return ContextUtil.randomUUID(); - } - - public final String randomGUID() { - return ContextUtil.randomGUID(); - } - - public final String toGUID(long _n1, long _n2) { - return ContextUtil.toGUID(_n1, _n2); - } - - public final String toGUID(long _n1, long _n2, long _n3) { - return ContextUtil.toGUID(_n1, _n2, _n3); - } - - public final String toGUID(long _n1, long _n2, long _n3, long _n4) { - return ContextUtil.toGUID(_n1, _n2, _n3, _n4); - } - - public final String toGUID(long _n1, long _n2, long _n3, long _n4, long _n5) { - return ContextUtil.toGUID(_n1, _n2, _n3, _n4, _n5); - } - - public final String toGUID(String _name) { - return ContextUtil.toGUID(_name); - } - - public final String toHashGUID(String _name) { - return ContextUtil.toHashGUID(_name); - } - - public final String toGUID(String _name1, String _name2) { - return ContextUtil.toGUID(_name1, _name2); - } - - public final String toGUID(String _name1, String _name2, String _name3) { - return ContextUtil.toGUID(_name1, _name2, _name3); - } - - public final String toGUID(String _name1, String _name2, Long _l) { - return ContextUtil.toGUID(_name1, _name2, _l); - } - - public final String toGUID(String _name1, String _name2, String _name3, Long _l) { - return ContextUtil.toGUID(_name1, _name2, _name3, _l); - } - - public final String mformat(String _pattern, Object... _objs) { - return ContextUtil.mformat(_pattern, _objs); - } - - public final String sformat(String _pattern, Object... _objs) { - return ContextUtil.sformat(_pattern, _objs); - } - - public final String toHashGUID(String _name1, String _name2) { - return ContextUtil.toHashGUID(_name1, _name2); - } - - public final String toHashGUID(String _name1, String _name2, String _name3) { - return ContextUtil.toHashGUID(_name1, _name2, _name3); - } - - public final Map toMap(List _args) { - return ContextUtil.toMap(_args); - } - - public final Map toMap(Object... _args) { - return ContextUtil.toMap(_args); - } - - public final Map toMap(String _k, Object _v) { - return ContextUtil.toMap(_k, _v); - } - - public final Map fromYaml(String _source) - { - return ContextUtil.fromYaml(_source); - } - - public final Map fromJson(String _source) - { - return ContextUtil.fromJson(_source); - } + if(!_fn.exists()) + { + throw new IllegalArgumentException(MessageFormat.format("File '{0}' not found.", _file)); + } - public final Map fromHjson(String _source) - { - return ContextUtil.fromHjson(_source); + return loadContextFrom(_fn); } - public final Map fromPdata(String _source) - { - return ContextUtil.fromPdata(_source); - } } diff --git a/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextUtil.java b/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextUtil.java index 4ec33c3..9f439ef 100644 --- a/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextUtil.java +++ b/template-maven-plugin/src/main/java/com/github/terefang/template_maven_plugin/util/ContextUtil.java @@ -1,583 +1,212 @@ package com.github.terefang.template_maven_plugin.util; -import com.github.terefang.jmelange.commons.CommonUtil; import com.github.terefang.jmelange.dao.JDAO; import com.github.terefang.jmelange.dao.utils.JdaoUtils; -import com.github.terefang.jmelange.data.DataReadWriteFactory; -import com.github.terefang.jmelange.data.ObjectDataReader; -import com.github.terefang.jmelange.data.ObjectDataWriter; -import com.github.terefang.jmelange.data.RowDataWriter; -import com.github.terefang.jmelange.data.util.CsvUtil; +import com.github.terefang.jmelange.data.*; import com.github.terefang.jmelange.image.PdfImage; import com.github.terefang.jmelange.image.PixelImage; import com.github.terefang.jmelange.image.SvgImage; +import com.github.terefang.jmelange.scripted.util.ScriptHelper; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.codec.digest.HmacUtils; -import org.apache.commons.codec.net.PercentCodec; import org.apache.commons.codec.net.URLCodec; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVParser; -import org.apache.commons.csv.CSVRecord; -import org.apache.commons.csv.QuoteMode; -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.text.CaseUtils; import org.apache.commons.text.StringEscapeUtils; -import org.apache.commons.text.WordUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; -import org.yaml.snakeyaml.Yaml; import java.io.*; -import java.math.BigDecimal; -import java.math.BigInteger; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.MessageFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; @Slf4j -public class ContextUtil { - - public static final String[] EXTENSION_LIST = { - ".props", - ".properties", - ".yaml", - ".yml", - ".json", - ".hson", - ".hjson", - ".tml", - ".toml", - ".ini", - ".pdx", - ".pdata", - ".sqlite.csv", - ".list", - ".scsv", - ".csv", - ".tsv", - ".txt" }; - public static final String EXTENSIONS = StringUtils.join(ContextUtil.EXTENSION_LIST," "); - - public static Map loadContextFrom(String _file) throws MojoExecutionException - { - return loadContextFrom(new File(_file)); - } +public class ContextUtil extends ScriptHelper +{ + DataUtil dataUtil; - @SneakyThrows - public static Map loadContextFrom(File _file) throws MojoExecutionException - { - Map _ret = new HashMap<>(); - InputStream _fh = getStreamBySuffix(_file); - String _fn = unCompressedFilename(_file); - - if(_fn.endsWith(".props") - || _fn.endsWith(".properties")) - { - _ret.putAll(loadContextFromProperties(_fh)); - } - else - if(_fn.endsWith(".yaml") - || _fn.endsWith(".yml")) - { - _ret.putAll(loadContextFromYaml(_fh)); - } - else - if(_fn.endsWith(".json") - || _fn.endsWith(".hson") - || _fn.endsWith(".hjson")) - { - _ret.putAll(loadContextFromHjson(_fh)); - } - else - if(_fn.endsWith(".ini")) - { - _ret.putAll(loadContextFromIni(_fh)); - } - else - if(_fn.endsWith(".pdx") - || _fn.endsWith(".pdata") ) - { - _ret.putAll(loadContextFromPdx(_fh)); - } - else - if(_fn.endsWith(".sqlite.csv")) - { - _ret.putAll(loadContextFromSqliteCsv(_fh)); - } - else - if(_fn.endsWith(".list")) - { - _ret.putAll(loadContextFromSqliteList(_fh)); - } - else - if(_fn.endsWith(".scsv")) - { - _ret.putAll(loadContextFromScsv(_fh)); - } - else - if(_fn.endsWith(".csv")) - { - _ret.putAll(loadContextFromCsv(_fh)); - } - else - if(_fn.endsWith(".tsv")) - { - _ret.putAll(loadContextFromTsv(_fh)); - } - else - if(_fn.endsWith(".txt")) - { - _ret.putAll(loadContextFromTxt(_fh)); - } - else - { - throw new MojoExecutionException(MessageFormat.format("Context file '{0}' is unknown format", _file.getName())); - } - IOUtil.close(_fh); - return _ret; - } - - public static Map loadContextFromIni(InputStream _fh) - { - return loadContextFromType("ini", _fh); + public static Map loadContextFrom(String _file) { + return DataUtil.loadContextFrom(_file); } - public static Map loadContextFromType(String _type, InputStream _fh) - { - try - { - ObjectDataReader _rd = DataReadWriteFactory.findByName(_type, ObjectDataReader.class); - return _rd.readObject(_fh); - } - finally { - CommonUtil.close(_fh); - } + public static List> loadRowsFrom(String _file) { + return DataUtil.loadRowsFrom(_file); } - public static Map loadContextFromType(String _type, File _fh) - { - ObjectDataReader _rd = DataReadWriteFactory.findByName(_type, ObjectDataReader.class); - return _rd.readObject(_fh); + public static Map loadContextFrom(File _file) { + return DataUtil.loadContextFrom(_file); } - public static String unCompressedFilename(File _res) - { - String _fn = _res.getName(); - String _ext = FileUtils.getExtension(_fn); - if("gz".equalsIgnoreCase(_ext)) - { - return _fn.substring(0, _fn.length()-3); - } - else - if("zst".equalsIgnoreCase(_ext)) - { - return _fn.substring(0, _fn.length()-4); - } - else - if("zstd".equalsIgnoreCase(_ext)) - { - return _fn.substring(0, _fn.length()-5); - } - else - if("xz".equalsIgnoreCase(_ext)) - { - return _fn.substring(0, _fn.length()-3); - } - else - if("bz2".equalsIgnoreCase(_ext)) - { - return _fn.substring(0, _fn.length()-4); - } - return _fn; + public static List> loadRowsFrom(File _file) { + return DataUtil.loadRowsFrom(_file); } - @SneakyThrows - public static InputStream getStreamBySuffix(File _res) - { - InputStream _stream = new FileInputStream(_res); - String _ext = FileUtils.getExtension(_res.getName()); - if("gz".equalsIgnoreCase(_ext)) - { - // _stream = new GzipCompressorInputStream(_stream); - } - else - if("zstd".equalsIgnoreCase(_ext) || "zst".equalsIgnoreCase(_ext)) - { - // _stream = new ZstdCompressorInputStream(_stream); - } - else - if("xz".equalsIgnoreCase(_ext)) - { - // _stream = new XZCompressorInputStream(_stream); - } - else - if("bz2".equalsIgnoreCase(_ext)) - { - // _stream = new BZip2CompressorInputStream(_stream); - } - return _stream; - } - - - public static final CSVFormat _SCSV = CSVFormat.newFormat(';') - .withAllowDuplicateHeaderNames() - .withEscape('\\') - .withQuote('"') - .withQuoteMode(QuoteMode.MINIMAL) - .withRecordSeparator('\n') - .withTrim(); - - public static final CSVFormat _SQLITECSV = CSVFormat.newFormat(',') - .withAllowDuplicateHeaderNames() - .withEscape('\\') - .withQuote('"') - .withQuoteMode(QuoteMode.ALL_NON_NULL) - .withRecordSeparator('\n') - .withTrim(); - - public static final CSVFormat _SQLITELIST = CSVFormat.newFormat('|') - .withAllowDuplicateHeaderNames() - .withEscape('\\') - .withRecordSeparator('\n') - .withTrim(); - - @SneakyThrows - public static Map loadContextFromTxt(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", loadFileLines(_source)); - return _ret; + public static Map loadContextFromIni(InputStream _fh) { + return DataUtil.loadContextFromIni(_fh); } - @SneakyThrows - public static List loadFileLines(InputStream _source) - { - final List _lines = new ArrayList(); - BufferedReader _reader = null; - try - { - _reader = new BufferedReader(new InputStreamReader(_source)); - - for (String _line = _reader.readLine(); _line != null; _line = _reader.readLine()) - { - _line = _line.trim(); - - if (!_line.startsWith("#") && (_line.length() != 0)) - { - _lines.add(_line); - } - } - - _reader.close(); - _reader = null; - } - finally - { - IOUtil.close(_reader); - } - - return _lines; + public static Map loadContextFromType(String _type, InputStream _fh) { + return DataUtil.loadContextFromType(_type, _fh); } - @SneakyThrows - public static Map loadContextFromTsv(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", readFileCsv("TDF", _source, StandardCharsets.UTF_8)); - return _ret; + public static Map loadContextFromType(String _type, File _fh) { + return DataUtil.loadContextFromType(_type, _fh); } - @SneakyThrows - public static Map loadContextFromCsv(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", readFileCsv("Default", _source, StandardCharsets.UTF_8)); - return _ret; + public static List> loadRowsFromType(String _type, InputStream _fh) { + return DataUtil.loadRowsFromType(_type, _fh); } - @SneakyThrows - public static Map loadContextFromScsv(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", readFileCsv("scsv", _source, StandardCharsets.UTF_8)); - return _ret; + public static List> loadRowsFromType(String _type, File _fh) { + return DataUtil.loadRowsFromType(_type, _fh); } - @SneakyThrows - public static Map loadContextFromSqliteCsv(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", readFileCsv("sqlite-csv", _source, StandardCharsets.UTF_8)); - return _ret; + public static String unCompressedFilename(File _res) { + return DataUtil.unCompressedFilename(_res); } - @SneakyThrows - public static Map loadContextFromSqliteList(InputStream _source) - { - Map _ret = new HashMap<>(); - _ret.put("data", readFileCsv("sqlite-list", _source, StandardCharsets.UTF_8)); - return _ret; + public static InputStream getStreamBySuffix(File _res) { + return DataUtil.getStreamBySuffix(_res); } - @SneakyThrows - public static JDAO daoFromJdbc(String jdbcDriver, String _url, String _user, String _pass) - { - return JDAO.createDaoFromConnection(JdaoUtils.createConnectionByDriverSpec(StringUtils.isNotEmpty(jdbcDriver) ? jdbcDriver : null, _url, _user, _pass), true); + public static Map loadContextFromTxt(InputStream _source) { + return DataUtil.loadContextFromTxt(_source); } - @SneakyThrows - public static List> readFileCsv(String _infmt, InputStream _in, Charset _cs) - { - return CsvUtil.readFileCsv(_infmt, _in, _cs); + public static List loadFileLines(InputStream _source) { + return DataUtil.loadFileLines(_source); } - @SneakyThrows - public static Map loadContextFromPdx(InputStream _source) - { - return loadContextFromType("pdata", _source); + public static Map loadContextFromTsv(InputStream _source) { + return DataUtil.loadContextFromTsv(_source); } - @SneakyThrows - public static Map loadContextFromPdata(InputStream _source) - { - return loadContextFromType("pdata", _source); + public static Map loadContextFromCsv(InputStream _source) { + return DataUtil.loadContextFromCsv(_source); } - @SneakyThrows - public static Map fromPdx(String _source) - { - return loadContextFromType("pdata", new StringBufferInputStream(_source)); + public static Map loadContextFromScsv(InputStream _source) { + return DataUtil.loadContextFromScsv(_source); } - @SneakyThrows - public static Map fromPdata(String _source) - { - return loadContextFromType("pdata", new StringBufferInputStream(_source)); + public static Map loadContextFromSqliteCsv(InputStream _source) { + return DataUtil.loadContextFromSqliteCsv(_source); } - @SneakyThrows - public static Map loadContextFromProperties(InputStream _source) - { - return loadContextFromType("properties", _source); + public static Map loadContextFromSqliteList(InputStream _source) { + return DataUtil.loadContextFromSqliteList(_source); } - @SneakyThrows - public static Map loadContextFromYaml(InputStream _source) - { - return loadContextFromType("yaml", _source); + public static List> readFileCsv(String _infmt, InputStream _in, Charset _cs) { + return DataUtil.readFileCsv(_infmt, _in, _cs); } - @SneakyThrows - public static Map fromYaml(String _source) - { - return loadContextFromType("yaml", new StringBufferInputStream(_source)); + public static Map loadContextFromPdx(InputStream _source) { + return DataUtil.loadContextFromPdx(_source); } - public static void writeContextAsType(String _type, Map _data, OutputStream _fh) - { - try - { - ObjectDataWriter _rd = DataReadWriteFactory.findByName(_type, ObjectDataWriter.class); - _rd.writeObject(_data, _fh); - } - finally { - CommonUtil.close(_fh); - } + public static Map loadContextFromPdata(InputStream _source) { + return DataUtil.loadContextFromPdata(_source); } - public static void writeContextAsType(String _type, Map _data, File _fh) - { - ObjectDataWriter _rd = DataReadWriteFactory.findByName(_type, ObjectDataWriter.class); - _rd.writeObject(_data, _fh); + public static Map fromPdx(String _source) { + return DataUtil.fromPdx(_source); } - public static void writeRowsAsType(String _type, List> _data, OutputStream _fh) - { - try - { - RowDataWriter _rd = DataReadWriteFactory.findByName(_type, RowDataWriter.class); - _rd.writeRows(_data, _fh); - } - finally { - CommonUtil.close(_fh); - } + public static Map fromPdata(String _source) { + return DataUtil.fromPdata(_source); } - public static void writeRowsAsType(String _type, List> _data, File _fh) - { - RowDataWriter _rd = DataReadWriteFactory.findByName(_type, RowDataWriter.class); - _rd.writeRows(_data, _fh); + public static Map loadContextFromProperties(InputStream _source) { + return DataUtil.loadContextFromProperties(_source); } - @SneakyThrows - public static void writeAsHson(boolean _json, Writer _out, List> _res) - { - ByteArrayOutputStream _baos = new ByteArrayOutputStream(); - if(_json) - { - writeRowsAsType("json", _res, _baos); - } - else - { - writeRowsAsType("hson", _res, _baos); - } - _out.write(_baos.toString("UTF-8")); + public static Map loadContextFromYaml(InputStream _source) { + return DataUtil.loadContextFromYaml(_source); } - @SneakyThrows - public static void writeAsHson(boolean _json, Writer _out, Map _res) - { - ByteArrayOutputStream _baos = new ByteArrayOutputStream(); - if(_json) - { - writeContextAsType("json", _res, _baos); - } - else - { - writeContextAsType("hson", _res, _baos); - } - _out.write(_baos.toString("UTF-8")); - } - - public static String toHson(Map _res) - { - StringWriter _sw = new StringWriter(); - writeAsHson(false, _sw, _res); - _sw.flush(); - return _sw.getBuffer().toString(); + public static Map fromYaml(String _source) { + return DataUtil.fromYaml(_source); } - public static String toJson(Map _res) - { - StringWriter _sw = new StringWriter(); - writeAsHson(true, _sw, _res); - _sw.flush(); - return _sw.getBuffer().toString(); + public static void writeContextAsType(String _type, Map _data, OutputStream _fh) { + DataUtil.writeContextAsType(_type, _data, _fh); } - @SneakyThrows - public static void writeAsPdata(Writer _out, Map _res) - { - ByteArrayOutputStream _baos = new ByteArrayOutputStream(); - writeContextAsType("pdata", _res, _baos); - _out.write(_baos.toString("UTF-8")); + public static void writeContextAsType(String _type, Map _data, File _fh) { + DataUtil.writeContextAsType(_type, _data, _fh); } - public static String toPdata(Map _res) - { - StringWriter _sw = new StringWriter(); - writeAsPdata(_sw, _res); - _sw.flush(); - return _sw.getBuffer().toString(); + public static void writeRowsAsType(String _type, List> _data, OutputStream _fh) { + DataUtil.writeRowsAsType(_type, _data, _fh); } - @SneakyThrows - public static Map loadContextFromHjson(InputStream _source) - { - return loadContextFromType("hson", _source); + public static void writeRowsAsType(String _type, List> _data, File _fh) { + DataUtil.writeRowsAsType(_type, _data, _fh); } - @SneakyThrows - public static Map fromJson(String _source) - { - return loadContextFromType("json", new StringBufferInputStream(_source)); + public static void writeAsHson(boolean _json, Writer _out, List> _res) { + DataUtil.writeAsHson(_json, _out, _res); } - @SneakyThrows - public static Map fromHjson(String _source) - { - return loadContextFromType("hson", new StringBufferInputStream(_source)); + public static void writeAsHson(boolean _json, Writer _out, Map _res) { + DataUtil.writeAsHson(_json, _out, _res); } - /*----- image helper -----*/ - - public static PixelImage pixImage(int _w, int _h) { return PixelImage.create(_w,_h); } - - public static SvgImage svgImage(int _w, int _h) { return SvgImage.create(_w,_h); } - - public static PdfImage pdfImage(int _w, int _h) { return PdfImage.create(_w,_h); } - - - /*----- hmacs -----*/ - - public static String hmacMd5Hex(String key, String valueToDigest) { - return HmacUtils.hmacMd5Hex(key, valueToDigest); + public static String toHson(Map _res) { + return DataUtil.toHson(_res); } - public static String hmacSha1Hex(String key, String valueToDigest) { - return HmacUtils.hmacSha1Hex(key, valueToDigest); + public static String toJson(Map _res) { + return DataUtil.toJson(_res); } - public static String hmacSha256Hex(String key, String valueToDigest) { - return HmacUtils.hmacSha256Hex(key, valueToDigest); + public static void writeAsPdata(Writer _out, Map _res) { + DataUtil.writeAsPdata(_out, _res); } - public static String hmacSha384Hex(String key, String valueToDigest) { - return HmacUtils.hmacSha384Hex(key, valueToDigest); + public static String toPdata(Map _res) { + return DataUtil.toPdata(_res); } - public static String hmacSha512Hex(String key, String valueToDigest) { - return HmacUtils.hmacSha512Hex(key, valueToDigest); + public static Map loadContextFromHjson(InputStream _source) { + return DataUtil.loadContextFromHjson(_source); } - /*----- digest -----*/ + public static Map fromJson(String _source) { + return DataUtil.fromJson(_source); + } - public static String md5Hex(String data) { - return DigestUtils.md5Hex(data); + public static Map fromHjson(String _source) { + return DataUtil.fromHjson(_source); } - public static String sha1Hex(String data) { - return CommonUtil.sha1Hex(data); + + public static void writeAsJsonPerLine(Writer _out, List> _res) { + DataUtil.writeAsJsonPerLine(_out, _res); } - public static String sha256Hex(String data) { - return CommonUtil.sha256Hex(data); + + public static String toJsonPerLine(List> _res) { + return DataUtil.toJsonPerLine(_res); } - public static String sha384Hex(String data) { - return CommonUtil.sha384Hex(data); + + public static List> loadRowsFromJsonPerLine(InputStream _source) { + return DataUtil.loadRowsFromJsonPerLine(_source); } - public static String sha512Hex(String data) { - return CommonUtil.sha512Hex(data); + + public static List> fromJsonPerLine(String _source) { + return DataUtil.fromJsonPerLine(_source); } - /*----- WordUtils -----*/ + /*----- image helper -----*/ - public static String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords, String wrapOn) { - return WordUtils.wrap(str, wrapLength, newLineStr, wrapLongWords, wrapOn); - } + public static PixelImage pixImage(int _w, int _h) { return png(_w,_h); } - public static boolean containsAllWords(CharSequence word, CharSequence... words) { - return WordUtils.containsAllWords(word, words); - } + public static SvgImage svgImage(int _w, int _h) { return svg(_w,_h); } - @Deprecated - public static boolean isDelimiter(char ch, char[] delimiters) { - return WordUtils.isDelimiter(ch, delimiters); - } + public static PdfImage pdfImage(int _w, int _h) { return pdf(_w,_h); } - @Deprecated - public static boolean isDelimiter(int codePoint, char[] delimiters) { - return WordUtils.isDelimiter(codePoint, delimiters); - } - public static String abbreviate(String str, int lower, int upper, String appendToEnd) { - return WordUtils.abbreviate(str, lower, upper, appendToEnd); - } + /*----- WordUtils -----*/ public static String toCamelCase(String str, boolean capitalizeFirstLetter, char... delimiters) { return CaseUtils.toCamelCase(str, capitalizeFirstLetter, delimiters); @@ -587,14 +216,6 @@ public static String toCamelCase(String str) { return CaseUtils.toCamelCase(str, false); } - public static String wrap(String str, int wrapLength) { - return WordUtils.wrap(str, wrapLength); - } - - public static String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords) { - return WordUtils.wrap(str, wrapLength, newLineStr, wrapLongWords); - } - /*----- StringEscapeUtils -----*/ @@ -662,1975 +283,27 @@ public static String unescapeCsv(String input) { return StringEscapeUtils.unescapeCsv(input); } - /*----- StringUtils -----*/ - - public static boolean isEmpty(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isEmpty(cs); - } - - public static boolean isNotEmpty(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isNotEmpty(cs); - } - - public static boolean isAnyEmpty(CharSequence... css) { - return org.apache.commons.lang3.StringUtils.isAnyEmpty(css); - } - - public static boolean isNoneEmpty(CharSequence... css) { - return org.apache.commons.lang3.StringUtils.isNoneEmpty(css); - } - - public static boolean isBlank(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isBlank(cs); - } - - public static boolean isNotBlank(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isNotBlank(cs); - } - - public static boolean isAnyBlank(CharSequence... css) { - return org.apache.commons.lang3.StringUtils.isAnyBlank(css); - } - - public static boolean isNoneBlank(CharSequence... css) { - return org.apache.commons.lang3.StringUtils.isNoneBlank(css); - } - - public static String trim(String str) { - return org.apache.commons.lang3.StringUtils.trim(str); - } - - public static String trimToNull(String str) { - return org.apache.commons.lang3.StringUtils.trimToNull(str); - } - - public static String trimToEmpty(String str) { - return org.apache.commons.lang3.StringUtils.trimToEmpty(str); - } - - public static String strip(String str) { - return org.apache.commons.lang3.StringUtils.strip(str); - } - - public static String stripToNull(String str) { - return org.apache.commons.lang3.StringUtils.stripToNull(str); - } - - public static String stripToEmpty(String str) { - return org.apache.commons.lang3.StringUtils.stripToEmpty(str); - } - - public static String strip(String str, String stripChars) { - return org.apache.commons.lang3.StringUtils.strip(str, stripChars); - } - - public static String stripStart(String str, String stripChars) { - return org.apache.commons.lang3.StringUtils.stripStart(str, stripChars); - } - - public static String stripEnd(String str, String stripChars) { - return org.apache.commons.lang3.StringUtils.stripEnd(str, stripChars); - } - - public static String[] stripAll(String... strs) { - return org.apache.commons.lang3.StringUtils.stripAll(strs); - } - - public static String[] stripAll(String[] strs, String stripChars) { - return org.apache.commons.lang3.StringUtils.stripAll(strs, stripChars); - } - - public static String stripAccents(String input) { - return org.apache.commons.lang3.StringUtils.stripAccents(input); - } - - public static boolean equals(CharSequence cs1, CharSequence cs2) { - return org.apache.commons.lang3.StringUtils.equals(cs1, cs2); - } - - public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2) { - return org.apache.commons.lang3.StringUtils.equalsIgnoreCase(str1, str2); - } - - public static int indexOf(CharSequence seq, int searchChar) { - return org.apache.commons.lang3.StringUtils.indexOf(seq, searchChar); - } - - public static int indexOf(CharSequence seq, int searchChar, int startPos) { - return org.apache.commons.lang3.StringUtils.indexOf(seq, searchChar, startPos); - } - - public static int indexOf(CharSequence seq, CharSequence searchSeq) { - return org.apache.commons.lang3.StringUtils.indexOf(seq, searchSeq); - } - - public static int indexOf(CharSequence seq, CharSequence searchSeq, int startPos) { - return org.apache.commons.lang3.StringUtils.indexOf(seq, searchSeq, startPos); - } - - public static int ordinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal) { - return org.apache.commons.lang3.StringUtils.ordinalIndexOf(str, searchStr, ordinal); - } - - public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr) { - return org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(str, searchStr); - } - - public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos) { - return org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(str, searchStr, startPos); - } - - public static int lastIndexOf(CharSequence seq, int searchChar) { - return org.apache.commons.lang3.StringUtils.lastIndexOf(seq, searchChar); - } - - public static int lastIndexOf(CharSequence seq, int searchChar, int startPos) { - return org.apache.commons.lang3.StringUtils.lastIndexOf(seq, searchChar, startPos); - } - - public static int lastIndexOf(CharSequence seq, CharSequence searchSeq) { - return org.apache.commons.lang3.StringUtils.lastIndexOf(seq, searchSeq); - } - - public static int lastOrdinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal) { - return org.apache.commons.lang3.StringUtils.lastOrdinalIndexOf(str, searchStr, ordinal); - } - - public static int lastIndexOf(CharSequence seq, CharSequence searchSeq, int startPos) { - return org.apache.commons.lang3.StringUtils.lastIndexOf(seq, searchSeq, startPos); - } - - public static int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr) { - return org.apache.commons.lang3.StringUtils.lastIndexOfIgnoreCase(str, searchStr); - } - - public static int lastIndexOfIgnoreCase(CharSequence str, CharSequence searchStr, int startPos) { - return org.apache.commons.lang3.StringUtils.lastIndexOfIgnoreCase(str, searchStr, startPos); - } - - public static boolean contains(CharSequence seq, int searchChar) { - return org.apache.commons.lang3.StringUtils.contains(seq, searchChar); - } - - public static boolean contains(CharSequence seq, CharSequence searchSeq) { - return org.apache.commons.lang3.StringUtils.contains(seq, searchSeq); - } - - public static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr) { - return org.apache.commons.lang3.StringUtils.containsIgnoreCase(str, searchStr); - } - - public static boolean containsWhitespace(CharSequence seq) { - return org.apache.commons.lang3.StringUtils.containsWhitespace(seq); - } - - public static int indexOfAny(CharSequence cs, char... searchChars) { - return org.apache.commons.lang3.StringUtils.indexOfAny(cs, searchChars); - } - - public static int indexOfAny(CharSequence cs, String searchChars) { - return org.apache.commons.lang3.StringUtils.indexOfAny(cs, searchChars); - } - - public static boolean containsAny(CharSequence cs, char... searchChars) { - return org.apache.commons.lang3.StringUtils.containsAny(cs, searchChars); - } - - public static boolean containsAny(CharSequence cs, CharSequence searchChars) { - return org.apache.commons.lang3.StringUtils.containsAny(cs, searchChars); - } - - public static boolean containsAny(CharSequence cs, CharSequence... searchCharSequences) { - return org.apache.commons.lang3.StringUtils.containsAny(cs, searchCharSequences); - } - - public static int indexOfAnyBut(CharSequence cs, char... searchChars) { - return org.apache.commons.lang3.StringUtils.indexOfAnyBut(cs, searchChars); - } - - public static int indexOfAnyBut(CharSequence seq, CharSequence searchChars) { - return org.apache.commons.lang3.StringUtils.indexOfAnyBut(seq, searchChars); - } - - public static boolean containsOnly(CharSequence cs, char... valid) { - return org.apache.commons.lang3.StringUtils.containsOnly(cs, valid); - } - - public static boolean containsOnly(CharSequence cs, String validChars) { - return org.apache.commons.lang3.StringUtils.containsOnly(cs, validChars); - } - - public static boolean containsNone(CharSequence cs, char... searchChars) { - return org.apache.commons.lang3.StringUtils.containsNone(cs, searchChars); - } - - public static boolean containsNone(CharSequence cs, String invalidChars) { - return org.apache.commons.lang3.StringUtils.containsNone(cs, invalidChars); - } - - public static int indexOfAny(CharSequence str, CharSequence... searchStrs) { - return org.apache.commons.lang3.StringUtils.indexOfAny(str, searchStrs); - } - - public static int lastIndexOfAny(CharSequence str, CharSequence... searchStrs) { - return org.apache.commons.lang3.StringUtils.lastIndexOfAny(str, searchStrs); - } - - public static String substring(String str, int start) { - return org.apache.commons.lang3.StringUtils.substring(str, start); - } - - public static String substring(String str, int start, int end) { - return org.apache.commons.lang3.StringUtils.substring(str, start, end); - } - - public static String left(String str, int len) { - return org.apache.commons.lang3.StringUtils.left(str, len); - } - - public static String right(String str, int len) { - return org.apache.commons.lang3.StringUtils.right(str, len); - } - - public static String mid(String str, int pos, int len) { - return org.apache.commons.lang3.StringUtils.mid(str, pos, len); - } - - public static String substringBefore(String str, String separator) { - return org.apache.commons.lang3.StringUtils.substringBefore(str, separator); - } - - public static String substringAfter(String str, String separator) { - return org.apache.commons.lang3.StringUtils.substringAfter(str, separator); - } - - public static String substringBeforeLast(String str, String separator) { - return org.apache.commons.lang3.StringUtils.substringBeforeLast(str, separator); - } - - public static String substringAfterLast(String str, String separator) { - return org.apache.commons.lang3.StringUtils.substringAfterLast(str, separator); - } - - public static String substringBetween(String str, String tag) { - return org.apache.commons.lang3.StringUtils.substringBetween(str, tag); - } - - public static String substringBetween(String str, String open, String close) { - return org.apache.commons.lang3.StringUtils.substringBetween(str, open, close); - } - - public static String[] substringsBetween(String str, String open, String close) { - return org.apache.commons.lang3.StringUtils.substringsBetween(str, open, close); - } - - public static String[] split(String str) { - return org.apache.commons.lang3.StringUtils.split(str); - } - - public static String[] split(String str, char separatorChar) { - return org.apache.commons.lang3.StringUtils.split(str, separatorChar); - } - - public static String[] split(String str, String separatorChars) { - return org.apache.commons.lang3.StringUtils.split(str, separatorChars); - } - - public static String[] split(String str, String separatorChars, int max) { - return org.apache.commons.lang3.StringUtils.split(str, separatorChars, max); - } - - public static String[] splitByWholeSeparator(String str, String separator) { - return org.apache.commons.lang3.StringUtils.splitByWholeSeparator(str, separator); - } - - public static String[] splitByWholeSeparator(String str, String separator, int max) { - return org.apache.commons.lang3.StringUtils.splitByWholeSeparator(str, separator, max); - } - - public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator) { - return org.apache.commons.lang3.StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator); - } - - public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max) { - return org.apache.commons.lang3.StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator, max); - } - - public static String[] splitPreserveAllTokens(String str) { - return org.apache.commons.lang3.StringUtils.splitPreserveAllTokens(str); - } - - public static String[] splitPreserveAllTokens(String str, char separatorChar) { - return org.apache.commons.lang3.StringUtils.splitPreserveAllTokens(str, separatorChar); - } - - public static String[] splitPreserveAllTokens(String str, String separatorChars) { - return org.apache.commons.lang3.StringUtils.splitPreserveAllTokens(str, separatorChars); - } + // URL codec - public static String[] splitPreserveAllTokens(String str, String separatorChars, int max) { - return org.apache.commons.lang3.StringUtils.splitPreserveAllTokens(str, separatorChars, max); + @SneakyThrows + public static String encodeUrl(String _raw) + { + return new String(URLCodec.encodeUrl(null, _raw.getBytes())); } - public static String[] splitByCharacterType(String str) { - return org.apache.commons.lang3.StringUtils.splitByCharacterType(str); + @SneakyThrows + public static String decodeUrl(String _cooked) + { + return new String(URLCodec.decodeUrl( _cooked.getBytes())); } - public static String[] splitByCharacterTypeCamelCase(String str) { - return org.apache.commons.lang3.StringUtils.splitByCharacterTypeCamelCase(str); - } + // dao - public static String join(T... elements) { - return org.apache.commons.lang3.StringUtils.join(elements); - } - - public static String join(Object[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(long[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(int[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(short[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(byte[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(char[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(float[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(double[] array, char separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(Object[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(long[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(int[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(byte[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(short[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(char[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(double[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(float[] array, char separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(Object[] array, String separator) { - return org.apache.commons.lang3.StringUtils.join(array, separator); - } - - public static String join(Object[] array, String separator, int startIndex, int endIndex) { - return org.apache.commons.lang3.StringUtils.join(array, separator, startIndex, endIndex); - } - - public static String join(Iterator iterator, char separator) { - return org.apache.commons.lang3.StringUtils.join(iterator, separator); - } - - public static String join(Iterator iterator, String separator) { - return org.apache.commons.lang3.StringUtils.join(iterator, separator); - } - - public static String join(Iterable iterable, char separator) { - return org.apache.commons.lang3.StringUtils.join(iterable, separator); - } - - public static String join(Iterable iterable, String separator) { - return org.apache.commons.lang3.StringUtils.join(iterable, separator); - } - - public static String deleteWhitespace(String str) { - return org.apache.commons.lang3.StringUtils.deleteWhitespace(str); - } - - public static String removeStart(String str, String remove) { - return org.apache.commons.lang3.StringUtils.removeStart(str, remove); - } - - public static String removeStartIgnoreCase(String str, String remove) { - return org.apache.commons.lang3.StringUtils.removeStartIgnoreCase(str, remove); - } - - public static String removeEnd(String str, String remove) { - return org.apache.commons.lang3.StringUtils.removeEnd(str, remove); - } - - public static String removeEndIgnoreCase(String str, String remove) { - return org.apache.commons.lang3.StringUtils.removeEndIgnoreCase(str, remove); - } - - public static String remove(String str, String remove) { - return org.apache.commons.lang3.StringUtils.remove(str, remove); - } - - public static String remove(String str, char remove) { - return org.apache.commons.lang3.StringUtils.remove(str, remove); - } - - public static String replaceOnce(String text, String searchString, String replacement) { - return org.apache.commons.lang3.StringUtils.replaceOnce(text, searchString, replacement); - } - - public static String replacePattern(String source, String regex, String replacement) { - return org.apache.commons.lang3.StringUtils.replacePattern(source, regex, replacement); - } - - public static String removePattern(String source, String regex) { - return org.apache.commons.lang3.StringUtils.removePattern(source, regex); - } - - public static String replace(String text, String searchString, String replacement) { - return org.apache.commons.lang3.StringUtils.replace(text, searchString, replacement); - } - - public static String replace(String text, String searchString, String replacement, int max) { - return org.apache.commons.lang3.StringUtils.replace(text, searchString, replacement, max); - } - - public static String replaceEach(String text, String[] searchList, String[] replacementList) { - return org.apache.commons.lang3.StringUtils.replaceEach(text, searchList, replacementList); - } - - public static String replaceEachRepeatedly(String text, String[] searchList, String[] replacementList) { - return org.apache.commons.lang3.StringUtils.replaceEachRepeatedly(text, searchList, replacementList); - } - - public static String replaceChars(String str, char searchChar, char replaceChar) { - return org.apache.commons.lang3.StringUtils.replaceChars(str, searchChar, replaceChar); - } - - public static String replaceChars(String str, String searchChars, String replaceChars) { - return org.apache.commons.lang3.StringUtils.replaceChars(str, searchChars, replaceChars); - } - - public static String overlay(String str, String overlay, int start, int end) { - return org.apache.commons.lang3.StringUtils.overlay(str, overlay, start, end); - } - - public static String chomp(String str) { - return org.apache.commons.lang3.StringUtils.chomp(str); - } - - @Deprecated - public static String chomp(String str, String separator) { - return org.apache.commons.lang3.StringUtils.chomp(str, separator); - } - - public static String chop(String str) { - return org.apache.commons.lang3.StringUtils.chop(str); - } - - public static String repeat(String str, int repeat) { - return org.apache.commons.lang3.StringUtils.repeat(str, repeat); - } - - public static String repeat(String str, String separator, int repeat) { - return org.apache.commons.lang3.StringUtils.repeat(str, separator, repeat); - } - - public static String repeat(char ch, int repeat) { - return org.apache.commons.lang3.StringUtils.repeat(ch, repeat); - } - - public static String rightPad(String str, int size) { - return org.apache.commons.lang3.StringUtils.rightPad(str, size); - } - - public static String rightPad(String str, int size, char padChar) { - return org.apache.commons.lang3.StringUtils.rightPad(str, size, padChar); - } - - public static String rightPad(String str, int size, String padStr) { - return org.apache.commons.lang3.StringUtils.rightPad(str, size, padStr); - } - - public static String leftPad(String str, int size) { - return org.apache.commons.lang3.StringUtils.leftPad(str, size); - } - - public static String leftPad(String str, int size, char padChar) { - return org.apache.commons.lang3.StringUtils.leftPad(str, size, padChar); - } - - public static String leftPad(String str, int size, String padStr) { - return org.apache.commons.lang3.StringUtils.leftPad(str, size, padStr); - } - - public static int length(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.length(cs); - } - - public static String center(String str, int size) { - return org.apache.commons.lang3.StringUtils.center(str, size); - } - - public static String center(String str, int size, char padChar) { - return org.apache.commons.lang3.StringUtils.center(str, size, padChar); - } - - public static String center(String str, int size, String padStr) { - return org.apache.commons.lang3.StringUtils.center(str, size, padStr); - } - - public static String upperCase(String str) { - return org.apache.commons.lang3.StringUtils.upperCase(str); - } - - public static String upperCase(String str, Locale locale) { - return org.apache.commons.lang3.StringUtils.upperCase(str, locale); - } - - public static String lowerCase(String str) { - return org.apache.commons.lang3.StringUtils.lowerCase(str); - } - - public static String lowerCase(String str, Locale locale) { - return org.apache.commons.lang3.StringUtils.lowerCase(str, locale); - } - - public static String capitalize(String str) { - return org.apache.commons.lang3.StringUtils.capitalize(str); - } - - public static String capitalize(String str, char... delimiters) { - return WordUtils.capitalize(str, delimiters); - } - - public static String capitalizeFully(String str) { - return WordUtils.capitalizeFully(str); - } - - public static String capitalizeFully(String str, char... delimiters) { - return WordUtils.capitalizeFully(str, delimiters); - } - - public static String uncapitalize(String str) { - return org.apache.commons.lang3.StringUtils.uncapitalize(str); - } - - public static String uncapitalize(String str, char... delimiters) { - return WordUtils.uncapitalize(str, delimiters); - } - - public static String swapCase(String str) { - return org.apache.commons.lang3.StringUtils.swapCase(str); - } - - public static String initials(String str) { - return WordUtils.initials(str); - } - - public static String initials(String str, char... delimiters) { - return WordUtils.initials(str, delimiters); - } - - public static int countMatches(CharSequence str, CharSequence sub) { - return org.apache.commons.lang3.StringUtils.countMatches(str, sub); - } - - public static int countMatches(CharSequence str, char ch) { - return org.apache.commons.lang3.StringUtils.countMatches(str, ch); - } - - public static boolean isAlpha(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAlpha(cs); - } - - public static boolean isAlphaSpace(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAlphaSpace(cs); - } - - public static boolean isAlphanumeric(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAlphanumeric(cs); - } - - public static boolean isAlphanumericSpace(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAlphanumericSpace(cs); - } - - public static boolean isAsciiPrintable(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAsciiPrintable(cs); - } - - public static boolean isNumeric(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isNumeric(cs); - } - - public static boolean isNumericSpace(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isNumericSpace(cs); - } - - public static boolean isWhitespace(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isWhitespace(cs); - } - - public static boolean isAllLowerCase(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAllLowerCase(cs); - } - - public static boolean isAllUpperCase(CharSequence cs) { - return org.apache.commons.lang3.StringUtils.isAllUpperCase(cs); - } - - public static String defaultString(String str) { - return org.apache.commons.lang3.StringUtils.defaultString(str); - } - - public static String defaultString(String str, String defaultStr) { - return org.apache.commons.lang3.StringUtils.defaultString(str, defaultStr); - } - - public static T defaultIfBlank(T str, T defaultStr) { - return org.apache.commons.lang3.StringUtils.defaultIfBlank(str, defaultStr); - } - - public static T defaultIfEmpty(T str, T defaultStr) { - return org.apache.commons.lang3.StringUtils.defaultIfEmpty(str, defaultStr); - } - - public static String reverse(String str) { - return org.apache.commons.lang3.StringUtils.reverse(str); - } - - public static String reverseDelimited(String str, char separatorChar) { - return org.apache.commons.lang3.StringUtils.reverseDelimited(str, separatorChar); - } - - public static String abbreviate(String str, int maxWidth) { - return org.apache.commons.lang3.StringUtils.abbreviate(str, maxWidth); - } - - public static String abbreviate(String str, int offset, int maxWidth) { - return org.apache.commons.lang3.StringUtils.abbreviate(str, offset, maxWidth); - } - - public static String abbreviateMiddle(String str, String middle, int length) { - return org.apache.commons.lang3.StringUtils.abbreviateMiddle(str, middle, length); - } - - public static String difference(String str1, String str2) { - return org.apache.commons.lang3.StringUtils.difference(str1, str2); - } - - public static int indexOfDifference(CharSequence cs1, CharSequence cs2) { - return org.apache.commons.lang3.StringUtils.indexOfDifference(cs1, cs2); - } - - public static int indexOfDifference(CharSequence... css) { - return org.apache.commons.lang3.StringUtils.indexOfDifference(css); - } - - public static String getCommonPrefix(String... strs) { - return org.apache.commons.lang3.StringUtils.getCommonPrefix(strs); - } - - public static int getLevenshteinDistance(CharSequence s, CharSequence t) { - return org.apache.commons.lang3.StringUtils.getLevenshteinDistance(s, t); - } - - public static int getLevenshteinDistance(CharSequence s, CharSequence t, int threshold) { - return org.apache.commons.lang3.StringUtils.getLevenshteinDistance(s, t, threshold); - } - - public static double getJaroWinklerDistance(CharSequence first, CharSequence second) { - return org.apache.commons.lang3.StringUtils.getJaroWinklerDistance(first, second); - } - - public static int getFuzzyDistance(CharSequence term, CharSequence query, Locale locale) { - return org.apache.commons.lang3.StringUtils.getFuzzyDistance(term, query, locale); - } - - public static boolean startsWith(CharSequence str, CharSequence prefix) { - return org.apache.commons.lang3.StringUtils.startsWith(str, prefix); - } - - public static boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix) { - return org.apache.commons.lang3.StringUtils.startsWithIgnoreCase(str, prefix); - } - - public static boolean startsWithAny(CharSequence string, CharSequence... searchStrings) { - return org.apache.commons.lang3.StringUtils.startsWithAny(string, searchStrings); - } - - public static boolean endsWith(CharSequence str, CharSequence suffix) { - return org.apache.commons.lang3.StringUtils.endsWith(str, suffix); - } - - public static boolean endsWithIgnoreCase(CharSequence str, CharSequence suffix) { - return org.apache.commons.lang3.StringUtils.endsWithIgnoreCase(str, suffix); - } - - public static String normalizeSpace(String str) { - return org.apache.commons.lang3.StringUtils.normalizeSpace(str); - } - - public static boolean endsWithAny(CharSequence string, CharSequence... searchStrings) { - return org.apache.commons.lang3.StringUtils.endsWithAny(string, searchStrings); - } - - public static String appendIfMissing(String str, CharSequence suffix, CharSequence... suffixes) { - return org.apache.commons.lang3.StringUtils.appendIfMissing(str, suffix, suffixes); - } - - public static String appendIfMissingIgnoreCase(String str, CharSequence suffix, CharSequence... suffixes) { - return org.apache.commons.lang3.StringUtils.appendIfMissingIgnoreCase(str, suffix, suffixes); - } - - public static String prependIfMissing(String str, CharSequence prefix, CharSequence... prefixes) { - return org.apache.commons.lang3.StringUtils.prependIfMissing(str, prefix, prefixes); - } - - public static String prependIfMissingIgnoreCase(String str, CharSequence prefix, CharSequence... prefixes) { - return org.apache.commons.lang3.StringUtils.prependIfMissingIgnoreCase(str, prefix, prefixes); - } - - @Deprecated - public static String toString(byte[] bytes, String charsetName) throws UnsupportedEncodingException { - return org.apache.commons.lang3.StringUtils.toString(bytes, charsetName); - } - - public static String toEncodedString(byte[] bytes, Charset charset) { - return org.apache.commons.lang3.StringUtils.toEncodedString(bytes, charset); - } - - public static String wrap(String str, char wrapWith) { - return org.apache.commons.lang3.StringUtils.wrap(str, wrapWith); - } - - public static String wrap(String str, String wrapWith) { - return org.apache.commons.lang3.StringUtils.wrap(str, wrapWith); - } - - /* ---- numberutils ---- */ - - public static int toInt(String str) { - return NumberUtils.toInt(str); - } - - public static int toInt(String str, int defaultValue) { - return NumberUtils.toInt(str, defaultValue); - } - - public static long toLong(String str) { - return NumberUtils.toLong(str); - } - - public static long toLong(String str, long defaultValue) { - return NumberUtils.toLong(str, defaultValue); - } - - public static float toFloat(String str) { - return NumberUtils.toFloat(str); - } - - public static float toFloat(String str, float defaultValue) { - return NumberUtils.toFloat(str, defaultValue); - } - - public static double toDouble(String str) { - return NumberUtils.toDouble(str); - } - - public static double toDouble(String str, double defaultValue) { - return NumberUtils.toDouble(str, defaultValue); - } - - public static byte toByte(String str) { - return NumberUtils.toByte(str); - } - - public static byte toByte(String str, byte defaultValue) { - return NumberUtils.toByte(str, defaultValue); - } - - public static short toShort(String str) { - return NumberUtils.toShort(str); - } - - public static short toShort(String str, short defaultValue) { - return NumberUtils.toShort(str, defaultValue); - } - - public static Number createNumber(String str) throws NumberFormatException { - return NumberUtils.createNumber(str); - } - - public static Float createFloat(String str) { - return NumberUtils.createFloat(str); - } - - public static Double createDouble(String str) { - return NumberUtils.createDouble(str); - } - - public static Integer createInteger(String str) { - return NumberUtils.createInteger(str); - } - - public static Long createLong(String str) { - return NumberUtils.createLong(str); - } - - public static BigInteger createBigInteger(String str) { - return NumberUtils.createBigInteger(str); - } - - public static BigDecimal createBigDecimal(String str) { - return NumberUtils.createBigDecimal(str); - } - - public static long min(long... array) { - return NumberUtils.min(array); - } - - public static int min(int... array) { - return NumberUtils.min(array); - } - - public static short min(short... array) { - return NumberUtils.min(array); - } - - public static byte min(byte... array) { - return NumberUtils.min(array); - } - - public static double min(double... array) { - return NumberUtils.min(array); - } - - public static float min(float... array) { - return NumberUtils.min(array); - } - - public static long max(long... array) { - return NumberUtils.max(array); - } - - public static int max(int... array) { - return NumberUtils.max(array); - } - - public static short max(short... array) { - return NumberUtils.max(array); - } - - public static byte max(byte... array) { - return NumberUtils.max(array); - } - - public static double max(double... array) { - return NumberUtils.max(array); - } - - public static float max(float... array) { - return NumberUtils.max(array); - } - - public static long min(long a, long b, long c) { - return NumberUtils.min(a, b, c); - } - - public static int min(int a, int b, int c) { - return NumberUtils.min(a, b, c); - } - - public static short min(short a, short b, short c) { - return NumberUtils.min(a, b, c); - } - - public static byte min(byte a, byte b, byte c) { - return NumberUtils.min(a, b, c); - } - - public static double min(double a, double b, double c) { - return NumberUtils.min(a, b, c); - } - - public static float min(float a, float b, float c) { - return NumberUtils.min(a, b, c); - } - - public static long max(long a, long b, long c) { - return NumberUtils.max(a, b, c); - } - - public static int max(int a, int b, int c) { - return NumberUtils.max(a, b, c); - } - - public static short max(short a, short b, short c) { - return NumberUtils.max(a, b, c); - } - - public static byte max(byte a, byte b, byte c) { - return NumberUtils.max(a, b, c); - } - - public static double max(double a, double b, double c) { - return NumberUtils.max(a, b, c); - } - - public static float max(float a, float b, float c) { - return NumberUtils.max(a, b, c); - } - - public static boolean isDigits(String str) { - return NumberUtils.isDigits(str); - } - - public static boolean isNumber(String str) { - return NumberUtils.isNumber(str); - } - - public static boolean isParsable(String str) { - return NumberUtils.isParsable(str); - } - - public static int compare(int x, int y) { - return NumberUtils.compare(x, y); - } - - public static int compare(long x, long y) { - return NumberUtils.compare(x, y); - } - - public static int compare(short x, short y) { - return NumberUtils.compare(x, y); - } - - public static int compare(byte x, byte y) { - return NumberUtils.compare(x, y); - } - - /* ---- booleanutils ---- */ - - public static Boolean negate(Boolean bool) { - return BooleanUtils.negate(bool); - } - - public static boolean isTrue(Boolean bool) { - return BooleanUtils.isTrue(bool); - } - - public static boolean isNotTrue(Boolean bool) { - return BooleanUtils.isNotTrue(bool); - } - - public static boolean isFalse(Boolean bool) { - return BooleanUtils.isFalse(bool); - } - - public static boolean isNotFalse(Boolean bool) { - return BooleanUtils.isNotFalse(bool); - } - - public static boolean toBoolean(Boolean bool) { - return BooleanUtils.toBoolean(bool); - } - - public static boolean toBooleanDefaultIfNull(Boolean bool, boolean valueIfNull) { - return BooleanUtils.toBooleanDefaultIfNull(bool, valueIfNull); - } - - public static boolean toBoolean(int value) { - return BooleanUtils.toBoolean(value); - } - - public static Boolean toBooleanObject(int value) { - return BooleanUtils.toBooleanObject(value); - } - - public static Boolean toBooleanObject(Integer value) { - return BooleanUtils.toBooleanObject(value); - } - - public static boolean toBoolean(int value, int trueValue, int falseValue) { - return BooleanUtils.toBoolean(value, trueValue, falseValue); - } - - public static boolean toBoolean(Integer value, Integer trueValue, Integer falseValue) { - return BooleanUtils.toBoolean(value, trueValue, falseValue); - } - - public static Boolean toBooleanObject(int value, int trueValue, int falseValue, int nullValue) { - return BooleanUtils.toBooleanObject(value, trueValue, falseValue, nullValue); - } - - public static Boolean toBooleanObject(Integer value, Integer trueValue, Integer falseValue, Integer nullValue) { - return BooleanUtils.toBooleanObject(value, trueValue, falseValue, nullValue); - } - - public static int toInteger(boolean bool) { - return BooleanUtils.toInteger(bool); - } - - public static Integer toIntegerObject(boolean bool) { - return BooleanUtils.toIntegerObject(bool); - } - - public static Integer toIntegerObject(Boolean bool) { - return BooleanUtils.toIntegerObject(bool); - } - - public static int toInteger(boolean bool, int trueValue, int falseValue) { - return BooleanUtils.toInteger(bool, trueValue, falseValue); - } - - public static int toInteger(Boolean bool, int trueValue, int falseValue, int nullValue) { - return BooleanUtils.toInteger(bool, trueValue, falseValue, nullValue); - } - - public static Integer toIntegerObject(boolean bool, Integer trueValue, Integer falseValue) { - return BooleanUtils.toIntegerObject(bool, trueValue, falseValue); - } - - public static Integer toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue) { - return BooleanUtils.toIntegerObject(bool, trueValue, falseValue, nullValue); - } - - public static Boolean toBooleanObject(String str) { - return BooleanUtils.toBooleanObject(str); - } - - public static Boolean toBooleanObject(String str, String trueString, String falseString, String nullString) { - return BooleanUtils.toBooleanObject(str, trueString, falseString, nullString); - } - - public static boolean toBoolean(String str) { - return BooleanUtils.toBoolean(str); - } - - public static boolean toBoolean(String str, String trueString, String falseString) { - return BooleanUtils.toBoolean(str, trueString, falseString); - } - - public static String toStringTrueFalse(Boolean bool) { - return BooleanUtils.toStringTrueFalse(bool); - } - - public static String toStringOnOff(Boolean bool) { - return BooleanUtils.toStringOnOff(bool); - } - - public static String toStringYesNo(Boolean bool) { - return BooleanUtils.toStringYesNo(bool); - } - - public static String toString(Boolean bool, String trueString, String falseString, String nullString) { - return BooleanUtils.toString(bool, trueString, falseString, nullString); - } - - public static String toStringTrueFalse(boolean bool) { - return BooleanUtils.toStringTrueFalse(bool); - } - - public static String toStringOnOff(boolean bool) { - return BooleanUtils.toStringOnOff(bool); - } - - public static String toStringYesNo(boolean bool) { - return BooleanUtils.toStringYesNo(bool); - } - - public static String toString(boolean bool, String trueString, String falseString) { - return BooleanUtils.toString(bool, trueString, falseString); - } - - public static boolean and(boolean... array) { - return BooleanUtils.and(array); - } - - public static Boolean and(Boolean... array) { - return BooleanUtils.and(array); - } - - public static boolean or(boolean... array) { - return BooleanUtils.or(array); - } - - public static Boolean or(Boolean... array) { - return BooleanUtils.or(array); - } - - public static boolean xor(boolean... array) { - return BooleanUtils.xor(array); - } - - public static Boolean xor(Boolean... array) { - return BooleanUtils.xor(array); - } - - public static int compare(boolean x, boolean y) { - return BooleanUtils.compare(x, y); - } - - /*----- -----*/ - - public static boolean checkBoolean(final Object _str) - { - if(_str==null) - { - return false; - } - - return checkBoolean(_str.toString()); - } - - static final String [] _btests = {"false", "f", "off", "none", "no", "n", "null", "nul", "nil", "0"}; - public static boolean checkBoolean(String _str) - { - if (_str == null) { - return false; - } - - _str = _str.trim().toLowerCase(); - // any defined string is "true" unless it is a false indicator: - // false, off, none, no, null, nul, nil, 0 - for(String _test : _btests) - { - if(_test.equalsIgnoreCase(_str)) - return false; - } - - return true; - } - - // Hex - - public static byte[] decodeHex(String data) throws DecoderException { - return Hex.decodeHex(data.toCharArray()); - } - - public static byte[] decodeHex(char[] data) throws DecoderException { - return Hex.decodeHex(data); - } - - public static char[] encodeHex(byte[] data) { - return Hex.encodeHex(data); - } - - public static char[] encodeHex(byte[] data, boolean toLowerCase) { - return Hex.encodeHex(data, toLowerCase); - } - - public static String encodeHexString(byte[] data) { - return Hex.encodeHexString(data); - } - - public static String encodeHexString(byte[] data, boolean toLowerCase) { - String _str = Hex.encodeHexString(data); - return (toLowerCase ? _str.toLowerCase() : _str.toUpperCase()); - } - - // - - static PercentCodec _pct = new PercentCodec(); - - @SneakyThrows - public static String encodePercent(String _raw) - { - return new String(_pct.encode(_raw.getBytes())); - } - - @SneakyThrows - public static String decodePercent(String _cooked) - { - return new String(_pct.encode(_cooked.getBytes())); - } - - // URL codec - - @SneakyThrows - public static String encodeUrl(String _raw) - { - return new String(URLCodec.encodeUrl(null, _raw.getBytes())); - } - - @SneakyThrows - public static String decodeUrl(String _cooked) - { - return new String(URLCodec.decodeUrl( _cooked.getBytes())); - } - - - // DateUtils _du; - - public static long MILLIS_PER_DAY = DateUtils.MILLIS_PER_DAY; - public static long MILLIS_PER_HOUR = DateUtils.MILLIS_PER_HOUR; - public static long MILLIS_PER_MINUTE = DateUtils.MILLIS_PER_MINUTE; - public static long MILLIS_PER_SECOND = DateUtils.MILLIS_PER_SECOND; - - public static int DATE_FIELD_YEAR = Calendar.YEAR; - public static int DATE_FIELD_MONTH = Calendar.MONTH; - public static int DATE_FIELD_DAY = Calendar.DAY_OF_MONTH; - public static int DATE_FIELD_HOUR = Calendar.HOUR; - public static int DATE_FIELD_MINUTE = Calendar.MINUTE; - public static int DATE_FIELD_SECOND = Calendar.SECOND; - public static int DATE_FIELD_MILLISECOND = Calendar.MILLISECOND; - - public static int DATE_RANGE_WEEK_SUNDAY = DateUtils.RANGE_WEEK_SUNDAY; - public static int DATE_RANGE_MONTH_SUNDAY = DateUtils.RANGE_MONTH_SUNDAY; - public static int DATE_RANGE_WEEK_CENTER = DateUtils.RANGE_WEEK_CENTER; - public static int DATE_RANGE_WEEK_MONDAY = DateUtils.RANGE_WEEK_MONDAY; - public static int DATE_RANGE_WEEK_RELATIVE = DateUtils.RANGE_WEEK_RELATIVE; - public static int DATE_RANGE_MONTH_MONDAY = DateUtils.RANGE_MONTH_MONDAY; - - public static boolean isSameDay(Date date1, Date date2) { - return DateUtils.isSameDay(date1, date2); - } - - public static boolean isSameDay(Calendar cal1, Calendar cal2) { - return DateUtils.isSameDay(cal1, cal2); - } - - public static boolean isSameInstant(Date date1, Date date2) { - return DateUtils.isSameInstant(date1, date2); - } - - public static boolean isSameInstant(Calendar cal1, Calendar cal2) { - return DateUtils.isSameInstant(cal1, cal2); - } - - public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) { - return DateUtils.isSameLocalTime(cal1, cal2); - } - - public static Date parseDate(String str, String... parsePatterns) throws ParseException { - return DateUtils.parseDate(str, parsePatterns); - } - - public static Date parseDate(String str, Locale locale, String... parsePatterns) throws ParseException { - return DateUtils.parseDate(str, locale, parsePatterns); - } - - public static Date parseDateStrictly(String str, String... parsePatterns) throws ParseException { - return DateUtils.parseDateStrictly(str, parsePatterns); - } - - public static Date parseDateStrictly(String str, Locale locale, String... parsePatterns) throws ParseException { - return DateUtils.parseDateStrictly(str, locale, parsePatterns); - } - - public static Date addYears(Date date, int amount) { - return DateUtils.addYears(date, amount); - } - - public static Date addMonths(Date date, int amount) { - return DateUtils.addMonths(date, amount); - } - - public static Date addWeeks(Date date, int amount) { - return DateUtils.addWeeks(date, amount); - } - - public static Date addDays(Date date, int amount) { - return DateUtils.addDays(date, amount); - } - - public static Date addHours(Date date, int amount) { - return DateUtils.addHours(date, amount); - } - - public static Date addMinutes(Date date, int amount) { - return DateUtils.addMinutes(date, amount); - } - - public static Date addSeconds(Date date, int amount) { - return DateUtils.addSeconds(date, amount); - } - - public static Date addMilliseconds(Date date, int amount) { - return DateUtils.addMilliseconds(date, amount); - } - - public static Date setYears(Date date, int amount) { - return DateUtils.setYears(date, amount); - } - - public static Date setMonths(Date date, int amount) { - return DateUtils.setMonths(date, amount); - } - - public static Date setDays(Date date, int amount) { - return DateUtils.setDays(date, amount); - } - - public static Date setHours(Date date, int amount) { - return DateUtils.setHours(date, amount); - } - - public static Date setMinutes(Date date, int amount) { - return DateUtils.setMinutes(date, amount); - } - - public static Date setSeconds(Date date, int amount) { - return DateUtils.setSeconds(date, amount); - } - - public static Date setMilliseconds(Date date, int amount) { - return DateUtils.setMilliseconds(date, amount); - } - - public static Calendar toCalendar(Date date) { - return DateUtils.toCalendar(date); - } - - public static Calendar toCalendar(Date date, TimeZone tz) { - return DateUtils.toCalendar(date, tz); - } - - public static Date dateRound(Date date, int field) { - return DateUtils.round(date, field); - } - - public static Calendar dateRound(Calendar date, int field) { - return DateUtils.round(date, field); - } - - public static Date dateRound(Object date, int field) { - return DateUtils.round(date, field); - } - - public static Date dateTruncate(Date date, int field) { - return DateUtils.truncate(date, field); - } - - public static Calendar dateTruncate(Calendar date, int field) { - return DateUtils.truncate(date, field); - } - - public static Date dateTruncate(Object date, int field) { - return DateUtils.truncate(date, field); - } - - public static Date dateCeiling(Date date, int field) { - return DateUtils.ceiling(date, field); - } - - public static Calendar dateCeiling(Calendar date, int field) { - return DateUtils.ceiling(date, field); - } - - public static Date dateCeiling(Object date, int field) { - return DateUtils.ceiling(date, field); - } - - public static Iterator dateIterator(Date focus, int rangeStyle) { - return DateUtils.iterator(focus, rangeStyle); - } - - public static Iterator dateIterator(Calendar focus, int rangeStyle) { - return DateUtils.iterator(focus, rangeStyle); - } - - public static Iterator dateIterator(Object focus, int rangeStyle) { - return DateUtils.iterator(focus, rangeStyle); - } - - public static long getFragmentInMilliseconds(Date date, int fragment) { - return DateUtils.getFragmentInMilliseconds(date, fragment); - } - - public static long getFragmentInSeconds(Date date, int fragment) { - return DateUtils.getFragmentInSeconds(date, fragment); - } - - public static long getFragmentInMinutes(Date date, int fragment) { - return DateUtils.getFragmentInMinutes(date, fragment); - } - - public static long getFragmentInHours(Date date, int fragment) { - return DateUtils.getFragmentInHours(date, fragment); - } - - public static long getFragmentInDays(Date date, int fragment) { - return DateUtils.getFragmentInDays(date, fragment); - } - - public static long getFragmentInMilliseconds(Calendar calendar, int fragment) { - return DateUtils.getFragmentInMilliseconds(calendar, fragment); - } - - public static long getFragmentInSeconds(Calendar calendar, int fragment) { - return DateUtils.getFragmentInSeconds(calendar, fragment); - } - - public static long getFragmentInMinutes(Calendar calendar, int fragment) { - return DateUtils.getFragmentInMinutes(calendar, fragment); - } - - public static long getFragmentInHours(Calendar calendar, int fragment) { - return DateUtils.getFragmentInHours(calendar, fragment); - } - - public static long getFragmentInDays(Calendar calendar, int fragment) { - return DateUtils.getFragmentInDays(calendar, fragment); - } - - public static boolean dateTruncatedEquals(Calendar cal1, Calendar cal2, int field) { - return DateUtils.truncatedEquals(cal1, cal2, field); - } - - public static boolean dateTruncatedEquals(Date date1, Date date2, int field) { - return DateUtils.truncatedEquals(date1, date2, field); - } - - public static int dateTruncatedCompareTo(Calendar cal1, Calendar cal2, int field) { - return DateUtils.truncatedCompareTo(cal1, cal2, field); - } - - public static int dateTruncatedCompareTo(Date date1, Date date2, int field) { - return DateUtils.truncatedCompareTo(date1, date2, field); - } - - // netcool like inspired by probe functions - - @SneakyThrows - public static Date dateToTime(String _format, String _text) - { - return DateUtils.parseDate(_text, _format); - } @SneakyThrows - public static Long dateToLong(String _format, String _text) - { - Date _d = DateUtils.parseDate(_text, _format); - return (_d==null) ? null : _d.getTime(); - } - - public static Date getDate() - { - return new Date(); - } - - public static Long getDateLong() - { - return new Date().getTime(); - } - - public static String timeToDate(String _format, Date _time) - { - SimpleDateFormat _sdf = new SimpleDateFormat(_format); - return _sdf.format(_time); - } - - public static String timeToDate(String _format, long _time) - { - SimpleDateFormat _sdf = new SimpleDateFormat(_format); - return _sdf.format(new Date(_time)); - } - - public static String toBase(int _base, long _n) - { - return Long.toString(_n, _base); - } - - public static String regReplace(String _text, String _expr, String _repl) - { - return replace(_text, _expr, _repl); - } - - public static String regReplace(String _text, String _expr, String _repl, int _count) - { - return replace(_text, _expr, _repl, _count); - } - - public static String decimalToAscii(String _text) - { - String[] _parts = StringUtils.split(_text); - StringBuilder _sb = new StringBuilder(); - for(String _part : _parts) - { - _sb.append((char)NumberUtils.toInt(_part)); - } - return _sb.toString(); - } - - public static String decimalToHex(String _text) - { - String[] _parts = StringUtils.split(_text); - for(int _i=0; _i<_parts.length; _i++) - { - _parts[_i] = toBase(16,NumberUtils.toInt(_parts[_i])); - } - return StringUtils.join(_parts, ""); - } - - public static String decimalToHex(String _text, String _sep) - { - String[] _parts = StringUtils.split(_text, _sep); - for(int _i=0; _i<_parts.length; _i++) - { - _parts[_i] = toBase(16,NumberUtils.toInt(_parts[_i])); - } - return StringUtils.join(_parts, ""); - } - - public static String decimalToHex(String _text, String _sep, String _delim) - { - String[] _parts = StringUtils.split(_text, _sep); - for(int _i=0; _i<_parts.length; _i++) - { - _parts[_i] = toBase(16,NumberUtils.toInt(_parts[_i])); - } - return StringUtils.join(_parts, _delim); - } - - public static String extract(String s, String rx) - { - Pattern p = Pattern.compile(rx); - Matcher m = p.matcher(s); - if(m.find()) - { - return m.group(1); - } - return ""; - } - - public static String[] extractN(String s, String rx) - { - Pattern p = Pattern.compile(rx); - Matcher m = p.matcher(s); - if(m.find()) - { - String[] sa = new String[m.groupCount()]; - for(int i=0; i< sa.length; i++) - { - sa[i]=m.group(i+1); - } - return sa; - } - return new String[]{}; - } - - public static String formatMsg(String _fmt, Object... _params) - { - return MessageFormat.format(_fmt, _params); - } - - public static String format(String _fmt, Object... _params) - { - return String.format(_fmt, _params); - } - - public static boolean fnmatch(String a, String fx) - { - return wcmatch(fx, a); - } - - public static boolean wcmatch(String expr, String value) - { - if(value==null) - return false; - - ArrayList p = new ArrayList(); - - switch(wildcard_substring(expr.toLowerCase(),p)) - { - case -1: // presense - return (value.length() > 0); - - case 1: // wcmatch - return wildcard_check((String[])p.toArray(new String[] {}), value.toLowerCase()); - - case 0: // simple - default: - return expr.equalsIgnoreCase(value); - } - } - - private static boolean wildcard_check(String[] pieces, String s) - { - // Walk the pieces to match the string - // There are implicit stars between each piece, - // and the first and last pieces might be "" to anchor the match. - // assert (pieces.length > 1) - // minimal case is * - - boolean result = false; - int len = pieces.length; - - int index = 0; - for (int i = 0; i < len; i++) - { - String piece = (String) pieces[i]; - - if (i == len - 1) - { - // this is the last piece - if (s.endsWith(piece)) - { - result = true; - } - else - { - result = false; - } - break; - } - // initial non-star; assert index == 0 - else if (i == 0) - { - if (!s.startsWith(piece)) - { - result = false; - break; - } - } - // assert i > 0 && i < len-1 - else - { - // Sure wish stringbuffer supported e.g. indexOf - index = s.indexOf(piece, index); - if (index < 0) - { - result = false; - break; - } - } - // start beyond the matching piece - index += piece.length(); - } - - return result; - } - - private static int wildcard_substring(String wcstring, ArrayList pieces) - { - pieces.clear(); - StringBuffer ss = new StringBuffer(); - boolean wasStar = false; // indicates last piece was a star - boolean leftstar = false; // track if the initial piece is a star - boolean rightstar = false; // track if the final piece is a star - - char[] wcs = wcstring.toCharArray(); - int wco=0; - // We assume (sub)strings can contain leading and trailing blanks - for (;wco 0) - { - pieces.add(ss.toString()); // accumulate the pieces - // between '*' occurrences - } - ss.setLength(0); - // if this is a leading star, then track it - if (pieces.size() == 0) - { - leftstar = true; - } - ss.setLength(0); - wasStar = true; - break; - default : - wasStar = false; - c = wcs[wco]; wco++; - ss.append((char) c); - } - } - - if (ss.length() > 0) - { - pieces.add(ss.toString()); // accumulate the pieces - ss.setLength(0); - } - - if (pieces.size() == 0) - { - return -1; // presense - } - if (leftstar || rightstar || pieces.size() > 1) - { - // insert leading and/or trailing "" to anchor ends - if (rightstar) - { - pieces.add(""); - } - if (leftstar) - { - pieces.add(0, ""); - } - return 1; // wcmatch - } - // assert !leftstar && !rightstar && pieces.size == 1 - return 0; // simple - } - - public static String toString(Object _o) - { - return Objects.toString(_o); - } - - public static String randomUUID() { return UUID.randomUUID().toString().toUpperCase(); } - public static String randomGUID() { - UUID _uuid = UUID.randomUUID(); - long _l = System.currentTimeMillis(); - long _n = System.nanoTime(); - return toGUID(_uuid.getMostSignificantBits(), _uuid.getLeastSignificantBits(), _l, _n); - } - - public static String toGUID(long _n1, long _n2) - { - return String.format("%s-%s", - Long.toString(_n1 & 0x7fffffffffffffffL, 13), - Long.toString(_n2 & 0x7fffffffffffffffL, 17) - ).toUpperCase(); - } - - public static String toGUID(long _n1, long _n2, long _n3) - { - return String.format("%s-%s-%s", - Long.toString(_n1 & 0x7fffffffffffffffL, 13), - Long.toString(_n2 & 0x7fffffffffffffffL, 17), - Long.toString(_n3 & 0x7fffffffffffffffL, 35) - ).toUpperCase(); - } - - public static String toGUID(long _n1, long _n2, long _n3, long _n4) - { - return String.format("%s-%s-%s-%s", - Long.toString(_n1 & 0x7fffffffffffffffL, 17), - Long.toString(_n2 & 0x7fffffffffffffffL, 17), - Long.toString(_n3 & 0x7fffffffffffffffL, 36), - Long.toString(_n4 & 0x7fffffffffffffffL, 36) - ).toUpperCase(); - } - - public static String toGUID(long _n1, long _n2, long _n3, long _n4, long _n5) - { - return String.format("%s-%s-%s-%s-%s", - Long.toString(_n1 & 0x7ffffffffffffffL, 36), - Long.toString(_n2 & 0x7ffffffffffffffL, 36), - Long.toString(_n3 & 0x7ffffffffffffffL, 36), - Long.toString(_n4 & 0x7ffffffffffffffL, 36), - Long.toString(_n5 & 0x7ffffffffffffffL, 36) - ).toUpperCase(); - } - - public static String toGUID(String _name) - { - UUID _uuid = UUID.nameUUIDFromBytes(_name.getBytes()); - return toGUID(_name, _uuid.toString()); - } - - public static BigInteger sha512ToBigInt(String _name) - { - try { - MessageDigest _md = MessageDigest.getInstance("SHA-512"); - return new BigInteger(_md.digest(_name.getBytes())); - } - catch (NoSuchAlgorithmException e) { - return null; - } - } - - public static String toHashGUID(String _name) - { - BigInteger _bi = sha512ToBigInt(_name); - - return toGUID(_bi.longValue(), - _bi.shiftRight(64).longValue(), - _bi.shiftRight(128).longValue(), - _bi.shiftRight(192).longValue(), - _bi.shiftRight(256).longValue()); - } - - public static String toGUID(String _name1, String _name2) - { - UUID _uuid1 = UUID.nameUUIDFromBytes(_name1.getBytes()); - UUID _uuid2 = UUID.nameUUIDFromBytes(_name2.getBytes()); - return toGUID(_uuid1.getMostSignificantBits(), - _uuid1.getLeastSignificantBits(), - _uuid2.getMostSignificantBits(), - _uuid2.getLeastSignificantBits()); - } - - public static String toGUID(String _name1, String _name2, Long _l) - { - UUID _uuid1 = UUID.nameUUIDFromBytes(_name1.getBytes()); - UUID _uuid2 = UUID.nameUUIDFromBytes(_name2.getBytes()); - return toGUID(_uuid1.getMostSignificantBits(), - _uuid1.getLeastSignificantBits(), - _uuid2.getMostSignificantBits(), - _uuid2.getLeastSignificantBits(), - _l); - } - - public static String toGUID(String _name1, String _name2, String _name3) - { - UUID _uuid1 = UUID.nameUUIDFromBytes(_name1.getBytes()); - UUID _uuid2 = UUID.nameUUIDFromBytes((_name2).getBytes()); - UUID _uuid3 = UUID.nameUUIDFromBytes((_name3).getBytes()); - return toGUID(_uuid1.getMostSignificantBits() ^ _uuid1.getLeastSignificantBits(), - _uuid2.getMostSignificantBits(), - _uuid2.getLeastSignificantBits(), - _uuid3.getMostSignificantBits(), - _uuid3.getLeastSignificantBits()); - } - - public static String toGUID(String _name1, String _name2, String _name3, Long _l) - { - UUID _uuid1 = UUID.nameUUIDFromBytes(_name1.getBytes()); - UUID _uuid2 = UUID.nameUUIDFromBytes((_name2).getBytes()); - UUID _uuid3 = UUID.nameUUIDFromBytes((_name3).getBytes()); - return toGUID( - _uuid1.getMostSignificantBits() ^ _uuid1.getLeastSignificantBits(), - _uuid2.getMostSignificantBits() ^ _uuid2.getLeastSignificantBits(), - _uuid3.getMostSignificantBits() ^ _uuid3.getLeastSignificantBits(), - _l); - } - - public static String mformat(String _pattern, Object... _objs) - { - return MessageFormat.format(_pattern, _objs); - } - - public static String sformat(String _pattern, Object... _objs) - { - return String.format(_pattern, _objs); - } - - public static BigInteger sha256ToBigInt(String _name) - { - try { - MessageDigest _md = MessageDigest.getInstance("SHA-256"); - return new BigInteger(_md.digest(_name.getBytes())); - } - catch (NoSuchAlgorithmException e) { - return null; - } - } - - public static BigInteger sha1ToBigInt(String _name) - { - try { - MessageDigest _md = MessageDigest.getInstance("SHA-1"); - return new BigInteger(_md.digest(_name.getBytes())); - } - catch (NoSuchAlgorithmException e) { - return null; - } - } - - public static String toHashGUID(String _name1, String _name2) - { - BigInteger _b1 = sha256ToBigInt(_name1); - BigInteger _b2 = sha256ToBigInt(_name2); - - return toGUID(_b1.longValue(), - _b1.shiftRight(64).longValue(), - _b2.longValue(), - _b2.shiftRight(64).longValue(), - _b2.shiftRight(128).longValue()); - } - - public static String toHashGUID(String _name1, String _name2, String _name3) - { - BigInteger _b1 = sha1ToBigInt(_name1); - BigInteger _b2 = sha1ToBigInt(_name2); - BigInteger _b3 = sha1ToBigInt(_name3); - - return toGUID(_b1.longValue(), - _b1.shiftRight(64).longValue(), - _b2.longValue(), - _b2.shiftRight(64).longValue(), - _b3.longValue()); - } - - public static Map toMap(List _args) - { - Map _ret = new HashMap<>(); - for(int _i = 0; (_i+1)<_args.size(); _i+=2) - { - _ret.put(_args.get(_i).toString(), _args.get(_i+1)); - } - return _ret; - } - - public static Map toMap(Object... _args) - { - Map _ret = new HashMap<>(); - for(int _i = 0; (_i+1)<_args.length; _i+=2) - { - _ret.put(_args[_i].toString(), _args[_i+1]); - } - return _ret; - } - - public static Map toMap(String _k, Object _v) + public static JDAO daoFromJdbc(String jdbcDriver, String _url, String _user, String _pass) { - Map _ret = new HashMap<>(); - _ret.put(_k, _v); - return _ret; + return JDAO.createDaoFromConnection(JdaoUtils.createConnectionByDriverSpec(StringUtils.isNotEmpty(jdbcDriver) ? jdbcDriver : null, _url, _user, _pass), true); } public static JDAO mysqlDao(String _hostPortDb, String _user, String _pass) diff --git a/template-maven-plugin/template-maven-plugin.iml b/template-maven-plugin/template-maven-plugin.iml index bf94e52..039fae0 100644 --- a/template-maven-plugin/template-maven-plugin.iml +++ b/template-maven-plugin/template-maven-plugin.iml @@ -11,10 +11,11 @@ - - + + + - + @@ -48,7 +49,7 @@ - + @@ -73,13 +74,13 @@ - + - +