From b01a6095f8474133a296e9580d6fc84baaabac94 Mon Sep 17 00:00:00 2001 From: Norberto Lopez <106690103+nobes888@users.noreply.github.com> Date: Wed, 30 Jul 2025 18:06:33 -0400 Subject: [PATCH] Changes for 2.1.0: [1] Updates to improve the ParseUtil functionality. [2] Added check for null font argument. --- src/glum/app/AppInfo.java | 2 +- src/glum/gui/GuiUtil.java | 3 +- src/glum/io/ParseUtil.java | 69 +++++++++++++++++++++++++++++++-- src/glum/io/TokenParseAttr.java | 26 +++++++++++++ tools/buildRelease | 2 +- 5 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 src/glum/io/TokenParseAttr.java diff --git a/src/glum/app/AppInfo.java b/src/glum/app/AppInfo.java index 3c68852..9124aa3 100644 --- a/src/glum/app/AppInfo.java +++ b/src/glum/app/AppInfo.java @@ -26,7 +26,7 @@ public class AppInfo * Note we do not make the Version directly visible and final so other classes will not utilized a cached version * when built via Ant. */ - private static String Version = "2.0.0"; + private static String Version = "2.1.0"; /** * Returns the version of the application diff --git a/src/glum/gui/GuiUtil.java b/src/glum/gui/GuiUtil.java index 58943fd..0f69a49 100644 --- a/src/glum/gui/GuiUtil.java +++ b/src/glum/gui/GuiUtil.java @@ -76,7 +76,8 @@ public class GuiUtil { var tmpB = new JButton(aTitle); tmpB.addActionListener(aActionListener); - tmpB.setFont(aFont); + if (aFont != null) + tmpB.setFont(aFont); return tmpB; } diff --git a/src/glum/io/ParseUtil.java b/src/glum/io/ParseUtil.java index cd6b710..d904ebd 100644 --- a/src/glum/io/ParseUtil.java +++ b/src/glum/io/ParseUtil.java @@ -13,6 +13,9 @@ // limitations under the License. package glum.io; +import java.util.ArrayList; +import java.util.List; + /** * Collection of utility methods for parsing values from text input. * @@ -20,6 +23,15 @@ package glum.io; */ public class ParseUtil { + /** + * Utility method to strip the white space from an array of tokens. + */ + public static void cleanTokens(String[] aTokenArr) + { + for (int c1 = 0; c1 < aTokenArr.length; c1++) + aTokenArr[c1] = aTokenArr[c1].strip(); + } + /** * Reads a boolean from a string with out throwing a exception. */ @@ -137,12 +149,61 @@ public class ParseUtil } /** - * Utility method to strip the white space from an array of tokens. + * Utility method that strips out the 1st and last double quotes from a string. + *
+ * If there are no double quotes at the 1st and last position then the original string is returned. */ - public static void cleanTokens(String[] aTokenArr) + public static String stripQuotes(String aStr) { - for (int c1 = 0; c1 < aTokenArr.length; c1++) - aTokenArr[c1] = aTokenArr[c1].strip(); + if (aStr.startsWith("\"") == true && aStr.endsWith("\"") == true) + return aStr.substring(1, aStr.length() - 1); + + return aStr; + } + + /** + * Method to parse the specified input string and break it up based on commas. Note quoted string with the tokenizing + * char (aSplitChar) will be preserved. + *
+ * The basis of this method is from:
+ * https://stackoverflow.com/questions/1757065/java-splitting-a-comma-separated-string-but-ignoring-commas-in-quotes
+ *
+ * @param aInputStr
+ * The input string to tokenize.
+ * @param aSplitChar
+ * The character to split the input string by.
+ * @param aParseTokenAttr
+ * Provides the behavior specific to tokenization.
+ * @return
+ */
+ public static List