Search in sources :

Example 1 with BinaryFormatterString

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));
}
Also used : BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) Charset(java.nio.charset.Charset) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) SQLDataSource(org.jkiss.dbeaver.model.sql.SQLDataSource) DBCException(org.jkiss.dbeaver.model.exec.DBCException) DBException(org.jkiss.dbeaver.DBException)

Example 2 with BinaryFormatterString

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));
}
Also used : BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) Charset(java.nio.charset.Charset) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) DBException(org.jkiss.dbeaver.DBException)

Example 3 with BinaryFormatterString

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));
}
Also used : BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) Charset(java.nio.charset.Charset) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) BinaryFormatterString(org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString) DBException(org.jkiss.dbeaver.DBException)

Aggregations

Charset (java.nio.charset.Charset)3 DBException (org.jkiss.dbeaver.DBException)3 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)3 BinaryFormatterString (org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterString)3 DBCException (org.jkiss.dbeaver.model.exec.DBCException)1 SQLDataSource (org.jkiss.dbeaver.model.sql.SQLDataSource)1