/** * Constructs a {@link SimpleTableDef} using a {@link Table} as a prototype. * * @param table */ public SimpleTableDef(Table table) { _name = table.getName(); _columnNames = new String[table.getColumnCount()]; _columnTypes = new ColumnType[table.getColumnCount()]; for (int i = 0; i < table.getColumnCount(); i++) { Column column = table.getColumn(i); _columnNames[i] = column.getName(); _columnTypes[i] = column.getType(); } }
/** * Constructs a {@link SimpleTableDef} using a {@link Table} as a prototype. * * @param table */ public SimpleTableDef(Table table) { _name = table.getName(); _columnNames = new String[table.getColumnCount()]; _columnTypes = new ColumnType[table.getColumnCount()]; for (int i = 0; i < table.getColumnCount(); i++) { Column column = table.getColumn(i); _columnNames[i] = column.getName(); _columnTypes[i] = column.getType(); } }
private SimpleTableDef createTableDef(final Table table) { final int columnCount = table.getColumnCount(); final String[] names = new String[columnCount]; final ColumnType[] types = new ColumnType[columnCount]; for (int i = 0; i < columnCount; i++) { names[i] = table.getColumn(i).getName(); types[i] = table.getColumn(i).getType(); } return new SimpleTableDef(table.getName(), names, types); }
new Object[] { t.getName(), typeString, t.getColumnCount(), t.getRemarks() }));
new Object[] { t.getName(), typeString, t.getColumnCount(), t.getRemarks() }));
@Override public DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) { final int lineNumber = _configuration.getColumnNameLineNumber(); final int columnCount = table.getColumnCount(); final BufferedReader reader = FileHelper.getBufferedReader(_resource.read(), _configuration.getEncoding()); try { // skip column header lines for (int i = 0; i < lineNumber; i++) { String line = reader.readLine(); if (line == null) { FileHelper.safeClose(reader); return EmptyDataSet.fromColumns(columns); } } } catch (IOException e) { FileHelper.safeClose(reader); throw new MetaModelException("IOException occurred while reading from CSV resource: " + _resource, e); } final boolean failOnInconsistentRowLength = _configuration.isFailOnInconsistentRowLength(); final Integer maxRowsOrNull = (maxRows > 0 ? maxRows : null); if (_configuration.isMultilineValues()) { final CSVReader csvReader = createCsvReader(reader); return new CsvDataSet(csvReader, columns, maxRowsOrNull, columnCount, failOnInconsistentRowLength); } return new SingleLineCsvDataSet(reader, createParser(), columns, maxRowsOrNull, columnCount, failOnInconsistentRowLength); }
@Override public DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) { final int lineNumber = _configuration.getColumnNameLineNumber(); final int columnCount = table.getColumnCount(); final BufferedReader reader = FileHelper.getBufferedReader(_resource.read(), _configuration.getEncoding()); try { // skip column header lines for (int i = 0; i < lineNumber; i++) { String line = reader.readLine(); if (line == null) { FileHelper.safeClose(reader); return EmptyDataSet.fromColumns(columns); } } } catch (IOException e) { FileHelper.safeClose(reader); throw new MetaModelException("IOException occurred while reading from CSV resource: " + _resource, e); } final boolean failOnInconsistentRowLength = _configuration.isFailOnInconsistentRowLength(); final Integer maxRowsOrNull = (maxRows > 0 ? maxRows : null); if (_configuration.isMultilineValues()) { final CSVReader csvReader = createCsvReader(reader); return new CsvDataSet(csvReader, columns, maxRowsOrNull, columnCount, failOnInconsistentRowLength); } return new SingleLineCsvDataSet(reader, createParser(), columns, maxRowsOrNull, columnCount, failOnInconsistentRowLength); }