test_class.declarator: spreadsheetReader
test_class.modifier: private
test_class.original_string: private SpreadsheetReader spreadsheetReader;
test_class.type: SpreadsheetReader
test_class.var_name: spreadsheetReader
test_class.declarator: testFiles = new String[] {"/test-spreadsheet.xlsx" , "/test-spreadsheet.xls"}
test_class.modifier: private
test_class.original_string: private String[] testFiles = new String[] {"/test-spreadsheet.xlsx" , "/test-spreadsheet.xls"};
test_class.type: String[]
test_class.var_name: testFiles
test_class.file: taverna-spreadsheet-import-activity/src/test/java/org/apache/taverna/activities/spreadsheet/ExcelSpreadsheetReaderTest.java
test_class.identifier: ExcelSpreadsheetReaderTest
test_case.body: @Test
  	public void testRead() throws Exception {
  		for (int i = 0; i < testFiles.length; i++) {
  			final List<Integer> rows = new ArrayList<Integer>(Arrays.asList(0, 1, 2, 3, 4, 5));
  			spreadsheetReader.read(getClass().getResourceAsStream(testFiles[i]), new Range(0, 5),
  					new Range(0, 4), false, new SpreadsheetRowProcessor() {
  
  						public void processRow(int rowIndex, SortedMap<Integer, String> row) {
  							assertTrue(rows.remove((Integer) rowIndex));
  							List<Integer> columns = new ArrayList<Integer>(Arrays.asList(0, 1, 2,
  									3, 4));
  							for (Entry<Integer, String> cell : row.entrySet()) {
  								assertTrue(columns.remove(cell.getKey()));
  								if (rowIndex == 0) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("A", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertEquals("5.0", cell.getValue());
  									} else if (cell.getKey().equals(2)) {
  										assertEquals("C", cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("1.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 1) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("A", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertEquals("5.0", cell.getValue());
  									} else if (cell.getKey().equals(2)) {
  										assertEquals("C", cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("1.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 2) {
  									if (cell.getKey().equals(0)) {
  										assertEquals("true", cell.getValue());
  									} else if (cell.getKey().equals(1)) {
  										assertTrue("Unexpected date format: " + cell.getValue(), cell.getValue().matches("Mon Jun 15 00:00:00 ....? 2009"));
  									} else if (cell.getKey().equals(2)) {
  										assertNull(cell.getValue());
  									} else if (cell.getKey().equals(3)) {
  										assertEquals("2.0", cell.getValue());
  									} else {
  										assertNull(cell.getValue());
  									}
  								} else if (rowIndex == 3 || rowIndex == 4) {
  									if (cell.getKey().equals(4)) {
  										assertNull(cell.getValue());
  									} else {
  										assertEquals("X", cell.getValue());
  									}
  								} else if (rowIndex == 5) {
  									assertNull(cell.getValue());
  								}
  							}
  							assertTrue(columns.isEmpty());
  						}
  					});
  			assertTrue(rows.isEmpty());
  		}
  	}
test_case.class_method_signature: ExcelSpreadsheetReaderTest.testRead()
test_case.full_signature: @Test public void testRead()
test_case.identifier: testRead
test_case.invocations: asList read getResourceAsStream getClass assertTrue remove asList entrySet assertTrue remove getKey equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertEquals getValue equals getKey assertTrue getValue matches getValue equals getKey assertNull getValue equals getKey assertEquals getValue assertNull getValue equals getKey assertNull getValue assertEquals getValue assertNull getValue assertTrue isEmpty assertTrue isEmpty
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testRead()
focal_class.declarator: logger = Logger.getLogger(ExcelSpreadsheetReader.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(ExcelSpreadsheetReader.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: taverna-spreadsheet-import-activity/src/main/java/org/apache/taverna/activities/spreadsheet/ExcelSpreadsheetReader.java
focal_class.identifier: ExcelSpreadsheetReader
focal_class.interfaces: implements SpreadsheetReader
focal_class.class_method_signature: ExcelSpreadsheetReader.read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.full_signature: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.identifier: read
focal_class.modifiers: public
focal_class.parameters: (InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.return: void
focal_class.signature: void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_class.class_method_signature: ExcelSpreadsheetReader.getCellValue(Cell cell, DataFormatter dataFormatter)
focal_class.full_signature: private String getCellValue(Cell cell, DataFormatter dataFormatter)
focal_class.identifier: getCellValue
focal_class.modifiers: private
focal_class.parameters: (Cell cell, DataFormatter dataFormatter)
focal_class.return: String
focal_class.signature: String getCellValue(Cell cell, DataFormatter dataFormatter)
focal_method.body: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
  			throws SpreadsheetReadException {
  		Workbook workbook;
  		try {
  			workbook = WorkbookFactory.create(inputStream);
  		} catch (InvalidFormatException e) {
  			throw new SpreadsheetReadException(
  					"The file does not have a compatible spreadsheet format", e);
  		} catch (IOException e) {
  			throw new SpreadsheetReadException("The spreadsheet stream could not be read", e);
  		} catch (IllegalArgumentException e) {
  			throw new SpreadsheetReadException("The spreadsheet stream could not be read", e);
  		}
  
  		DataFormatter dataFormatter = new DataFormatter();
  		
  		workbook.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK);
  		Sheet sheet = workbook.getSheetAt(0);
  
  		if (rowRange.getEnd() < 0) {
  			rowRange.setEnd(sheet.getLastRowNum());
  			logger.debug("No end of row range specified, setting to " + rowRange.getEnd());
  		}
  
  		SortedMap<Integer, String> currentDataRow = new TreeMap<Integer, String>();
  
  		for (int rowIndex = rowRange.getStart(); rowIndex <= rowRange.getEnd(); rowIndex++) {
  			boolean blankRow = true;
  			if (rowRange.contains(rowIndex)) {
  				Row row = sheet.getRow(rowIndex);
  				for (int columnIndex = columnRange.getStart(); columnIndex <= columnRange.getEnd(); columnIndex++) {
  					if (columnRange.contains(columnIndex)) {
  						String value = null;
  						if (row != null) {
  							Cell cell = row.getCell(columnIndex);
  							if (cell != null) {
  								value = getCellValue(cell, dataFormatter);
  							}
  						}
  						if (value != null) {
  							blankRow = false;
  						}
  						currentDataRow.put(columnIndex, value);
  						if (columnIndex == columnRange.getEnd()) {
  							if (!ignoreBlankRows || !blankRow) {
  								rowProcessor.processRow(rowIndex, currentDataRow);
  							}
  							currentDataRow = new TreeMap<Integer, String>();
  						}
  					}
  				}
  			}
  		}
  
  	}
focal_method.class_method_signature: ExcelSpreadsheetReader.read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.full_signature: public void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.identifier: read
focal_method.invocations: create setMissingCellPolicy getSheetAt getEnd setEnd getLastRowNum debug getEnd getStart getEnd contains getRow getStart getEnd contains getCell getCellValue put getEnd processRow
focal_method.modifiers: public
focal_method.parameters: (InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)
focal_method.return: void
focal_method.signature: void read(InputStream inputStream, Range rowRange, Range columnRange, boolean ignoreBlankRows, SpreadsheetRowProcessor rowProcessor)