<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
- <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/jline/jline/2.14.1/jline-2.14.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.0/junit-4.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/postgresql/postgresql/9.4.1208.jre7/postgresql-9.4.1208.jre7.jar"/>
-</classpath>
\ No newline at end of file
+ <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.3.1/commons-cli-1.3.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jline/jline/2.14.1/jline-2.14.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.0/junit-4.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/postgresql/postgresql/9.4.1208.jre7/postgresql-9.4.1208.jre7.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
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
//
--- /dev/null
+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();
+ }
+}
--- /dev/null
+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));
+ }
+ }
+}
+