org.gageot.excel.core
Class ColumnMapRowMapper

java.lang.Object
  extended by org.gageot.excel.core.ColumnMapRowMapper
All Implemented Interfaces:
RowMapper

public class ColumnMapRowMapper
extends java.lang.Object
implements RowMapper

RowMapper implementation that creates a java.util.Map for each row, representing all columns as key-value pairs: one entry for each column, with the column name as key.

The Map implementation to use can be customized through overriding createColumnMap.

The CellMapper implementation to use can be customized through overriding createCellMapper.

Author:
David Gageot
See Also:
ExcelTemplate.readList(String)

Constructor Summary
ColumnMapRowMapper(java.lang.String[] aKeys)
           
 
Method Summary
protected  CellMapper createCellMapper(int rowNum)
          Create a CellMapper instance to be used to map cells content.
protected  java.util.Map createColumnMap(int columnCount)
          Create a Map instance to be used as column map.
 java.lang.Object mapRow(org.apache.poi.hssf.usermodel.HSSFRow row, int rowNum)
          Implementations must implement this method to map each row of data in the HSSFSheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnMapRowMapper

public ColumnMapRowMapper(java.lang.String[] aKeys)
Method Detail

mapRow

public java.lang.Object mapRow(org.apache.poi.hssf.usermodel.HSSFRow row,
                               int rowNum)
                        throws java.io.IOException
Description copied from interface: RowMapper
Implementations must implement this method to map each row of data in the HSSFSheet. This method should extract the values of the current row.

Specified by:
mapRow in interface RowMapper
Parameters:
row - the HSSFRow to map
rowNum - the number of the current row
Throws:
java.io.IOException - if a IOException is encountered getting column values (that is, there's no need to catch IOException)

createColumnMap

protected java.util.Map createColumnMap(int columnCount)
Create a Map instance to be used as column map.

By default, a linked case-insensitive Map will be created if possible, else a plain HashMap (see Spring's CollectionFactory).

Parameters:
columnCount - the column count, to be used as initial capacity for the Map
Returns:
the new Map instance
See Also:
CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(int)

createCellMapper

protected CellMapper createCellMapper(int rowNum)
Create a CellMapper instance to be used to map cells content.

By default, a java.lang.String for each cell.

Parameters:
rowNum - the number of the current row
Returns:
the new CellMapper instance
See Also:
StringCellMapper


Copyright © 2007 gageot.net. All Rights Reserved.