private void writeHeaders(ResultSet resultSet) throws SQLException, IOException { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs final ResultSetMetaData meta = resultSet.getMetaData(); final int numberOfColumns = meta.getColumnCount(); final List<Object> headers = new LinkedList<Object>(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { headers.add(meta.getColumnName(columnIndex)); } super.writeRow(headers); }
/** * {@inheritDoc} */ public void writeHeader(final String... header) throws IOException { // update the current row/line numbers incrementRowAndLineNo(); writeRow(header); }
private void writeContents(ResultSet resultSet) throws SQLException, IOException { final int numberOfColumns = resultSet.getMetaData().getColumnCount(); final List<Object> objects = new LinkedList<Object>(); while( resultSet.next() ) { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs objects.clear(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { objects.add(resultSet.getObject(columnIndex)); } super.writeRow(objects); } }
/** * {@inheritDoc} */ public void write(List<?> columns) throws IOException { super.incrementRowAndLineNo(); super.writeRow(columns); }
/** * {@inheritDoc} */ public void write(final Object... columns) throws IOException { super.incrementRowAndLineNo(); super.writeRow(columns); }
/** * {@inheritDoc} */ public void write(final String... columns) throws IOException { super.incrementRowAndLineNo(); super.writeRow(columns); } }
/** * Writes a List of columns as a line to the CsvWriter. * * @param columns * the columns to write * @throws IllegalArgumentException * if columns.size == 0 * @throws IOException * If an I/O error occurs * @throws NullPointerException * if columns is null */ protected void writeRow(final List<?> columns) throws IOException { writeRow(Util.objectListToStringArray(columns)); }
/** * Writes one or more Object columns as a line to the CsvWriter. * * @param columns * the columns to write * @throws IllegalArgumentException * if columns.length == 0 * @throws IOException * If an I/O error occurs * @throws NullPointerException * if columns is null */ protected void writeRow(final Object... columns) throws IOException { writeRow(Util.objectArrayToStringArray(columns)); }
/** * {@inheritDoc} */ public void write(final Object source, final String... nameMapping) throws IOException { // update the current row/line numbers super.incrementRowAndLineNo(); // extract the bean values extractBeanValues(source, nameMapping); // write the list super.writeRow(beanValues); }
private void writeContents(ResultSet resultSet, CellProcessor[] writeProcessors) throws SQLException, IOException { final int numberOfColumns = resultSet.getMetaData().getColumnCount(); final List<Object> objects = new LinkedList<Object>(); final List<Object> processedColumns = new LinkedList<Object>(); while( resultSet.next() ) { super.incrementRowAndLineNo(); // This will allow the correct row/line numbers to be used in any exceptions // thrown before writing occurs objects.clear(); for( int columnIndex = 1; columnIndex <= numberOfColumns; columnIndex++ ) { objects.add(resultSet.getObject(columnIndex)); } Util.executeCellProcessors(processedColumns, objects, writeProcessors, getLineNumber(), getRowNumber()); super.writeRow(processedColumns); } } }
/** * {@inheritDoc} */ public void write(final Map<String, ?> values, final String... nameMapping) throws IOException { super.incrementRowAndLineNo(); super.writeRow(Util.filterMapToObjectArray(values, nameMapping)); }
/** * {@inheritDoc} */ public void write(final Object source) throws IOException { if( source == null ) { throw new NullPointerException("object to write should not be null"); } // update the current row/line numbers super.incrementRowAndLineNo(); // extract the bean values into the List using dozer beanData.getColumns().clear(); dozerBeanMapper.map(source, beanData); // write the list super.writeRow(beanData.getColumns()); }
/** * {@inheritDoc} */ public void write(final List<?> columns, final CellProcessor[] processors) throws IOException { super.incrementRowAndLineNo(); // execute the processors for each column Util.executeCellProcessors(processedColumns, columns, processors, getLineNumber(), getRowNumber()); super.writeRow(processedColumns); }
/** * {@inheritDoc} */ public void write(final Object source, final CellProcessor[] processors) throws IOException { if( source == null ) { throw new NullPointerException("object to write should not be null"); } else if( processors == null ) { throw new NullPointerException("processors should not be null"); } // update the current row/line numbers super.incrementRowAndLineNo(); // extract the bean values into the List using dozer beanData.getColumns().clear(); dozerBeanMapper.map(source, beanData); // execute the cell processors Util.executeCellProcessors(processedColumns, beanData.getColumns(), processors, getLineNumber(), getRowNumber()); // write the list super.writeRow(processedColumns); }
/** * {@inheritDoc} */ public void write(final Map<String, ?> values, final String[] nameMapping, final CellProcessor[] processors) throws IOException { super.incrementRowAndLineNo(); // execute the processors for each column Util.executeCellProcessors(processedColumns, Util.filterMapToList(values, nameMapping), processors, getLineNumber(), getRowNumber()); super.writeRow(processedColumns); } }
/** * {@inheritDoc} */ public void write(final Object source, final String[] nameMapping, final CellProcessor[] processors) throws IOException { // update the current row/line numbers super.incrementRowAndLineNo(); // extract the bean values extractBeanValues(source, nameMapping); // execute the processors for each column Util.executeCellProcessors(processedColumns, beanValues, processors, getLineNumber(), getRowNumber()); // write the list super.writeRow(processedColumns); } }