use of org.jkiss.dbeaver.model.data.DBDCollection in project dbeaver by serge-rider.
the class PostgreArrayValueHandler method getValueDisplayString.
@NotNull
@Override
public String getValueDisplayString(@NotNull DBSTypedObject column, Object value, @NotNull DBDDisplayFormat format) {
DBDCollection collection = (DBDCollection) value;
if (!DBUtils.isNullValue(value)) {
DBDValueHandler valueHandler = collection.getComponentValueHandler();
StringBuilder str = new StringBuilder();
str.append("{");
for (int i = 0; i < collection.getItemCount(); i++) {
if (i > 0) {
//$NON-NLS-1$
str.append(',');
}
final Object item = collection.getItem(i);
String itemString;
if (item instanceof JDBCCollection) {
// Multi-dimensional arrays case
itemString = getValueDisplayString(column, item, format);
} else {
itemString = valueHandler.getValueDisplayString(collection.getComponentType(), item, DBDDisplayFormat.NATIVE);
}
str.append(itemString);
}
str.append("}");
return str.toString();
}
return super.getValueDisplayString(column, value, format);
}
use of org.jkiss.dbeaver.model.data.DBDCollection in project dbeaver by dbeaver.
the class PostgreArrayValueHandler method getValueDisplayString.
@NotNull
@Override
public String getValueDisplayString(@NotNull DBSTypedObject column, Object value, @NotNull DBDDisplayFormat format) {
DBDCollection collection = (DBDCollection) value;
if (!DBUtils.isNullValue(value)) {
DBDValueHandler valueHandler = collection.getComponentValueHandler();
StringBuilder str = new StringBuilder();
if (format == DBDDisplayFormat.NATIVE) {
str.append("'");
}
str.append("{");
for (int i = 0; i < collection.getItemCount(); i++) {
if (i > 0) {
// $NON-NLS-1$
str.append(',');
}
final Object item = collection.getItem(i);
String itemString;
if (item instanceof JDBCCollection) {
// Multi-dimensional arrays case
itemString = getValueDisplayString(column, item, format);
} else {
itemString = valueHandler.getValueDisplayString(collection.getComponentType(), item, DBDDisplayFormat.NATIVE);
}
str.append(itemString);
}
str.append("}");
if (format == DBDDisplayFormat.NATIVE) {
str.append("'");
}
return str.toString();
}
return super.getValueDisplayString(column, value, format);
}
use of org.jkiss.dbeaver.model.data.DBDCollection in project dbeaver by serge-rider.
the class PostgreArrayValueHandler method convertArrayToString.
private String convertArrayToString(@NotNull DBSTypedObject column, Object value, @NotNull DBDDisplayFormat format, boolean nested) {
if (!DBUtils.isNullValue(value) && value instanceof DBDCollection) {
DBDCollection collection = (DBDCollection) value;
boolean isNativeFormat = format == DBDDisplayFormat.NATIVE;
boolean isStringArray = collection.getComponentType().getDataKind() == DBPDataKind.STRING;
DBDValueHandler valueHandler = collection.getComponentValueHandler();
StringBuilder str = new StringBuilder();
if (isNativeFormat && !nested) {
str.append("'");
}
str.append("{");
for (int i = 0; i < collection.getItemCount(); i++) {
if (i > 0) {
// $NON-NLS-1$
str.append(',');
}
final Object item = collection.getItem(i);
String itemString;
if (item instanceof JDBCCollection) {
// Multi-dimensional arrays case
itemString = convertArrayToString(column, item, format, true);
} else {
itemString = valueHandler.getValueDisplayString(collection.getComponentType(), item, format);
}
if (isNativeFormat) {
if (item instanceof String)
str.append('"');
str.append(SQLUtils.escapeString(collection.getComponentType().getDataSource(), itemString));
if (item instanceof String)
str.append('"');
} else {
str.append(itemString);
}
}
str.append("}");
if (isNativeFormat && !nested) {
str.append("'");
}
return str.toString();
}
return super.getValueDisplayString(column, value, format);
}
Aggregations