use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDataType in project dbeaver by serge-rider.
the class PostgreArrayValueHandler method getValueFromObject.
@Override
public DBDCollection getValueFromObject(@NotNull DBCSession session, @NotNull DBSTypedObject type, Object object, boolean copy) throws DBCException {
if (object != null) {
String className = object.getClass().getName();
if (object instanceof String || className.equals(PostgreConstants.PG_OBJECT_CLASS)) {
PostgreDataType itemType = null;
final PostgreDataType arrayType = PostgreUtils.findDataType((PostgreDataSource) session.getDataSource(), type);
if (arrayType != null) {
itemType = arrayType.getElementType();
}
if (itemType != null) {
if (className.equals(PostgreConstants.PG_OBJECT_CLASS)) {
final Object value = PostgreUtils.extractPGObjectValue(object);
if (value == null) {
return null;
} else if (value instanceof String) {
return convertStringToArray(session, itemType, (String) value);
} else {
// Can't parse
return new JDBCCollection(itemType, DBUtils.findValueHandler(session, itemType), new Object[] { value });
}
} else if (object instanceof String) {
return convertStringToArray(session, itemType, (String) object);
}
}
}
}
return super.getValueFromObject(session, type, object, copy);
}
Aggregations