/** * Auto-detects / guesses the type converters to be applied on a table. This * method will query the String columns of a table in order to assert which * columns are likely candidates for conversion. * * As such this method is not guaranteed to pick the correct converters, * since data can change over time or other conversions can be requested. * * @param dataContext * the DataContext that holds the data. * @param table * the table to inspect to find type conversion candidates. This * table will hold all columns of the result. * @param sampleSize * the max amount of rows to query for doing auto-detection. Use * {@link Integer#MAX_VALUE} if no constraint should be put on * the number of records to sample. * @return a map of {@link Column}s and {@link TypeConverter}s which can be * used (eg. with the {@link #addTypeConverters(DataContext, Map)} * method) to decorate the DataContext with type converters. */ public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext dataContext, Table table, int sampleSize) { final Map<Column, TypeConverter<?, ?>> result = new HashMap<Column, TypeConverter<?, ?>>(); List<Column> columns = table.getColumnsOfSuperType(SuperColumnType.LITERAL_TYPE); autoDetectConvertersInternally(dataContext, table, columns, sampleSize, result); return result; }
/** * Auto-detects / guesses the type converters to be applied on a table. This * method will query the String columns of a table in order to assert which * columns are likely candidates for conversion. * * As such this method is not guaranteed to pick the correct converters, * since data can change over time or other conversions can be requested. * * @param dataContext * the DataContext that holds the data. * @param table * the table to inspect to find type conversion candidates. This * table will hold all columns of the result. * @param sampleSize * the max amount of rows to query for doing auto-detection. Use * {@link Integer#MAX_VALUE} if no constraint should be put on * the number of records to sample. * @return a map of {@link Column}s and {@link TypeConverter}s which can be * used (eg. with the {@link #addTypeConverters(DataContext, Map)} * method) to decorate the DataContext with type converters. */ public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext dataContext, Table table, int sampleSize) { final Map<Column, TypeConverter<?, ?>> result = new HashMap<Column, TypeConverter<?, ?>>(); List<Column> columns = table.getColumnsOfSuperType(SuperColumnType.LITERAL_TYPE); autoDetectConvertersInternally(dataContext, table, columns, sampleSize, result); return result; }