com.clickzetta.client.jdbc.arrow.util.JsonUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickzetta-java Show documentation
Show all versions of clickzetta-java Show documentation
The java SDK for clickzetta's Lakehouse
package com.clickzetta.client.jdbc.arrow.util;
import org.apache.arrow.vector.util.Text;
public class JsonUtils {
public static String printBinary(byte[] value) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i = 0; i < value.length; ++i) {
sb.append(String.format("%02x", (int) value[i] & 0xff));
if (i != value.length - 1) {
sb.append(" ");
}
}
sb.append("]");
return sb.toString();
}
public static String convert(Object value) {
if (value == null) {
return "null";
}
if (value instanceof byte[]) {
return printBinary((byte[]) value);
}
if (value instanceof Text || value instanceof String) {
StringBuilder sb = new StringBuilder();
sb.append("\"").append(value).append("\"");
return sb.toString();
}
return value.toString();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy