From: Chris Jaekl Date: Thu, 20 Jun 2024 01:51:47 +0000 (-0400) Subject: Update to build in a modern environment X-Git-Url: https://jaekl.net/gitweb/?a=commitdiff_plain;ds=sidebyside;p=squelch.git Update to build in a modern environment This requires moving the minimum JDK version to 1.8, because support for building 1.7-compatible classes seems to have been dropped sometime between JDK17 and JDK20. I also re-implemented DatatypeConverter.printHexString(), because javax.xml.bind was removed from the JDK in JDK11. --- diff --git a/.classpath b/.classpath index 217e069..c2e1fb9 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,16 @@ - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index 399bea9..4899224 100644 --- a/pom.xml +++ b/pom.xml @@ -43,8 +43,8 @@ maven-compiler-plugin 3.0 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/src/main/java/net/jaekl/squelch/stmt/Tabular.java b/src/main/java/net/jaekl/squelch/stmt/Tabular.java index 6a060f1..6cab5c6 100644 --- a/src/main/java/net/jaekl/squelch/stmt/Tabular.java +++ b/src/main/java/net/jaekl/squelch/stmt/Tabular.java @@ -9,11 +9,10 @@ import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.sql.Types; -import javax.xml.bind.DatatypeConverter; - import net.jaekl.squelch.db.DbDriver; import net.jaekl.squelch.sql.Column; import net.jaekl.squelch.sql.Row; +import net.jaekl.squelch.util.DatatypeConverter;; // Copyright (C) 2016 by Chris Jaekl // diff --git a/src/main/java/net/jaekl/squelch/util/DatatypeConverter.java b/src/main/java/net/jaekl/squelch/util/DatatypeConverter.java new file mode 100644 index 0000000..422d189 --- /dev/null +++ b/src/main/java/net/jaekl/squelch/util/DatatypeConverter.java @@ -0,0 +1,13 @@ +package net.jaekl.squelch.util; + +public class DatatypeConverter { + public static String printHexBinary(byte[] content) { + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < content.length; ++i) { + sb.append(String.format("%02x", content[i])); + } + + return sb.toString(); + } +} diff --git a/src/test/java/net/jaekl/squelch/util/DatatypeConverterTest.java b/src/test/java/net/jaekl/squelch/util/DatatypeConverterTest.java new file mode 100644 index 0000000..a528c33 --- /dev/null +++ b/src/test/java/net/jaekl/squelch/util/DatatypeConverterTest.java @@ -0,0 +1,22 @@ +package net.jaekl.squelch.util; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class DatatypeConverterTest { + @Test + public void testPrintHexBinary() { + String[][] data = { + { "Hello, World", "48656c6c6f2c20576f726c64" }, + { "日本語がわかりますか?", "e697a5e69cace8aa9ee3818ce3828fe3818be3828ae381bee38199e3818befbc9f" }, + }; + + for (int i = 0; i < data.length; ++i) { + byte[] input = data[i][0].getBytes(); + String expected = data[i][1]; + + assertEquals(expected, DatatypeConverter.printHexBinary(input)); + } + } +} +