use of org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString in project dbeaver by dbeaver.
the class BinaryAttributeTransformer method transformAttribute.
@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, String> options) throws DBException {
DBPDataSource dataSource = session.getDataSource();
String formatterId = options.getOrDefault(PROP_FORMAT, FORMAT_HEX);
DBDBinaryFormatter formatter;
if (FORMAT_NATIVE.equals(formatterId) && dataSource instanceof SQLDataSource) {
formatter = ((SQLDataSource) dataSource).getSQLDialect().getNativeBinaryFormatter();
} else {
formatter = DBValueFormatting.getBinaryPresentation(formatterId);
}
if (formatter == null) {
formatter = new BinaryFormatterString();
}
String encodingName = options.getOrDefault(PROP_ENCODING, GeneralUtils.UTF8_ENCODING);
Charset charset;
try {
charset = Charset.forName(encodingName);
} catch (Exception e) {
log.warn(e);
charset = Charset.defaultCharset();
}
attribute.setTransformHandler(new BinaryValueHandler(attribute.getValueHandler(), charset, formatter));
}
use of org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString in project dbeaver by serge-rider.
the class BinaryAttributeTransformer method transformAttribute.
@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, Object> options) throws DBException {
DBPDataSource dataSource = session.getDataSource();
String formatterId = CommonUtils.toString(options.get(PROP_FORMAT), FORMAT_HEX);
DBDBinaryFormatter formatter;
if (FORMAT_NATIVE.equals(formatterId)) {
formatter = dataSource.getSQLDialect().getNativeBinaryFormatter();
} else {
formatter = DBValueFormatting.getBinaryPresentation(formatterId);
}
if (formatter == null) {
formatter = new BinaryFormatterString();
}
String encodingName = CommonUtils.toString(options.get(PROP_ENCODING), GeneralUtils.UTF8_ENCODING);
Charset charset;
try {
charset = Charset.forName(encodingName);
} catch (Exception e) {
log.warn(e);
charset = Charset.defaultCharset();
}
attribute.setTransformHandler(new BinaryValueHandler(attribute.getValueHandler(), charset, formatter));
}
use of org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString in project dbeaver by dbeaver.
the class BinaryAttributeTransformer method transformAttribute.
@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, Object> options) throws DBException {
DBPDataSource dataSource = session.getDataSource();
String formatterId = CommonUtils.toString(options.get(PROP_FORMAT), FORMAT_HEX);
DBDBinaryFormatter formatter;
if (FORMAT_NATIVE.equals(formatterId)) {
formatter = dataSource.getSQLDialect().getNativeBinaryFormatter();
} else {
formatter = DBValueFormatting.getBinaryPresentation(formatterId);
}
if (formatter == null) {
formatter = new BinaryFormatterString();
}
String encodingName = CommonUtils.toString(options.get(PROP_ENCODING), GeneralUtils.UTF8_ENCODING);
Charset charset;
try {
charset = Charset.forName(encodingName);
} catch (Exception e) {
log.warn(e);
charset = Charset.defaultCharset();
}
attribute.setTransformHandler(new BinaryValueHandler(attribute.getValueHandler(), charset, formatter));
}
Aggregations